@@ -86,7 +86,7 @@ func init() {
8686}
8787
8888// getAvailableControllers get the available controllers.
89- func getAvailableControllers (exclude map [ string ] controllerHandler ) ([]controller , error ) {
89+ func getAvailableControllers () ([]controller , error ) {
9090 controllers := []controller {}
9191 controllersFile := filepath .Join (cgroupRoot , "cgroup.controllers" )
9292
@@ -116,7 +116,7 @@ func getAvailableControllers(exclude map[string]controllerHandler) ([]controller
116116
117117// AvailableControllers get string:bool map of all the available controllers.
118118func AvailableControllers (exclude map [string ]controllerHandler ) ([]string , error ) {
119- availableControllers , err := getAvailableControllers (exclude )
119+ availableControllers , err := getAvailableControllers ()
120120 if err != nil {
121121 return nil , err
122122 }
@@ -128,31 +128,6 @@ func AvailableControllers(exclude map[string]controllerHandler) ([]string, error
128128 return controllerList , nil
129129}
130130
131- func cgroupV1GetAllSubsystems () ([]string , error ) {
132- f , err := os .Open ("/proc/cgroups" )
133- if err != nil {
134- return nil , err
135- }
136- defer f .Close ()
137-
138- subsystems := []string {}
139-
140- s := bufio .NewScanner (f )
141- for s .Scan () {
142- text := s .Text ()
143- if text [0 ] != '#' {
144- parts := strings .Fields (text )
145- if len (parts ) >= 4 && parts [3 ] != "0" {
146- subsystems = append (subsystems , parts [0 ])
147- }
148- }
149- }
150- if err := s .Err (); err != nil {
151- return nil , err
152- }
153- return subsystems , nil
154- }
155-
156131func getCgroupPathForCurrentProcess () (string , error ) {
157132 path := fmt .Sprintf ("/proc/%d/cgroup" , os .Getpid ())
158133 f , err := os .Open (path )
@@ -443,23 +418,6 @@ func readCgroup2MapFile(ctr *CgroupControl, name string) (map[string][]string, e
443418 return readCgroupMapPath (p )
444419}
445420
446- func (c * CgroupControl ) createCgroupDirectory (controller string ) (bool , error ) {
447- cPath := c .getCgroupv1Path (controller )
448- err := fileutils .Exists (cPath )
449- if err == nil {
450- return false , nil
451- }
452-
453- if ! errors .Is (err , os .ErrNotExist ) {
454- return false , err
455- }
456-
457- if err := os .MkdirAll (cPath , 0o755 ); err != nil {
458- return false , fmt .Errorf ("creating cgroup for %s: %w" , controller , err )
459- }
460- return true , nil
461- }
462-
463421var TestMode bool
464422
465423func createCgroupv2Path (path string ) (deferredError error ) {
@@ -541,32 +499,6 @@ func cleanString(s string) string {
541499 return strings .Trim (s , "\n " )
542500}
543501
544- func readAcct (ctr * CgroupControl , name string ) (uint64 , error ) {
545- p := filepath .Join (ctr .getCgroupv1Path (CPUAcct ), name )
546- return readFileAsUint64 (p )
547- }
548-
549- func readAcctList (ctr * CgroupControl , name string ) ([]uint64 , error ) {
550- p := filepath .Join (ctr .getCgroupv1Path (CPUAcct ), name )
551- data , err := os .ReadFile (p )
552- if err != nil {
553- return nil , err
554- }
555- r := []uint64 {}
556- for s := range strings .SplitSeq (string (data ), " " ) {
557- s = cleanString (s )
558- if s == "" {
559- break
560- }
561- v , err := strconv .ParseUint (s , 10 , 64 )
562- if err != nil {
563- return nil , fmt .Errorf ("parsing %s: %w" , s , err )
564- }
565- r = append (r , v )
566- }
567- return r , nil
568- }
569-
570502func cpusetCopyFromParent (path string , cgroupv2 bool ) error {
571503 for _ , file := range []string {"cpuset.cpus" , "cpuset.mems" } {
572504 if _ , err := cpusetCopyFileFromParent (path , file , cgroupv2 ); err != nil {
0 commit comments