(paths map[string]string, suffix string)
| 60 | var ErrControllerNotActive = errors.New("controller is not supported") |
| 61 | |
| 62 | func 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 | |
| 92 | func subPath(path Path, subName string) Path { |
| 93 | return func(name Name) (string, error) { |
searching dependent graphs…