From 55885daa56a0278ed5b412497b3bf99f52d6c52e Mon Sep 17 00:00:00 2001 From: Srini Brahmaroutu Date: Wed, 22 Jul 2015 02:15:14 +0000 Subject: [PATCH] daemon/graphdriver/aufs fix lint errors/warnings Addresses #14756 Signed-off-by: Srini Brahmaroutu --- daemon/graphdriver/aufs/aufs.go | 20 ++++++++++++++------ daemon/graphdriver/aufs/mount.go | 1 + daemon/graphdriver/aufs/mount_linux.go | 2 -- daemon/graphdriver/aufs/mount_unsupported.go | 1 + hack/make/validate-lint | 1 + 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/daemon/graphdriver/aufs/aufs.go b/daemon/graphdriver/aufs/aufs.go index 893801a364..eac7e94a7f 100644 --- a/daemon/graphdriver/aufs/aufs.go +++ b/daemon/graphdriver/aufs/aufs.go @@ -44,6 +44,7 @@ import ( ) var ( + // ErrAufsNotSupported is returned if aufs is not supported by the host. ErrAufsNotSupported = fmt.Errorf("AUFS was not found in /proc/filesystems") incompatibleFsMagic = []graphdriver.FsMagic{ graphdriver.FsMagicBtrfs, @@ -59,13 +60,17 @@ func init() { graphdriver.Register("aufs", Init) } +// Driver contains information about the filesystem mounted. +// root of the filesystem +// sync.Mutex to protect against concurrent modifications +// active maps mount id to the count type Driver struct { root string sync.Mutex // Protects concurrent modification to active active map[string]int } -// New returns a new AUFS driver. +// Init returns a new AUFS driver. // An error is returned if AUFS is not supported. func Init(root string, options []string) (graphdriver.Driver, error) { @@ -152,6 +157,7 @@ func (*Driver) String() string { return "aufs" } +// Status returns current information about the filesystem such as root directory, number of directories mounted, etc. func (a *Driver) Status() [][2]string { ids, _ := loadIds(path.Join(a.rootPath(), "layers")) return [][2]string{ @@ -162,6 +168,7 @@ func (a *Driver) Status() [][2]string { } } +// GetMetadata not implemented func (a *Driver) GetMetadata(id string) (map[string]string, error) { return nil, nil } @@ -175,7 +182,7 @@ func (a *Driver) Exists(id string) bool { return true } -// Three folders are created for each id +// Create three folders for each id // mnt, layers, and diff func (a *Driver) Create(id, parent string) error { if err := a.createDirsFor(id); err != nil { @@ -220,7 +227,7 @@ func (a *Driver) createDirsFor(id string) error { return nil } -// Unmount and remove the dir information +// Remove will unmount and remove the given id. func (a *Driver) Remove(id string) error { // Protect the a.active from concurrent access a.Lock() @@ -259,7 +266,7 @@ func (a *Driver) Remove(id string) error { return nil } -// Return the rootfs path for the id +// Get returns the rootfs path for the id. // This will mount the dir at it's given path func (a *Driver) Get(id, mountLabel string) (string, error) { ids, err := getParentIds(a.rootPath(), id) @@ -294,6 +301,7 @@ func (a *Driver) Get(id, mountLabel string) (string, error) { return out, nil } +// Put unmounts and updates list of active mounts. func (a *Driver) Put(id string) error { // Protect the a.active from concurrent access a.Lock() @@ -407,7 +415,7 @@ func (a *Driver) mounted(id string) (bool, error) { return mountpk.Mounted(target) } -// During cleanup aufs needs to unmount all mountpoints +// Cleanup aufs and unmount all mountpoints func (a *Driver) Cleanup() error { ids, err := loadIds(path.Join(a.rootPath(), "layers")) if err != nil { @@ -454,7 +462,7 @@ func (a *Driver) aufsMount(ro []string, rw, target, mountLabel string) (err erro bp += copy(b[bp:], layer) } else { data := label.FormatMountLabel(fmt.Sprintf("append%s", layer), mountLabel) - if err = mount("none", target, "aufs", MsRemount, data); err != nil { + if err = mount("none", target, "aufs", syscall.MS_REMOUNT, data); err != nil { return } } diff --git a/daemon/graphdriver/aufs/mount.go b/daemon/graphdriver/aufs/mount.go index b82b17f2d3..d7e9bf9fd7 100644 --- a/daemon/graphdriver/aufs/mount.go +++ b/daemon/graphdriver/aufs/mount.go @@ -9,6 +9,7 @@ import ( "github.com/Sirupsen/logrus" ) +// Unmount the target specified. func Unmount(target string) error { if err := exec.Command("auplink", target, "flush").Run(); err != nil { logrus.Errorf("Couldn't run auplink before unmount: %s", err) diff --git a/daemon/graphdriver/aufs/mount_linux.go b/daemon/graphdriver/aufs/mount_linux.go index c86f1bbd63..8062bae420 100644 --- a/daemon/graphdriver/aufs/mount_linux.go +++ b/daemon/graphdriver/aufs/mount_linux.go @@ -2,8 +2,6 @@ package aufs import "syscall" -const MsRemount = syscall.MS_REMOUNT - func mount(source string, target string, fstype string, flags uintptr, data string) error { return syscall.Mount(source, target, fstype, flags, data) } diff --git a/daemon/graphdriver/aufs/mount_unsupported.go b/daemon/graphdriver/aufs/mount_unsupported.go index 0cc31d54fc..d030b06637 100644 --- a/daemon/graphdriver/aufs/mount_unsupported.go +++ b/daemon/graphdriver/aufs/mount_unsupported.go @@ -4,6 +4,7 @@ package aufs import "errors" +// MsRemount declared to specify a non-linux system mount. const MsRemount = 0 func mount(source string, target string, fstype string, flags uintptr, data string) (err error) { diff --git a/hack/make/validate-lint b/hack/make/validate-lint index d358cb8255..027100517c 100644 --- a/hack/make/validate-lint +++ b/hack/make/validate-lint @@ -14,6 +14,7 @@ packages=( builder/parser/dumper daemon/events daemon/execdriver/native/template + daemon/graphdriver/aufs daemon/network docker dockerinit