return 0;
}
-static int controller_is_accessible(const char *controller) {
- int r;
+static int controller_is_v1_accessible(const char *controller) {
+ const char *cc, *dn;
assert(controller);
- /* Checks whether a specific controller is accessible,
- * i.e. its hierarchy mounted. In the unified hierarchy all
- * controllers are considered accessible, except for the named
- * hierarchies */
-
- if (!cg_controller_is_valid(controller))
- return -EINVAL;
-
- r = cg_all_unified();
- if (r < 0)
- return r;
- if (r > 0) {
- /* We don't support named hierarchies if we are using
- * the unified hierarchy. */
-
- if (streq(controller, SYSTEMD_CGROUP_CONTROLLER))
- return 0;
-
- if (startswith(controller, "name="))
- return -EOPNOTSUPP;
-
- } else {
- const char *cc, *dn;
-
- dn = controller_to_dirname(controller);
- cc = strjoina("/sys/fs/cgroup/", dn);
+ dn = controller_to_dirname(controller);
+ cc = strjoina("/sys/fs/cgroup/", dn);
- if (laccess(cc, F_OK) < 0)
- return -errno;
- }
+ if (laccess(cc, F_OK) < 0)
+ return -errno;
return 0;
}
assert(controller);
assert(fs);
- /* Check if the specified controller is actually accessible */
- r = controller_is_accessible(controller);
+ if (!cg_controller_is_valid(controller))
+ return -EINVAL;
+
+ r = cg_all_unified();
if (r < 0)
return r;
+ if (r > 0) {
+ /* In the unified hierarchy all controllers are considered accessible,
+ * except for the named hierarchies */
+ if (startswith(controller, "name="))
+ return -EOPNOTSUPP;
+ } else {
+ /* Check if the specified controller is actually accessible */
+ r = controller_is_v1_accessible(controller);
+ if (r < 0)
+ return r;
+ }
return cg_get_path(controller, path, suffix, fs);
}
continue;
n = cgroup_controller_to_string(c);
- if (controller_is_accessible(n) >= 0)
+ if (controller_is_v1_accessible(n) >= 0)
mask |= bit;
}
}