@@ -2,7 +2,6 @@ package cgroups
2
2
3
3
import (
4
4
"fmt"
5
- "io/ioutil"
6
5
"os"
7
6
"path/filepath"
8
7
"regexp"
@@ -62,7 +61,7 @@ func (cg *CgroupV1) GetBlockIOData(pid int, cgPath string) (*rspec.LinuxBlockIO,
62
61
}
63
62
filePath = filepath .Join (cg .MountPath , "blkio" , subPath , fileName )
64
63
}
65
- contents , err := ioutil .ReadFile (filePath )
64
+ contents , err := os .ReadFile (filePath )
66
65
if err != nil {
67
66
if os .IsNotExist (err ) {
68
67
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)
237
236
}
238
237
filePath = filepath .Join (cg .MountPath , "cpu" , subPath , fileName )
239
238
}
240
- contents , err := ioutil .ReadFile (filePath )
239
+ contents , err := os .ReadFile (filePath )
241
240
if err != nil {
242
241
if os .IsNotExist (err ) {
243
242
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)
271
270
}
272
271
// CONFIG_RT_GROUP_SCHED may be not set
273
272
// 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" )
275
274
if err != nil {
276
275
return nil , err
277
276
}
@@ -280,7 +279,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
280
279
return nil , err
281
280
}
282
281
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" )
284
283
if err != nil {
285
284
return nil , err
286
285
}
@@ -304,7 +303,7 @@ func (cg *CgroupV1) GetCPUData(pid int, cgPath string) (*rspec.LinuxCPU, error)
304
303
}
305
304
filePath = filepath .Join (cg .MountPath , "cpuset" , subPath , fileName )
306
305
}
307
- contents , err := ioutil .ReadFile (filePath )
306
+ contents , err := os .ReadFile (filePath )
308
307
if err != nil {
309
308
return nil , err
310
309
}
@@ -334,7 +333,7 @@ func (cg *CgroupV1) GetDevicesData(pid int, cgPath string) ([]rspec.LinuxDeviceC
334
333
}
335
334
filePath = filepath .Join (cg .MountPath , "devices" , subPath , fileName )
336
335
}
337
- contents , err := ioutil .ReadFile (filePath )
336
+ contents , err := os .ReadFile (filePath )
338
337
if err != nil {
339
338
return nil , err
340
339
}
@@ -403,12 +402,12 @@ func inBytes(size string) (int64, error) {
403
402
// eg. ["64KB", "2MB", "1GB"]
404
403
func GetHugePageSize () ([]string , error ) {
405
404
var pageSizes []string
406
- files , err := ioutil .ReadDir ("/sys/kernel/mm/hugepages" )
405
+ entries , err := os .ReadDir ("/sys/kernel/mm/hugepages" )
407
406
if err != nil {
408
407
return pageSizes , err
409
408
}
410
- for _ , st := range files {
411
- nameArray := strings .Split (st .Name (), "-" )
409
+ for _ , entry := range entries {
410
+ nameArray := strings .Split (entry .Name (), "-" )
412
411
pageSize , err := inBytes (nameArray [1 ])
413
412
if err != nil {
414
413
return []string {}, err
@@ -457,7 +456,7 @@ func (cg *CgroupV1) GetHugepageLimitData(pid int, cgPath string) ([]rspec.LinuxH
457
456
}
458
457
filePath = filepath .Join (cg .MountPath , "hugetlb" , subPath , maxUsage )
459
458
}
460
- contents , err := ioutil .ReadFile (filePath )
459
+ contents , err := os .ReadFile (filePath )
461
460
if err != nil {
462
461
if os .IsNotExist (err ) {
463
462
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
504
503
}
505
504
filePath = filepath .Join (cg .MountPath , "memory" , subPath , fileName )
506
505
}
507
- contents , err := ioutil .ReadFile (filePath )
506
+ contents , err := os .ReadFile (filePath )
508
507
if err != nil {
509
508
if os .IsNotExist (err ) {
510
509
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,
597
596
}
598
597
filePath = filepath .Join (cg .MountPath , "net_cls" , subPath , fileName )
599
598
}
600
- contents , err := ioutil .ReadFile (filePath )
599
+ contents , err := os .ReadFile (filePath )
601
600
if err != nil {
602
601
if os .IsNotExist (err ) {
603
602
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,
624
623
}
625
624
filePath = filepath .Join (cg .MountPath , "net_prio" , subPath , fileName )
626
625
}
627
- contents , err = ioutil .ReadFile (filePath )
626
+ contents , err = os .ReadFile (filePath )
628
627
if err != nil {
629
628
return nil , err
630
629
}
@@ -668,7 +667,7 @@ func (cg *CgroupV1) GetPidsData(pid int, cgPath string) (*rspec.LinuxPids, error
668
667
}
669
668
filePath = filepath .Join (cg .MountPath , "pids" , subPath , fileName )
670
669
}
671
- contents , err := ioutil .ReadFile (filePath )
670
+ contents , err := os .ReadFile (filePath )
672
671
if err != nil {
673
672
return nil , err
674
673
}
0 commit comments