mirror of
https://github.com/containers/podman.git
synced 2026-03-19 15:18:44 -04:00
Bumps [github.com/containers/common](https://github.com/containers/common) from 0.4.2 to 0.5.0. - [Release notes](https://github.com/containers/common/releases) - [Commits](https://github.com/containers/common/compare/v0.4.2...v0.5.0) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
30 lines
630 B
Go
30 lines
630 B
Go
package util
|
|
|
|
import (
|
|
"os"
|
|
"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
|
|
}
|
|
|
|
func UID(st os.FileInfo) int {
|
|
return int(st.Sys().(*syscall.Stat_t).Uid)
|
|
}
|
|
|
|
func GID(st os.FileInfo) int {
|
|
return int(st.Sys().(*syscall.Stat_t).Gid)
|
|
}
|