diff --git a/info.go b/info.go index 85e570ce7ca..72e1050abf5 100644 --- a/info.go +++ b/info.go @@ -12,6 +12,7 @@ import ( internalUtil "github.com/containers/buildah/internal/util" putil "github.com/containers/buildah/pkg/util" "github.com/containers/buildah/util" + "github.com/containers/common/pkg/cgroups" "github.com/containers/storage" "github.com/containers/storage/pkg/system" "github.com/containers/storage/pkg/unshare" @@ -50,7 +51,7 @@ func hostInfo() map[string]interface{} { info["cpus"] = runtime.NumCPU() info["rootless"] = unshare.IsRootless() - unified, err := util.IsCgroup2UnifiedMode() + unified, err := cgroups.IsCgroup2UnifiedMode() if err != nil { logrus.Error(err, "err reading cgroups mode") } diff --git a/util/util.go b/util/util.go index 74fecf0b793..b72353af2b2 100644 --- a/util/util.go +++ b/util/util.go @@ -9,7 +9,6 @@ import ( "path/filepath" "sort" "strings" - "sync" "syscall" "github.com/containers/buildah/define" @@ -376,12 +375,6 @@ func TruncateString(str string, to int) string { return newStr } -var ( - isUnifiedOnce sync.Once - isUnified bool - isUnifiedErr error -) - // fileExistsAndNotADir - Check to see if a file exists // and that it is not a directory. func fileExistsAndNotADir(path string) (bool, error) { diff --git a/util/util_linux.go b/util/util_linux.go deleted file mode 100644 index cca1f9e7e1a..00000000000 --- a/util/util_linux.go +++ /dev/null @@ -1,20 +0,0 @@ -package util - -import ( - "syscall" - - "golang.org/x/sys/unix" -) - -// IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode. -func IsCgroup2UnifiedMode() (bool, error) { - isUnifiedOnce.Do(func() { - var st syscall.Statfs_t - if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil { - isUnified, isUnifiedErr = false, err - } else { - isUnified, isUnifiedErr = st.Type == unix.CGROUP2_SUPER_MAGIC, nil - } - }) - return isUnified, isUnifiedErr -}