[systemd-devel] [PATCH] cgroup-util: fix is_valid check to pass for unified cgroup hierchy.

Dimitri John Ledkov dimitri.j.ledkov at intel.com
Thu May 28 08:39:19 PDT 2015


It appears in /proc/self/cgroup as `0::/'
---
 src/shared/cgroup-util.c    | 4 ++++
 src/test/test-cgroup-util.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c
index c0b0ca4..eda7523 100644
--- a/src/shared/cgroup-util.c
+++ b/src/shared/cgroup-util.c
@@ -1616,6 +1616,10 @@ bool cg_controller_is_valid(const char *p, bool allow_named) {
         if (!p)
                 return false;
 
+        /* Unified cgroup */
+        if (*p == 0)
+                return true;
+
         if (allow_named) {
                 s = startswith(p, "name=");
                 if (s)
diff --git a/src/test/test-cgroup-util.c b/src/test/test-cgroup-util.c
index 4a89f64..e4c3432 100644
--- a/src/test/test-cgroup-util.c
+++ b/src/test/test-cgroup-util.c
@@ -247,7 +247,7 @@ static void test_controller_is_valid(void) {
         assert_se(cg_controller_is_valid("foobar", false));
         assert_se(cg_controller_is_valid("foo_bar", false));
         assert_se(cg_controller_is_valid("name=foo", true));
-        assert_se(!cg_controller_is_valid("", false));
+        assert_se(cg_controller_is_valid("", true));
         assert_se(!cg_controller_is_valid("name=", true));
         assert_se(!cg_controller_is_valid("=", false));
         assert_se(!cg_controller_is_valid("cpu,cpuacct", false));
-- 
2.1.4



More information about the systemd-devel mailing list