MCPcopy Index your code
hub / github.com/containerd/containerd / getCgroupPath

Function getCgroupPath

integration/client/daemon_config_linux_test.go:89–121  ·  view source on GitHub ↗

code most copy from https://github.com/opencontainers/runc

()

Source from the content-addressed store, hash-verified

87
88// code most copy from https://github.com/opencontainers/runc
89func getCgroupPath() (map[string]string, error) {
90 cgroupPath := make(map[string]string)
91 f, err := os.Open("/proc/self/mountinfo")
92 if err != nil {
93 return nil, err
94 }
95 defer f.Close()
96
97 scanner := bufio.NewScanner(f)
98 for scanner.Scan() {
99 text := scanner.Text()
100 fields := strings.Split(text, " ")
101 // Safe as mountinfo encodes mountpoints with spaces as \040.
102 _, after, _ := strings.Cut(text, " - ")
103 postSeparatorFields := strings.Fields(after)
104 numPostFields := len(postSeparatorFields)
105
106 // This is an error as we can't detect if the mount is for "cgroup"
107 if numPostFields == 0 {
108 continue
109 }
110
111 if postSeparatorFields[0] == "cgroup" {
112 // Check that the mount is properly formatted.
113 if numPostFields < 3 {
114 continue
115 }
116 cgroupPath[filepath.Base(fields[4])] = fields[4]
117 }
118 }
119
120 return cgroupPath, nil
121}
122
123// TestDaemonCustomCgroup ensures plugin.cgroup.path is not ignored
124func TestDaemonCustomCgroup(t *testing.T) {

Callers 1

TestDaemonCustomCgroupFunction · 0.85

Calls 2

CloseMethod · 0.65
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…