@@ -2,7 +2,6 @@ package cgroups
22
33import (
44 "fmt"
5- "io/ioutil"
65 "os"
76 "path/filepath"
87 "regexp"
@@ -62,7 +61,7 @@ func (cg *CgroupV1) GetBlockIOData(pid int, cgPath string) (*rspec.LinuxBlockIO,
6261 }
6362 filePath = filepath .Join (cg .MountPath , "blkio" , subPath , fileName )
6463 }
65- contents , err := ioutil .ReadFile (filePath )
64+ contents , err := os .ReadFile (filePath )
6665 if err != nil {
6766 if os .IsNotExist (err ) {
6867 return nil , specerror .NewError (specerror .CgroupsPathAttach , fmt .Errorf ("The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`" ), rspec .Version )
@@ -237,7 +236,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
237236 }
238237 filePath = filepath .Join (cg .MountPath , "cpu" , subPath , fileName )
239238 }
240- contents , err := ioutil .ReadFile (filePath )
239+ contents , err := os .ReadFile (filePath )
241240 if err != nil {
242241 if os .IsNotExist (err ) {
243242 return nil , specerror .NewError (specerror .CgroupsPathAttach , fmt .Errorf ("The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`" ), rspec .Version )
@@ -271,7 +270,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
271270 }
272271 // CONFIG_RT_GROUP_SCHED may be not set
273272 // Can always get rt data from /proc
274- contents , err := ioutil .ReadFile ("/proc/sys/kernel/sched_rt_period_us" )
273+ contents , err := os .ReadFile ("/proc/sys/kernel/sched_rt_period_us" )
275274 if err != nil {
276275 return nil , err
277276 }
@@ -280,7 +279,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
280279 return nil , err
281280 }
282281 lc .RealtimePeriod = & rtPeriod
283- contents , err = ioutil .ReadFile ("/proc/sys/kernel/sched_rt_runtime_us" )
282+ contents , err = os .ReadFile ("/proc/sys/kernel/sched_rt_runtime_us" )
284283 if err != nil {
285284 return nil , err
286285 }
@@ -304,7 +303,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
304303 }
305304 filePath = filepath .Join (cg .MountPath , "cpuset" , subPath , fileName )
306305 }
307- contents , err := ioutil .ReadFile (filePath )
306+ contents , err := os .ReadFile (filePath )
308307 if err != nil {
309308 return nil , err
310309 }
@@ -334,7 +333,7 @@ func (cg *CgroupV1) GetDevicesData(pid int, cgPath string) ([]rspec.LinuxDeviceC
334333 }
335334 filePath = filepath .Join (cg .MountPath , "devices" , subPath , fileName )
336335 }
337- contents , err := ioutil .ReadFile (filePath )
336+ contents , err := os .ReadFile (filePath )
338337 if err != nil {
339338 return nil , err
340339 }
@@ -403,12 +402,12 @@ func inBytes(size string) (int64, error) {
403402// eg. ["64KB", "2MB", "1GB"]
404403func GetHugePageSize () ([]string , error ) {
405404 var pageSizes []string
406- files , err := ioutil .ReadDir ("/sys/kernel/mm/hugepages" )
405+ entries , err := os .ReadDir ("/sys/kernel/mm/hugepages" )
407406 if err != nil {
408407 return pageSizes , err
409408 }
410- for _ , st := range files {
411- nameArray := strings .Split (st .Name (), "-" )
409+ for _ , entry := range entries {
410+ nameArray := strings .Split (entry .Name (), "-" )
412411 pageSize , err := inBytes (nameArray [1 ])
413412 if err != nil {
414413 return []string {}, err
@@ -457,7 +456,7 @@ func (cg *CgroupV1) GetHugepageLimitData(pid int, cgPath string) ([]rspec.LinuxH
457456 }
458457 filePath = filepath .Join (cg .MountPath , "hugetlb" , subPath , maxUsage )
459458 }
460- contents , err := ioutil .ReadFile (filePath )
459+ contents , err := os .ReadFile (filePath )
461460 if err != nil {
462461 if os .IsNotExist (err ) {
463462 return nil , specerror .NewError (specerror .CgroupsPathAttach , fmt .Errorf ("The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`" ), rspec .Version )
@@ -504,7 +503,7 @@ func (cg *CgroupV1) GetMemoryData(pid int, cgPath string) (*rspec.LinuxMemory, e
504503 }
505504 filePath = filepath .Join (cg .MountPath , "memory" , subPath , fileName )
506505 }
507- contents , err := ioutil .ReadFile (filePath )
506+ contents , err := os .ReadFile (filePath )
508507 if err != nil {
509508 if os .IsNotExist (err ) {
510509 return nil , specerror .NewError (specerror .CgroupsPathAttach , fmt .Errorf ("The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`" ), rspec .Version )
@@ -597,7 +596,7 @@ func (cg *CgroupV1) GetNetworkData(pid int, cgPath string) (*rspec.LinuxNetwork,
597596 }
598597 filePath = filepath .Join (cg .MountPath , "net_cls" , subPath , fileName )
599598 }
600- contents , err := ioutil .ReadFile (filePath )
599+ contents , err := os .ReadFile (filePath )
601600 if err != nil {
602601 if os .IsNotExist (err ) {
603602 return nil , specerror .NewError (specerror .CgroupsPathAttach , fmt .Errorf ("The runtime MUST consistently attach to the same place in the cgroups hierarchy given the same value of `cgroupsPath`" ), rspec .Version )
@@ -624,7 +623,7 @@ func (cg *CgroupV1) GetNetworkData(pid int, cgPath string) (*rspec.LinuxNetwork,
624623 }
625624 filePath = filepath .Join (cg .MountPath , "net_prio" , subPath , fileName )
626625 }
627- contents , err = ioutil .ReadFile (filePath )
626+ contents , err = os .ReadFile (filePath )
628627 if err != nil {
629628 return nil , err
630629 }
@@ -668,7 +667,7 @@ func (cg *CgroupV1) GetPidsData(pid int, cgPath string) (*rspec.LinuxPids, error
668667 }
669668 filePath = filepath .Join (cg .MountPath , "pids" , subPath , fileName )
670669 }
671- contents , err := ioutil .ReadFile (filePath )
670+ contents , err := os .ReadFile (filePath )
672671 if err != nil {
673672 return nil , err
674673 }
0 commit comments