ソースを参照

Merge pull request #14863 from brahmaroutu/lint_daemon_graphdriver_aufs

daemon/graphdriver/aufs fix lint errors/warnings
Jessie Frazelle 10 年 前
コミット
e06df594f5

+ 14 - 6
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
 				}
 			}

+ 1 - 0
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)

+ 0 - 2
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)
 }

+ 1 - 0
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) {

+ 1 - 0
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