summaryrefslogtreecommitdiff
path: root/src/basic
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-07-25 22:23:00 +0200
committerGitHub <noreply@github.com>2016-07-25 22:23:00 +0200
commit1a0b98c43797ce96e47b110a58f0b4c55f3256f5 (patch)
treede31763744776a796fa929009a79eafafb2d2964 /src/basic
parentc92fcc4f4375b0aebc5919311bbf703138b21918 (diff)
parent0996ef00fb5c0770d49670f81a230fcc2552af89 (diff)
Merge pull request #3589 from brauner/cgroup_namespace
Cgroup namespace
Diffstat (limited to 'src/basic')
-rw-r--r--src/basic/cgroup-util.c14
-rw-r--r--src/basic/cgroup-util.h2
-rw-r--r--src/basic/missing.h4
3 files changed, 20 insertions, 0 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 472e24b7a3..302b958d0d 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;
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h
index 14ebde5fc9..ec5c715987 100644
--- a/src/basic/cgroup-util.h
+++ b/src/basic/cgroup-util.h
@@ -222,6 +222,8 @@ int cg_mask_supported(CGroupMask *ret);
int cg_kernel_controllers(Set *controllers);
+bool cg_ns_supported(void);
+
int cg_unified(void);
void cg_unified_flush(void);
diff --git a/src/basic/missing.h b/src/basic/missing.h
index b1272f8799..f8e096605e 100644
--- a/src/basic/missing.h
+++ b/src/basic/missing.h
@@ -445,6 +445,10 @@ struct btrfs_ioctl_quota_ctl_args {
#define CGROUP2_SUPER_MAGIC 0x63677270
#endif
+#ifndef CLONE_NEWCGROUP
+#define CLONE_NEWCGROUP 0x02000000
+#endif
+
#ifndef TMPFS_MAGIC
#define TMPFS_MAGIC 0x01021994
#endif