chiark / gitweb /
cgroup: detect cgroup namespaces
authorChristian Brauner <cbrauner@suse.de>
Thu, 23 Jun 2016 09:52:45 +0000 (11:52 +0200)
committerSven Eden <yamakuzure@gmx.net>
Wed, 5 Jul 2017 06:50:49 +0000 (08:50 +0200)
- define CLONE_NEWCGROUP
- add fun to detect whether cgroup namespaces are supported

src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/missing.h

index 5e53f447d03b63c18906000f58687926c503e484..a19995051198cc6706bc01c9569aa89ff71be3e2 100644 (file)
@@ -134,6 +134,22 @@ int cg_read_event(const char *controller, const char *path, const char *event,
         return -ENOENT;
 }
 
         return -ENOENT;
 }
 
+#if 0 /// UNNEEDED by elogind
+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;
+}
+#endif //0
+
 int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
         _cleanup_free_ char *fs = NULL;
         int r;
 int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
         _cleanup_free_ char *fs = NULL;
         int r;
index 56598d22bde8b1de244d4729ecb6ea129b1377f6..2c91a86714f94fd28b34365e0d7224980dc552ef 100644 (file)
@@ -232,6 +232,8 @@ int cg_mask_supported(CGroupMask *ret);
 
 #if 0 /// UNNEEDED by elogind
 int cg_kernel_controllers(Set *controllers);
 
 #if 0 /// UNNEEDED by elogind
 int cg_kernel_controllers(Set *controllers);
+
+bool cg_ns_supported(void);
 #endif // 0
 
 int cg_unified(void);
 #endif // 0
 
 int cg_unified(void);
index f2a0e1d8b0402605ace33e5a68db283e353e5948..848495ee26c890aae5008fe56e786acc45b2704d 100644 (file)
@@ -450,6 +450,10 @@ struct btrfs_ioctl_quota_ctl_args {
 #define CGROUP2_SUPER_MAGIC 0x63677270
 #endif
 
 #define CGROUP2_SUPER_MAGIC 0x63677270
 #endif
 
+#ifndef CLONE_NEWCGROUP
+#define CLONE_NEWCGROUP 0x02000000
+#endif
+
 #ifndef TMPFS_MAGIC
 #define TMPFS_MAGIC 0x01021994
 #endif
 #ifndef TMPFS_MAGIC
 #define TMPFS_MAGIC 0x01021994
 #endif