Files
podman/vendor/go.podman.io/common/pkg/cgroupv2/cgroups_linux.go
Paul Holzinger dbfddb82cb vendor: update go.podman.io/{common,image,storage}
Update to the latest tags to make sure they all work correctly.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-09-03 17:46:02 +02:00

28 lines
527 B
Go

package cgroupv2
import (
"sync"
"syscall"
"golang.org/x/sys/unix"
)
var (
isCgroupV2Once sync.Once
isCgroupV2 bool
isCgroupV2Err error
)
// Enabled returns whether we are running on cgroup v2.
func Enabled() (bool, error) {
isCgroupV2Once.Do(func() {
var st syscall.Statfs_t
if err := syscall.Statfs("/sys/fs/cgroup", &st); err != nil {
isCgroupV2, isCgroupV2Err = false, err
} else {
isCgroupV2, isCgroupV2Err = st.Type == unix.CGROUP2_SUPER_MAGIC, nil
}
})
return isCgroupV2, isCgroupV2Err
}