From: Christian Brauner Date: Tue, 2 Feb 2021 12:46:03 +0000 (+0100) Subject: cgroups: add unified_cgroup_fd() helper X-Git-Tag: lxc-5.0.0~306^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6d15354365ef2312de5a08682b3e7e6e6b73e24f;p=thirdparty%2Flxc.git cgroups: add unified_cgroup_fd() helper Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgroup_utils.c b/src/lxc/cgroups/cgroup_utils.c index dc7813441..1ffc63fa9 100644 --- a/src/lxc/cgroups/cgroup_utils.c +++ b/src/lxc/cgroups/cgroup_utils.c @@ -98,3 +98,16 @@ int unified_cgroup_hierarchy(void) return 0; } + +int unified_cgroup_fd(int fd) +{ + + int ret; + struct statfs fs; + + ret = fstatfs(fd, &fs); + if (!ret && is_fs_type(&fs, CGROUP2_SUPER_MAGIC)) + return true; + + return false; +} diff --git a/src/lxc/cgroups/cgroup_utils.h b/src/lxc/cgroups/cgroup_utils.h index 17d7b2ffe..818eead1d 100644 --- a/src/lxc/cgroups/cgroup_utils.h +++ b/src/lxc/cgroups/cgroup_utils.h @@ -30,4 +30,6 @@ __hidden extern bool test_writeable_v2(char *mountpoint, char *path); __hidden extern int unified_cgroup_hierarchy(void); +__hidden extern int unified_cgroup_fd(int fd); + #endif /* __LXC_CGROUP_UTILS_H */