@@ -23,36 +23,14 @@ const (
2323
2424// https://www.kernel.org/doc/Documentation/cgroup-v1/cgroups.txt 
2525func  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 
5328}
5429
5530func  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. 
5634	if  ! isSubsystemAvailable (subsystem ) {
5735		return  "" , "" , NewNotFoundError (subsystem )
5836	}
0 commit comments