1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #14863 from brahmaroutu/lint_daemon_graphdriver_aufs

daemon/graphdriver/aufs fix lint errors/warnings
This commit is contained in:
Jessie Frazelle 2015-07-28 11:46:40 -07:00
commit e06df594f5
5 changed files with 17 additions and 8 deletions

View file

@ -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
}
}

View file

@ -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)

View file

@ -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)
}

View file

@ -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) {

View file

@ -14,6 +14,7 @@ packages=(
builder/parser/dumper
daemon/events
daemon/execdriver/native/template
daemon/graphdriver/aufs
daemon/network
docker
dockerinit