2021-08-23 09:14:53 -04:00
|
|
|
//go:build linux
|
2015-04-27 10:53:12 -04:00
|
|
|
// +build linux
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package aufs // import "github.com/docker/docker/daemon/graphdriver/aufs"
|
2013-11-07 07:33:31 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"os"
|
|
|
|
"path"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Return all the directories
|
|
|
|
func loadIds(root string) ([]string, error) {
|
2021-08-24 06:10:50 -04:00
|
|
|
dirs, err := os.ReadDir(root)
|
2013-11-07 07:33:31 -05:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2018-05-19 07:38:54 -04:00
|
|
|
var out []string
|
2013-11-07 07:33:31 -05:00
|
|
|
for _, d := range dirs {
|
|
|
|
if !d.IsDir() {
|
|
|
|
out = append(out, d.Name())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Read the layers file for the current id and return all the
|
|
|
|
// layers represented by new lines in the file
|
|
|
|
//
|
|
|
|
// If there are no lines in the file then the id has no parent
|
|
|
|
// and an empty slice is returned.
|
2016-04-21 12:08:37 -04:00
|
|
|
func getParentIDs(root, id string) ([]string, error) {
|
2013-11-07 07:33:31 -05:00
|
|
|
f, err := os.Open(path.Join(root, "layers", id))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
2018-05-19 07:38:54 -04:00
|
|
|
var out []string
|
2013-11-07 07:33:31 -05:00
|
|
|
s := bufio.NewScanner(f)
|
|
|
|
|
|
|
|
for s.Scan() {
|
2013-11-08 14:10:33 -05:00
|
|
|
if t := s.Text(); t != "" {
|
|
|
|
out = append(out, s.Text())
|
2013-11-07 07:33:31 -05:00
|
|
|
}
|
|
|
|
}
|
2013-11-08 14:10:33 -05:00
|
|
|
return out, s.Err()
|
2013-11-07 07:33:31 -05:00
|
|
|
}
|
2016-03-09 16:23:04 -05:00
|
|
|
|
|
|
|
func (a *Driver) getMountpoint(id string) string {
|
|
|
|
return path.Join(a.mntPath(), id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Driver) mntPath() string {
|
|
|
|
return path.Join(a.rootPath(), "mnt")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Driver) getDiffPath(id string) string {
|
|
|
|
return path.Join(a.diffPath(), id)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Driver) diffPath() string {
|
|
|
|
return path.Join(a.rootPath(), "diff")
|
|
|
|
}
|