diff --git a/common/pkg/config/default.go b/common/pkg/config/default.go index d80ad4b2b1..4ec43eea18 100644 --- a/common/pkg/config/default.go +++ b/common/pkg/config/default.go @@ -7,7 +7,6 @@ import ( "path/filepath" "regexp" "strconv" - "syscall" "github.com/containers/common/pkg/unshare" "github.com/containers/storage" @@ -113,22 +112,6 @@ const ( SeccompDefaultPath = _installPrefix + "/share/containers/seccomp.json" ) -const ( - cgroupRoot = "/sys/fs/cgroup" - _cgroup2SuperMagic = 0x63677270 -) - -// isCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode. -func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) { - var st syscall.Statfs_t - if err := syscall.Statfs(cgroupRoot, &st); err != nil { - isUnified, isUnifiedErr = false, err - } else { - isUnified, isUnifiedErr = st.Type == _cgroup2SuperMagic, nil - } - return -} - // DefaultConfig defines the default values from containers.conf func DefaultConfig() (*Config, error) { diff --git a/common/pkg/config/default_linux.go b/common/pkg/config/default_linux.go new file mode 100644 index 0000000000..b5db6ea066 --- /dev/null +++ b/common/pkg/config/default_linux.go @@ -0,0 +1,19 @@ +package config + +import ( + "syscall" +) + +// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode. +func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) { + _cgroup2SuperMagic := int64(0x63677270) + cgroupRoot := "/sys/fs/cgroup" + + var st syscall.Statfs_t + if err := syscall.Statfs(cgroupRoot, &st); err != nil { + isUnified, isUnifiedErr = false, err + } else { + isUnified, isUnifiedErr = st.Type == _cgroup2SuperMagic, nil + } + return +} diff --git a/common/pkg/config/default_unsupported.go b/common/pkg/config/default_unsupported.go new file mode 100644 index 0000000000..def6775c71 --- /dev/null +++ b/common/pkg/config/default_unsupported.go @@ -0,0 +1,8 @@ +// +build !linux + +package config + +// isCgroup2UnifiedMode returns whether we are running in cgroup2 mode. +func isCgroup2UnifiedMode() (isUnified bool, isUnifiedErr error) { + return false, nil +}