summaryrefslogtreecommitdiff
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
authorChristian Brauner <cbrauner@suse.de>2016-06-23 11:52:45 +0200
committerChristian Brauner <cbrauner@suse.de>2016-07-09 05:49:04 +0200
commit3228995c534c4cae609e97502f7c7ca1d4a14840 (patch)
tree4fdcc4a53bacbb79234f923d634d865e8d229713 /src/basic/cgroup-util.c
parentd6cdc4cd4b58cfff4b44e1201e54f05b4a38d2d4 (diff)
cgroup: detect cgroup namespaces
- define CLONE_NEWCGROUP - add fun to detect whether cgroup namespaces are supported
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r--src/basic/cgroup-util.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 7cdc97ee3c..0561a07ed9 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -134,6 +134,20 @@ int cg_read_event(const char *controller, const char *path, const char *event,
return -ENOENT;
}
+bool cg_ns_supported(void) {
+ static thread_local int enabled = -1;
+
+ if (enabled >= 0)
+ return enabled;
+
+ if (access("/proc/self/ns/cgroup", F_OK) == 0)
+ enabled = 1;
+ else
+ enabled = 0;
+
+ return enabled;
+}
+
int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
_cleanup_free_ char *fs = NULL;
int r;