chiark / gitweb /
locale: fix LC_MESSAGES variable name
[elogind.git] / src / cgls.c
index 93617ddc2fa6b77ad0df97c2bea4e57b1da416b1..2bde743acf314420c9c9c2c3375facd452a172e2 100644 (file)
@@ -106,8 +106,22 @@ int main(int argc, char *argv[]) {
                 if (path_startswith(p, "/sys/fs/cgroup")) {
                         printf("Working Directory %s:\n", p);
                         r = show_cgroup_by_path(p, NULL, 0);
-                } else
-                        r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, "/", NULL, 0);
+                } else {
+                        char *root = NULL;
+                        const char *t = NULL;
+
+                        if ((r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root)) < 0)
+                                t = "/";
+                        else {
+                                if (endswith(root, "/system"))
+                                        root[strlen(root)-7] = 0;
+
+                                t = root[0] ? root : "/";
+                        }
+
+                        r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0);
+                        free(root);
+                }
 
                 free(p);
         }