github.com/demonoid81/moby@v0.0.0-20200517203328-62dd8e17c460/daemon/graphdriver/aufs/dirs.go (about) 1 // +build linux 2 3 package aufs // import "github.com/demonoid81/moby/daemon/graphdriver/aufs" 4 5 import ( 6 "bufio" 7 "io/ioutil" 8 "os" 9 "path" 10 ) 11 12 // Return all the directories 13 func loadIds(root string) ([]string, error) { 14 dirs, err := ioutil.ReadDir(root) 15 if err != nil { 16 return nil, err 17 } 18 var out []string 19 for _, d := range dirs { 20 if !d.IsDir() { 21 out = append(out, d.Name()) 22 } 23 } 24 return out, nil 25 } 26 27 // Read the layers file for the current id and return all the 28 // layers represented by new lines in the file 29 // 30 // If there are no lines in the file then the id has no parent 31 // and an empty slice is returned. 32 func getParentIDs(root, id string) ([]string, error) { 33 f, err := os.Open(path.Join(root, "layers", id)) 34 if err != nil { 35 return nil, err 36 } 37 defer f.Close() 38 39 var out []string 40 s := bufio.NewScanner(f) 41 42 for s.Scan() { 43 if t := s.Text(); t != "" { 44 out = append(out, s.Text()) 45 } 46 } 47 return out, s.Err() 48 } 49 50 func (a *Driver) getMountpoint(id string) string { 51 return path.Join(a.mntPath(), id) 52 } 53 54 func (a *Driver) mntPath() string { 55 return path.Join(a.rootPath(), "mnt") 56 } 57 58 func (a *Driver) getDiffPath(id string) string { 59 return path.Join(a.diffPath(), id) 60 } 61 62 func (a *Driver) diffPath() string { 63 return path.Join(a.rootPath(), "diff") 64 }