Use cgroupv2 super magic from golang.org/x/sys/unix

We can use this constant from the already existing sys/unix package
instead of defining it by our own.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
Sascha Grunert 2020-01-21 16:08:26 +01:00
parent 9be64300d4
commit 2511b50800
No known key found for this signature in database
GPG Key ID: 8CE029DD1A866E52
2 changed files with 3 additions and 3 deletions

View File

@ -97,8 +97,7 @@ type controllerHandler interface {
}
const (
cgroupRoot = "/sys/fs/cgroup"
_cgroup2SuperMagic = 0x63677270
cgroupRoot = "/sys/fs/cgroup"
// CPU is the cpu controller
CPU = "cpu"
// CPUAcct is the cpuacct controller

View File

@ -12,6 +12,7 @@ import (
"syscall"
"github.com/pkg/errors"
"golang.org/x/sys/unix"
)
var (
@ -27,7 +28,7 @@ func IsCgroup2UnifiedMode() (bool, error) {
if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
isUnified, isUnifiedErr = false, err
} else {
isUnified, isUnifiedErr = st.Type == _cgroup2SuperMagic, nil
isUnified, isUnifiedErr = st.Type == unix.CGROUP2_SUPER_MAGIC, nil
}
})
return isUnified, isUnifiedErr