mirror of
https://github.com/opencontainers/runc.git
synced 2025-11-01 03:22:38 +08:00
libct/cg/utils: use fscommon.ReadFile
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/opencontainers/runc/libcontainer/cgroups/fscommon"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
@@ -79,11 +80,11 @@ func GetAllSubsystems() ([]string, error) {
|
|||||||
// - freezer: implemented in kernel 5.2
|
// - freezer: implemented in kernel 5.2
|
||||||
// We assume these are always available, as it is hard to detect availability.
|
// We assume these are always available, as it is hard to detect availability.
|
||||||
pseudo := []string{"devices", "freezer"}
|
pseudo := []string{"devices", "freezer"}
|
||||||
data, err := ioutil.ReadFile("/sys/fs/cgroup/cgroup.controllers")
|
data, err := fscommon.ReadFile("/sys/fs/cgroup", "cgroup.controllers")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
subsystems := append(pseudo, strings.Fields(string(data))...)
|
subsystems := append(pseudo, strings.Fields(data)...)
|
||||||
return subsystems, nil
|
return subsystems, nil
|
||||||
}
|
}
|
||||||
f, err := os.Open("/proc/cgroups")
|
f, err := os.Open("/proc/cgroups")
|
||||||
|
|||||||
Reference in New Issue
Block a user