Skip to content

Commit

Permalink
cgroups: add unified_cgroup_fd() helper
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
  • Loading branch information
Christian Brauner committed Feb 26, 2021
1 parent 579a0d4 commit 6870cd2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lxc/cgroups/cgroup_utils.c
Expand Up @@ -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;
}
2 changes: 2 additions & 0 deletions src/lxc/cgroups/cgroup_utils.h
Expand Up @@ -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 */

0 comments on commit 6870cd2

Please sign in to comment.