chiark / gitweb /
nspawn: introduce the new /machine/ tree in the cgroup tree and move containers there
[elogind.git] / src / cgls / cgls.c
index e649b75df605b5a53bc3c38d8fa55a83c3a5150c..e01a7b13a139d535ed57356bd1a1e7bc70263ff8 100644 (file)
@@ -171,19 +171,14 @@ int main(int argc, char *argv[]) {
                                                 arg_kernel_threads, output_flags);
                 } else {
                         char _cleanup_free_ *root = NULL;
-                        const char *t = NULL;
 
-                        r = cg_get_by_pid(SYSTEMD_CGROUP_CONTROLLER, 1, &root);
-                        if (r < 0)
-                                t = "/";
-                        else {
-                                if (endswith(root, "/system"))
-                                        root[strlen(root)-7] = 0;
-
-                                t = root[0] ? root : "/";
+                        r = cg_get_root_path(&root);
+                        if (r < 0) {
+                                log_error("Failed to get root path: %s", strerror(-r));
+                                goto finish;
                         }
 
-                        r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, t, NULL, 0,
+                        r = show_cgroup(SYSTEMD_CGROUP_CONTROLLER, root, NULL, 0,
                                         arg_kernel_threads, output_flags);
                 }
         }