+
+ return r;
+}
+
+int show_cgroup_by_path(const char *path, const char *prefix, unsigned n_columns) {
+ DIR *d;
+ char *last = NULL;
+ char *p1 = NULL, *p2 = NULL, *fn = NULL, *gn = NULL;
+ bool shown_pids = false;
+ int r;
+
+ if (n_columns <= 0)
+ n_columns = columns();
+
+ if (!prefix)
+ prefix = "";
+
+ if ((r = cg_fix_path(path, &fn)) < 0)
+ return r;
+
+ if (!(d = opendir(fn))) {
+ free(fn);
+ return -errno;
+ }
+
+ while ((r = cg_read_subgroup(d, &gn)) > 0) {
+
+ if (!shown_pids) {
+ show_cgroup_one_by_path(path, prefix, n_columns, true);
+ shown_pids = true;
+ }
+
+ if (last) {
+ printf("%s\342\224\234 %s\n", prefix, file_name_from_path(last));
+
+ if (!p1)
+ if (!(p1 = strappend(prefix, "\342\224\202 "))) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ show_cgroup_by_path(last, p1, n_columns-2);
+
+ free(last);
+ last = NULL;
+ }
+
+ r = asprintf(&last, "%s/%s", fn, gn);
+ free(gn);
+
+ if (r < 0) {
+ r = -ENOMEM;
+ goto finish;
+ }
+ }
+
+ if (r < 0)
+ goto finish;
+
+ if (!shown_pids)
+ show_cgroup_one_by_path(path, prefix, n_columns, !!last);
+
+ if (last) {
+ printf("%s\342\224\224 %s\n", prefix, file_name_from_path(last));
+
+ if (!p2)
+ if (!(p2 = strappend(prefix, " "))) {
+ r = -ENOMEM;
+ goto finish;
+ }
+
+ show_cgroup_by_path(last, p2, n_columns-2);
+ }
+
+ r = 0;
+
+finish:
+ free(p1);
+ free(p2);
+ free(last);
+ free(fn);
+
+ closedir(d);
+
+ return r;
+}
+
+int show_cgroup(const char *controller, const char *path, const char *prefix, unsigned n_columns) {
+ char *p;
+ int r;
+
+ assert(controller);
+ assert(path);
+
+ if ((r = cg_get_path(controller, path, NULL, &p)) < 0)
+ return r;
+
+ r = show_cgroup_by_path(p, prefix, n_columns);
+ free(p);
+
+ return r;