1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
29 #include <sys/types.h>
32 #include "cgroup-util.h"
37 #include "path-util.h"
39 #include "unit-name.h"
44 int cg_enumerate_processes(const char *controller, const char *path, FILE **_f) {
45 _cleanup_free_ char *fs = NULL;
51 r = cg_get_path(controller, path, "cgroup.procs", &fs);
63 int cg_read_pid(FILE *f, pid_t *_pid) {
66 /* Note that the cgroup.procs might contain duplicates! See
67 * cgroups.txt for details. */
73 if (fscanf(f, "%lu", &ul) != 1) {
78 return errno ? -errno : -EIO;
88 int cg_enumerate_subgroups(const char *controller, const char *path, DIR **_d) {
89 _cleanup_free_ char *fs = NULL;
95 /* This is not recursive! */
97 r = cg_get_path(controller, path, NULL, &fs);
109 int cg_read_subgroup(DIR *d, char **fn) {
115 FOREACH_DIRENT(de, d, return -errno) {
118 if (de->d_type != DT_DIR)
121 if (streq(de->d_name, ".") ||
122 streq(de->d_name, ".."))
125 b = strdup(de->d_name);
136 int cg_rmdir(const char *controller, const char *path) {
137 _cleanup_free_ char *p = NULL;
140 r = cg_get_path(controller, path, NULL, &p);
145 if (r < 0 && errno != ENOENT)
151 int cg_kill(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, Set *s) {
152 _cleanup_set_free_ Set *allocated_set = NULL;
159 /* This goes through the tasks list and kills them all. This
160 * is repeated until no further processes are added to the
161 * tasks list, to properly handle forking processes */
164 s = allocated_set = set_new(trivial_hash_func, trivial_compare_func);
172 _cleanup_fclose_ FILE *f = NULL;
176 r = cg_enumerate_processes(controller, path, &f);
178 if (ret >= 0 && r != -ENOENT)
184 while ((r = cg_read_pid(f, &pid)) > 0) {
186 if (ignore_self && pid == my_pid)
189 if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
192 /* If we haven't killed this process yet, kill
194 if (kill(pid, sig) < 0) {
195 if (ret >= 0 && errno != ESRCH)
197 } else if (ret == 0) {
207 r = set_put(s, LONG_TO_PTR(pid));
223 /* To avoid racing against processes which fork
224 * quicker than we can kill them we repeat this until
225 * no new pids need to be killed. */
232 int cg_kill_recursive(const char *controller, const char *path, int sig, bool sigcont, bool ignore_self, bool rem, Set *s) {
233 _cleanup_set_free_ Set *allocated_set = NULL;
234 _cleanup_closedir_ DIR *d = NULL;
242 s = allocated_set = set_new(trivial_hash_func, trivial_compare_func);
247 ret = cg_kill(controller, path, sig, sigcont, ignore_self, s);
249 r = cg_enumerate_subgroups(controller, path, &d);
251 if (ret >= 0 && r != -ENOENT)
257 while ((r = cg_read_subgroup(d, &fn)) > 0) {
258 _cleanup_free_ char *p = NULL;
260 p = strjoin(path, "/", fn, NULL);
265 r = cg_kill_recursive(controller, p, sig, sigcont, ignore_self, rem, s);
266 if (ret >= 0 && r != 0)
270 if (ret >= 0 && r < 0)
274 r = cg_rmdir(controller, path);
275 if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
282 int cg_migrate(const char *cfrom, const char *pfrom, const char *cto, const char *pto, bool ignore_self) {
284 _cleanup_set_free_ Set *s = NULL;
293 s = set_new(trivial_hash_func, trivial_compare_func);
300 _cleanup_fclose_ FILE *f = NULL;
304 r = cg_enumerate_processes(cfrom, pfrom, &f);
306 if (ret >= 0 && r != -ENOENT)
312 while ((r = cg_read_pid(f, &pid)) > 0) {
314 /* This might do weird stuff if we aren't a
315 * single-threaded program. However, we
316 * luckily know we are not */
317 if (ignore_self && pid == my_pid)
320 if (set_get(s, LONG_TO_PTR(pid)) == LONG_TO_PTR(pid))
323 r = cg_attach(cto, pto, pid);
325 if (ret >= 0 && r != -ESRCH)
332 r = set_put(s, LONG_TO_PTR(pid));
352 int cg_migrate_recursive(
360 _cleanup_closedir_ DIR *d = NULL;
369 ret = cg_migrate(cfrom, pfrom, cto, pto, ignore_self);
371 r = cg_enumerate_subgroups(cfrom, pfrom, &d);
373 if (ret >= 0 && r != -ENOENT)
379 while ((r = cg_read_subgroup(d, &fn)) > 0) {
380 _cleanup_free_ char *p = NULL;
382 p = strjoin(pfrom, "/", fn, NULL);
391 r = cg_migrate_recursive(cfrom, p, cto, pto, ignore_self, rem);
392 if (r != 0 && ret >= 0)
396 if (r < 0 && ret >= 0)
400 r = cg_rmdir(cfrom, pfrom);
401 if (r < 0 && ret >= 0 && r != -ENOENT && r != -EBUSY)
408 int cg_migrate_recursive_fallback(
423 r = cg_migrate_recursive(cfrom, pfrom, cto, pto, ignore_self, rem);
425 char prefix[strlen(pto) + 1];
427 /* This didn't work? Then let's try all prefixes of the destination */
429 PATH_FOREACH_PREFIX(prefix, pto) {
430 r = cg_migrate_recursive(cfrom, pfrom, cto, prefix, ignore_self, rem);
439 static const char *normalize_controller(const char *controller) {
443 if (streq(controller, SYSTEMD_CGROUP_CONTROLLER))
445 else if (startswith(controller, "name="))
446 return controller + 5;
451 static int join_path(const char *controller, const char *path, const char *suffix, char **fs) {
454 if (!isempty(controller)) {
455 if (!isempty(path) && !isempty(suffix))
456 t = strjoin("/sys/fs/cgroup/", controller, "/", path, "/", suffix, NULL);
457 else if (!isempty(path))
458 t = strjoin("/sys/fs/cgroup/", controller, "/", path, NULL);
459 else if (!isempty(suffix))
460 t = strjoin("/sys/fs/cgroup/", controller, "/", suffix, NULL);
462 t = strappend("/sys/fs/cgroup/", controller);
464 if (!isempty(path) && !isempty(suffix))
465 t = strjoin(path, "/", suffix, NULL);
466 else if (!isempty(path))
475 path_kill_slashes(t);
481 int cg_get_path(const char *controller, const char *path, const char *suffix, char **fs) {
483 static __thread bool good = false;
487 if (controller && !cg_controller_is_valid(controller, true))
490 if (_unlikely_(!good)) {
493 r = path_is_mount_point("/sys/fs/cgroup", false);
495 return r < 0 ? r : -ENOENT;
497 /* Cache this to save a few stat()s */
501 p = controller ? normalize_controller(controller) : NULL;
503 return join_path(p, path, suffix, fs);
506 static int check_hierarchy(const char *p) {
511 /* Check if this controller actually really exists */
512 cc = alloca(sizeof("/sys/fs/cgroup/") + strlen(p));
513 strcpy(stpcpy(cc, "/sys/fs/cgroup/"), p);
514 if (access(cc, F_OK) < 0)
520 int cg_get_path_and_check(const char *controller, const char *path, const char *suffix, char **fs) {
526 if (!cg_controller_is_valid(controller, true))
529 /* Normalize the controller syntax */
530 p = normalize_controller(controller);
532 /* Check if this controller actually really exists */
533 r = check_hierarchy(p);
537 return join_path(p, path, suffix, fs);
540 static int trim_cb(const char *path, const struct stat *sb, int typeflag, struct FTW *ftwbuf) {
545 if (typeflag != FTW_DP)
548 if (ftwbuf->level < 1)
555 int cg_trim(const char *controller, const char *path, bool delete_root) {
556 _cleanup_free_ char *fs = NULL;
561 r = cg_get_path(controller, path, NULL, &fs);
566 if (nftw(fs, trim_cb, 64, FTW_DEPTH|FTW_MOUNT|FTW_PHYS) != 0)
567 r = errno ? -errno : -EIO;
570 if (rmdir(fs) < 0 && errno != ENOENT)
577 int cg_delete(const char *controller, const char *path) {
578 _cleanup_free_ char *parent = NULL;
583 r = path_get_parent(path, &parent);
587 r = cg_migrate_recursive(controller, path, controller, parent, false, true);
588 return r == -ENOENT ? 0 : r;
591 int cg_create(const char *controller, const char *path) {
592 _cleanup_free_ char *fs = NULL;
595 r = cg_get_path_and_check(controller, path, NULL, &fs);
599 r = mkdir_parents(fs, 0755);
603 if (mkdir(fs, 0755) < 0) {
614 int cg_create_and_attach(const char *controller, const char *path, pid_t pid) {
619 r = cg_create(controller, path);
623 q = cg_attach(controller, path, pid);
627 /* This does not remove the cgroup on failure */
631 int cg_attach(const char *controller, const char *path, pid_t pid) {
632 _cleanup_free_ char *fs = NULL;
633 char c[DECIMAL_STR_MAX(pid_t) + 2];
639 r = cg_get_path_and_check(controller, path, "cgroup.procs", &fs);
646 snprintf(c, sizeof(c), "%lu\n", (unsigned long) pid);
648 return write_string_file(fs, c);
651 int cg_attach_fallback(const char *controller, const char *path, pid_t pid) {
658 r = cg_attach(controller, path, pid);
660 char prefix[strlen(path) + 1];
662 /* This didn't work? Then let's try all prefixes of
665 PATH_FOREACH_PREFIX(prefix, path) {
666 r = cg_attach(controller, prefix, pid);
675 int cg_set_group_access(
676 const char *controller,
682 _cleanup_free_ char *fs = NULL;
687 if (mode != (mode_t) -1)
690 r = cg_get_path(controller, path, NULL, &fs);
694 return chmod_and_chown(fs, mode, uid, gid);
697 int cg_set_task_access(
698 const char *controller,
704 _cleanup_free_ char *fs = NULL, *procs = NULL;
709 if (mode == (mode_t) -1 && uid == (uid_t) -1 && gid == (gid_t) -1)
712 if (mode != (mode_t) -1)
715 r = cg_get_path(controller, path, "cgroup.procs", &fs);
719 r = chmod_and_chown(fs, mode, uid, gid);
723 /* Compatibility, Always keep values for "tasks" in sync with
725 r = cg_get_path(controller, path, "tasks", &procs);
729 return chmod_and_chown(procs, mode, uid, gid);
732 int cg_pid_get_path(const char *controller, pid_t pid, char **path) {
733 _cleanup_fclose_ FILE *f = NULL;
742 if (!cg_controller_is_valid(controller, true))
745 controller = normalize_controller(controller);
747 controller = SYSTEMD_CGROUP_CONTROLLER;
750 fs = "/proc/self/cgroup";
752 fs = procfs_file_alloca(pid, "cgroup");
756 return errno == ENOENT ? -ESRCH : -errno;
758 cs = strlen(controller);
760 FOREACH_LINE(line, f, return -errno) {
768 l = strchr(line, ':');
779 FOREACH_WORD_SEPARATOR(w, k, l, ",", state) {
781 if (k == cs && memcmp(w, controller, cs) == 0) {
787 memcmp(w, "name=", 5) == 0 &&
788 memcmp(w+5, controller, cs) == 0) {
808 int cg_install_release_agent(const char *controller, const char *agent) {
809 _cleanup_free_ char *fs = NULL, *contents = NULL;
815 r = cg_get_path(controller, NULL, "release_agent", &fs);
819 r = read_one_line_file(fs, &contents);
823 sc = strstrip(contents);
825 r = write_string_file(fs, agent);
828 } else if (!streq(sc, agent))
833 r = cg_get_path(controller, NULL, "notify_on_release", &fs);
839 r = read_one_line_file(fs, &contents);
843 sc = strstrip(contents);
844 if (streq(sc, "0")) {
845 r = write_string_file(fs, "1");
858 int cg_uninstall_release_agent(const char *controller) {
859 _cleanup_free_ char *fs = NULL;
862 r = cg_get_path(controller, NULL, "notify_on_release", &fs);
866 r = write_string_file(fs, "0");
873 r = cg_get_path(controller, NULL, "release_agent", &fs);
877 r = write_string_file(fs, "");
884 int cg_is_empty(const char *controller, const char *path, bool ignore_self) {
885 _cleanup_fclose_ FILE *f = NULL;
886 pid_t pid = 0, self_pid;
892 r = cg_enumerate_processes(controller, path, &f);
894 return r == -ENOENT ? 1 : r;
898 while ((r = cg_read_pid(f, &pid)) > 0) {
900 if (ignore_self && pid == self_pid)
913 int cg_is_empty_recursive(const char *controller, const char *path, bool ignore_self) {
914 _cleanup_closedir_ DIR *d = NULL;
920 r = cg_is_empty(controller, path, ignore_self);
924 r = cg_enumerate_subgroups(controller, path, &d);
926 return r == -ENOENT ? 1 : r;
928 while ((r = cg_read_subgroup(d, &fn)) > 0) {
929 _cleanup_free_ char *p = NULL;
931 p = strjoin(path, "/", fn, NULL);
936 r = cg_is_empty_recursive(controller, p, ignore_self);
947 int cg_split_spec(const char *spec, char **controller, char **path) {
949 char *t = NULL, *u = NULL;
950 _cleanup_free_ char *v = NULL;
955 if (!path_is_safe(spec))
963 path_kill_slashes(t);
973 e = strchr(spec, ':');
975 if (!cg_controller_is_valid(spec, true))
979 t = strdup(normalize_controller(spec));
992 v = strndup(spec, e-spec);
995 t = strdup(normalize_controller(v));
998 if (!cg_controller_is_valid(t, true)) {
1003 if (streq(e+1, "")) {
1016 if (!path_is_safe(u) ||
1017 !path_is_absolute(u)) {
1023 path_kill_slashes(u);
1039 int cg_mangle_path(const char *path, char **result) {
1040 _cleanup_free_ char *c = NULL, *p = NULL;
1047 /* First check if it already is a filesystem path */
1048 if (path_startswith(path, "/sys/fs/cgroup")) {
1054 path_kill_slashes(t);
1059 /* Otherwise treat it as cg spec */
1060 r = cg_split_spec(path, &c, &p);
1064 return cg_get_path(c ? c : SYSTEMD_CGROUP_CONTROLLER, p ? p : "/", NULL, result);
1067 int cg_get_root_path(char **path) {
1073 r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, 1, &p);
1077 e = endswith(p, "/" SPECIAL_SYSTEM_SLICE);
1085 int cg_pid_get_path_shifted(pid_t pid, const char *root, char **cgroup) {
1086 _cleanup_free_ char *cg_root = NULL;
1087 char *cg_process, *p;
1094 /* If the root was specified let's use that, otherwise
1095 * let's determine it from PID 1 */
1097 r = cg_get_root_path(&cg_root);
1104 r = cg_pid_get_path(SYSTEMD_CGROUP_CONTROLLER, pid, &cg_process);
1108 p = path_startswith(cg_process, root);
1120 *cgroup = cg_process;
1125 int cg_path_decode_unit(const char *cgroup, char **unit){
1131 e = strchrnul(cgroup, '/');
1132 c = strndupa(cgroup, e - cgroup);
1135 if (!unit_name_is_valid(c, false))
1146 static const char *skip_slices(const char *p) {
1147 /* Skips over all slice assignments */
1152 p += strspn(p, "/");
1154 n = strcspn(p, "/");
1155 if (n <= 6 || memcmp(p + n - 6, ".slice", 6) != 0)
1162 int cg_path_get_unit(const char *path, char **unit) {
1168 e = skip_slices(path);
1170 return cg_path_decode_unit(e, unit);
1173 int cg_pid_get_unit(pid_t pid, char **unit) {
1174 _cleanup_free_ char *cgroup = NULL;
1179 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1183 return cg_path_get_unit(cgroup, unit);
1186 static const char *skip_session(const char *p) {
1191 p += strspn(p, "/");
1193 n = strcspn(p, "/");
1194 if (n <= 12 || memcmp(p, "session-", 8) != 0 || memcmp(p + n - 6, ".scope", 6) != 0)
1198 p += strspn(p, "/");
1203 int cg_path_get_user_unit(const char *path, char **unit) {
1209 /* We always have to parse the path from the beginning as unit
1210 * cgroups might have arbitrary child cgroups and we shouldn't get
1211 * confused by those */
1213 /* Skip slices, if there are any */
1214 e = skip_slices(path);
1216 /* Skip the session scope, require that there is one */
1217 e = skip_session(e);
1221 /* And skip more slices */
1224 return cg_path_decode_unit(e, unit);
1227 int cg_pid_get_user_unit(pid_t pid, char **unit) {
1228 _cleanup_free_ char *cgroup = NULL;
1233 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1237 return cg_path_get_user_unit(cgroup, unit);
1240 int cg_path_get_machine_name(const char *path, char **machine) {
1241 const char *e, *n, *x;
1248 /* Skip slices, if there are any */
1249 e = skip_slices(path);
1251 n = strchrnul(e, '/');
1255 s = strndupa(e, n - e);
1258 x = startswith(s, "machine-");
1261 if (!endswith(x, ".scope"))
1268 r = strndup(x, l - 6);
1276 int cg_pid_get_machine_name(pid_t pid, char **machine) {
1277 _cleanup_free_ char *cgroup = NULL;
1282 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1286 return cg_path_get_machine_name(cgroup, machine);
1289 int cg_path_get_session(const char *path, char **session) {
1290 const char *e, *n, *x;
1297 /* Skip slices, if there are any */
1298 e = skip_slices(path);
1300 n = strchrnul(e, '/');
1304 s = strndupa(e, n - e);
1307 x = startswith(s, "session-");
1310 if (!endswith(x, ".scope"))
1317 r = strndup(x, l - 6);
1325 int cg_pid_get_session(pid_t pid, char **session) {
1326 _cleanup_free_ char *cgroup = NULL;
1331 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1335 return cg_path_get_session(cgroup, session);
1338 int cg_path_get_owner_uid(const char *path, uid_t *uid) {
1339 _cleanup_free_ char *slice = NULL;
1340 const char *start, *end;
1347 r = cg_path_get_slice(path, &slice);
1351 start = startswith(slice, "user-");
1354 end = endswith(slice, ".slice");
1358 s = strndupa(start, end - start);
1362 if (parse_uid(s, &u) < 0)
1371 int cg_pid_get_owner_uid(pid_t pid, uid_t *uid) {
1372 _cleanup_free_ char *cgroup = NULL;
1375 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1379 return cg_path_get_owner_uid(cgroup, uid);
1382 int cg_path_get_slice(const char *p, char **slice) {
1383 const char *e = NULL;
1392 p += strspn(p, "/");
1394 n = strcspn(p, "/");
1395 if (n <= 6 || memcmp(p + n - 6, ".slice", 6) != 0) {
1416 int cg_pid_get_slice(pid_t pid, char **slice) {
1417 _cleanup_free_ char *cgroup = NULL;
1422 r = cg_pid_get_path_shifted(pid, NULL, &cgroup);
1426 return cg_path_get_slice(cgroup, slice);
1429 char *cg_escape(const char *p) {
1430 bool need_prefix = false;
1432 /* This implements very minimal escaping for names to be used
1433 * as file names in the cgroup tree: any name which might
1434 * conflict with a kernel name or is prefixed with '_' is
1435 * prefixed with a '_'. That way, when reading cgroup names it
1436 * is sufficient to remove a single prefixing underscore if
1439 /* The return value of this function (unlike cg_unescape())
1445 streq(p, "notify_on_release") ||
1446 streq(p, "release_agent") ||
1452 dot = strrchr(p, '.');
1455 if (dot - p == 6 && memcmp(p, "cgroup", 6) == 0)
1460 n = strndupa(p, dot - p);
1462 if (check_hierarchy(n) >= 0)
1469 return strappend("_", p);
1474 char *cg_unescape(const char *p) {
1477 /* The return value of this function (unlike cg_escape())
1478 * doesn't need free()! */
1486 #define CONTROLLER_VALID \
1490 bool cg_controller_is_valid(const char *p, bool allow_named) {
1497 s = startswith(p, "name=");
1502 if (*p == 0 || *p == '_')
1505 for (t = p; *t; t++)
1506 if (!strchr(CONTROLLER_VALID, *t))
1509 if (t - p > FILENAME_MAX)
1515 int cg_slice_to_path(const char *unit, char **ret) {
1516 _cleanup_free_ char *p = NULL, *s = NULL, *e = NULL;
1522 if (!unit_name_is_valid(unit, false))
1525 if (!endswith(unit, ".slice"))
1528 p = unit_name_to_prefix(unit);
1532 dash = strchr(p, '-');
1534 _cleanup_free_ char *escaped = NULL;
1535 char n[dash - p + sizeof(".slice")];
1537 strcpy(stpncpy(n, p, dash - p), ".slice");
1539 if (!unit_name_is_valid(n, false))
1542 escaped = cg_escape(n);
1546 if (!strextend(&s, escaped, "/", NULL))
1549 dash = strchr(dash+1, '-');
1552 e = cg_escape(unit);
1556 if (!strextend(&s, e, NULL))
1565 int cg_set_attribute(const char *controller, const char *path, const char *attribute, const char *value) {
1566 _cleanup_free_ char *p = NULL;
1569 r = cg_get_path(controller, path, attribute, &p);
1573 return write_string_file(p, value);
1576 static const char mask_names[] =
1583 int cg_create_everywhere(CGroupControllerMask supported, CGroupControllerMask mask, const char *path) {
1584 CGroupControllerMask bit = 1;
1588 /* This one will create a cgroup in our private tree, but also
1589 * duplicate it in the trees specified in mask, and remove it
1592 /* First create the cgroup in our own hierarchy. */
1593 r = cg_create(SYSTEMD_CGROUP_CONTROLLER, path);
1597 /* Then, do the same in the other hierarchies */
1598 NULSTR_FOREACH(n, mask_names) {
1601 else if (supported & bit)
1602 cg_trim(n, path, true);
1610 int cg_attach_everywhere(CGroupControllerMask supported, const char *path, pid_t pid) {
1611 CGroupControllerMask bit = 1;
1615 r = cg_attach(SYSTEMD_CGROUP_CONTROLLER, path, pid);
1619 NULSTR_FOREACH(n, mask_names) {
1620 if (supported & bit)
1621 cg_attach_fallback(n, path, pid);
1629 int cg_attach_many_everywhere(CGroupControllerMask supported, const char *path, Set* pids) {
1634 SET_FOREACH(pidp, pids, i) {
1635 pid_t pid = PTR_TO_LONG(pidp);
1638 q = cg_attach_everywhere(supported, path, pid);
1646 int cg_migrate_everywhere(CGroupControllerMask supported, const char *from, const char *to) {
1647 CGroupControllerMask bit = 1;
1651 if (!path_equal(from, to)) {
1652 r = cg_migrate_recursive(SYSTEMD_CGROUP_CONTROLLER, from, SYSTEMD_CGROUP_CONTROLLER, to, false, true);
1657 NULSTR_FOREACH(n, mask_names) {
1658 if (supported & bit)
1659 cg_migrate_recursive_fallback(SYSTEMD_CGROUP_CONTROLLER, to, n, to, false, false);
1667 int cg_trim_everywhere(CGroupControllerMask supported, const char *path, bool delete_root) {
1668 CGroupControllerMask bit = 1;
1672 r = cg_trim(SYSTEMD_CGROUP_CONTROLLER, path, delete_root);
1676 NULSTR_FOREACH(n, mask_names) {
1677 if (supported & bit)
1678 cg_trim(n, path, delete_root);
1686 CGroupControllerMask cg_mask_supported(void) {
1687 CGroupControllerMask bit = 1, mask = 0;
1690 NULSTR_FOREACH(n, mask_names) {
1691 if (check_hierarchy(n) >= 0)