cgroups: move cgns_supported() to cgroup utilities

parent 4b946797
......@@ -27,7 +27,8 @@
#include "af_unix.h"
#include "attach.h"
#include "caps.h"
#include "cgroup.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
#include "commands.h"
#include "conf.h"
#include "config.h"
......
......@@ -7,6 +7,7 @@
#include <stdio.h>
#include "compiler.h"
#include "file_utils.h"
/* Retrieve the cgroup version of a given entry from /proc/<pid>/mountinfo. */
__hidden extern int get_cgroup_version(char *line);
......@@ -32,4 +33,14 @@ __hidden extern int unified_cgroup_hierarchy(void);
__hidden extern int unified_cgroup_fd(int fd);
static inline bool cgns_supported(void)
{
static int supported = -1;
if (supported == -1)
supported = file_exists("/proc/self/ns/cgroup");
return supported == 1;
}
#endif /* __LXC_CGROUP_UTILS_H */
......@@ -13,6 +13,7 @@
#include <unistd.h>
#include "caps.h"
#include "cgroups/cgroup_utils.h"
#include "conf.h"
#include "config.h"
#include "initutils.h"
......
......@@ -27,7 +27,8 @@
#include "af_unix.h"
#include "caps.h"
#include "cgroup.h"
#include "cgroups/cgroup.h"
#include "cgroups/cgroup_utils.h"
#include "commands.h"
#include "commands_utils.h"
#include "compiler.h"
......
......@@ -747,11 +747,6 @@ char *on_path(const char *cmd, const char *rootfs)
return NULL;
}
bool cgns_supported(void)
{
return file_exists("/proc/self/ns/cgroup");
}
/* historically lxc-init has been under /usr/lib/lxc and under
* /usr/lib/$ARCH/lxc. It now lives as $prefix/sbin/init.lxc.
*/
......
......@@ -138,7 +138,6 @@ __hidden extern bool is_shared_mountpoint(const char *path);
__hidden extern int detect_shared_rootfs(void);
__hidden extern bool detect_ramfs_rootfs(void);
__hidden extern char *on_path(const char *cmd, const char *rootfs);
__hidden extern bool cgns_supported(void);
__hidden extern char *choose_init(const char *rootfs);
__hidden extern bool switch_to_ns(pid_t pid, const char *ns);
__hidden extern char *get_template_path(const char *t);
......
......@@ -37,6 +37,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include "cgroups/cgroup_utils.h"
#include "lxctest.h"
#include "namespace.h"
#include "process_utils.h"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment