+
+ return r;
+}
+
+int show_cgroup(const char *path, const char *prefix, unsigned n_columns) {
+ return show_cgroup_full(path, prefix, n_columns, false);
+}
+
+int show_cgroup_recursive(const char *path, const char *prefix, unsigned n_columns) {
+ DIR *d;
+ char *last = NULL;
+ char *p1 = NULL, *p2 = NULL, *fn = NULL;
+ struct dirent *de;
+ bool shown_pids = false;
+ int r;
+
+ if (n_columns <= 0)
+ n_columns = columns();
+
+ if (!prefix)
+ prefix = "";
+
+ if (!(fn = get_cgroup_path(path)))
+ return -ENOMEM;
+
+ if (!(d = opendir(fn))) {
+ free(fn);
+ return -errno;
+ }
+
+ while ((de = readdir(d))) {
+
+ if (de->d_type != DT_DIR)
+ continue;
+
+ if (ignore_file(de->d_name))
+ continue;
+
+ if (!shown_pids) {
+ show_cgroup_full(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_recursive(last, p1, n_columns-2);
+
+ free(last);
+ last = NULL;
+ }
+
+ if (asprintf(&last, "%s/%s", strempty(path), de->d_name) < 0) {
+ r = -ENOMEM;
+ goto finish;
+ }
+ }
+
+ if (!shown_pids)
+ show_cgroup_full(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_recursive(last, p2, n_columns-2);
+ }
+
+ r = 0;
+
+finish:
+ free(p1);
+ free(p2);
+ free(last);
+ free(fn);
+
+ closedir(d);
+
+ return r;