MCPcopy Create free account
hub / github.com/containerd/cgroups / existingPath

Function existingPath

cgroup1/paths.go:62–90  ·  view source on GitHub ↗
(paths map[string]string, suffix string)

Source from the content-addressed store, hash-verified

60var ErrControllerNotActive = errors.New("controller is not supported")
61
62func existingPath(paths map[string]string, suffix string) Path {
63 // localize the paths based on the root mount dest for nested cgroups
64 for n, p := range paths {
65 dest, err := getCgroupDestination(n)
66 if err != nil {
67 return errorPath(err)
68 }
69 rel, err := filepath.Rel(dest, p)
70 if err != nil {
71 return errorPath(err)
72 }
73 if rel == "." {
74 rel = dest
75 }
76 paths[n] = filepath.Join("/", rel)
77 }
78 return func(name Name) (string, error) {
79 root, ok := paths[string(name)]
80 if !ok {
81 if root, ok = paths["name="+string(name)]; !ok {
82 return "", ErrControllerNotActive
83 }
84 }
85 if suffix != "" {
86 return filepath.Join(root, suffix), nil
87 }
88 return root, nil
89 }
90}
91
92func subPath(path Path, subName string) Path {
93 return func(name Name) (string, error) {

Callers 3

NestedPathFunction · 0.85
PidPathFunction · 0.85
TestSystemd240Function · 0.85

Calls 2

getCgroupDestinationFunction · 0.85
errorPathFunction · 0.85

Tested by 1

TestSystemd240Function · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…