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