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

Function v1MountPoint

cgroup1/v1.go:49–73  ·  view source on GitHub ↗

v1MountPoint returns the mount point where the cgroup mountpoints are mounted in a single hierarchy

()

Source from the content-addressed store, hash-verified

47// v1MountPoint returns the mount point where the cgroup
48// mountpoints are mounted in a single hierarchy
49func v1MountPoint() (string, error) {
50 f, err := os.Open("/proc/self/mountinfo")
51 if err != nil {
52 return "", err
53 }
54 defer f.Close()
55 scanner := bufio.NewScanner(f)
56 for scanner.Scan() {
57 var (
58 text = scanner.Text()
59 fields = strings.Split(text, " ")
60 numFields = len(fields)
61 )
62 if numFields < 10 {
63 return "", fmt.Errorf("mountinfo: bad entry %q", text)
64 }
65 if fields[numFields-3] == "cgroup" {
66 return filepath.Dir(fields[4]), nil
67 }
68 }
69 if err := scanner.Err(); err != nil {
70 return "", err
71 }
72 return "", ErrMountPointNotExist
73}

Callers 4

DefaultFunction · 0.85
SystemdFunction · 0.85
TestSelfPathFunction · 0.85
TestPidPathFunction · 0.85

Calls

no outgoing calls

Tested by 2

TestSelfPathFunction · 0.68
TestPidPathFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…