@@ -23,36 +23,14 @@ const (
23
23
24
24
// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt
25
25
func FindCgroupMountpoint (subsystem string ) (string , error ) {
26
- // We are not using mount.GetMounts() because it's super-inefficient,
27
- // parsing it directly sped up x10 times because of not using Sscanf.
28
- // It was one of two major performance drawbacks in container start.
29
- if ! isSubsystemAvailable (subsystem ) {
30
- return "" , NewNotFoundError (subsystem )
31
- }
32
- f , err := os .Open ("/proc/self/mountinfo" )
33
- if err != nil {
34
- return "" , err
35
- }
36
- defer f .Close ()
37
-
38
- scanner := bufio .NewScanner (f )
39
- for scanner .Scan () {
40
- txt := scanner .Text ()
41
- fields := strings .Split (txt , " " )
42
- for _ , opt := range strings .Split (fields [len (fields )- 1 ], "," ) {
43
- if opt == subsystem {
44
- return fields [4 ], nil
45
- }
46
- }
47
- }
48
- if err := scanner .Err (); err != nil {
49
- return "" , err
50
- }
51
-
52
- return "" , NewNotFoundError (subsystem )
26
+ mnt , _ , err := FindCgroupMountpointAndRoot (subsystem )
27
+ return mnt , err
53
28
}
54
29
55
30
func FindCgroupMountpointAndRoot (subsystem string ) (string , string , error ) {
31
+ // We are not using mount.GetMounts() because it's super-inefficient,
32
+ // parsing it directly sped up x10 times because of not using Sscanf.
33
+ // It was one of two major performance drawbacks in container start.
56
34
if ! isSubsystemAvailable (subsystem ) {
57
35
return "" , "" , NewNotFoundError (subsystem )
58
36
}
0 commit comments