The argument is not used anymore. Let's drop it.
_cleanup_free_ char *fs = NULL;
int r;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, /* suffix= */ NULL, &fs);
+ r = cg_get_path(path, /* suffix= */ NULL, &fs);
if (r < 0)
return r;
assert(ret);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "cgroup.procs", &fs);
+ r = cg_get_path(path, "cgroup.procs", &fs);
if (r < 0)
return r;
/* This is not recursive! */
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
if (!cg_kill_supported())
return -EOPNOTSUPP;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "cgroup.kill", &killfile);
+ r = cg_get_path(path, "cgroup.kill", &killfile);
if (r < 0)
return r;
return 0;
}
-int cg_get_path(const char *controller, const char *path, const char *suffix, char **ret) {
+int cg_get_path(const char *path, const char *suffix, char **ret) {
char *t;
assert(ret);
if (isempty(path))
path = TAKE_PTR(suffix);
- if (controller)
- t = path_join("/sys/fs/cgroup", path, suffix);
- else
- t = path_join(path, suffix);
+ t = path_join("/sys/fs/cgroup", path, suffix);
if (!t)
return -ENOMEM;
assert(name);
assert(value || size <= 0);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
assert(path);
assert(name);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
assert(path);
assert(name);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
assert(path);
assert(name);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
}
int cg_mangle_path(const char *path, char **ret) {
- _cleanup_free_ char *c = NULL, *p = NULL;
+ _cleanup_free_ char *p = NULL;
int r;
assert(path);
return path_simplify_alloc(path, ret);
/* Otherwise, treat it as cg spec */
- r = cg_split_spec(path, &c, &p);
+ r = cg_split_spec(path, /* ret_controller = */ NULL, &p);
if (r < 0)
return r;
- return cg_get_path(c ?: SYSTEMD_CGROUP_CONTROLLER, p ?: "/", NULL, ret);
+ return cg_get_path(p, /* suffix = */ NULL, ret);
}
int cg_get_root_path(char **ret_path) {
_cleanup_strv_free_ char **v = NULL;
int r;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "cgroup.type", &fs);
+ r = cg_get_path(path, "cgroup.type", &fs);
if (r < 0)
return r;
assert(attribute);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, attribute, &p);
+ r = cg_get_path(path, attribute, &p);
if (r < 0)
return r;
assert(attribute);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, attribute, &p);
+ r = cg_get_path(path, attribute, &p);
if (r < 0)
return r;
assert(ret_uid);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &f);
+ r = cg_get_path(path, /* suffix = */ NULL, &f);
if (r < 0)
return r;
*
* If the attribute file doesn't exist at all returns ENOENT, if any key is not found returns ENXIO. */
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, attribute, &filename);
+ r = cg_get_path(path, attribute, &filename);
if (r < 0)
return r;
/* We can read the supported and accessible controllers from the top-level cgroup attribute */
_cleanup_free_ char *controllers = NULL, *path = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, root, "cgroup.controllers", &path);
+ r = cg_get_path(root, "cgroup.controllers", &path);
if (r < 0)
return r;
int cg_split_spec(const char *spec, char **ret_controller, char **ret_path);
int cg_mangle_path(const char *path, char **ret);
-int cg_get_path(const char *controller, const char *path, const char *suffix, char **ret);
+int cg_get_path(const char *path, const char *suffix, char **ret);
int cg_pid_get_path(pid_t pid, char **ret);
int cg_pidref_get_path(const PidRef *pidref, char **ret);
if (cgroup && have_clone_into_cgroup) {
_cleanup_free_ char *resolved_cgroup = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup, /* suffix= */ NULL, &resolved_cgroup);
+ r = cg_get_path(cgroup, /* suffix= */ NULL, &resolved_cgroup);
if (r < 0)
return r;
else {
_cleanup_free_ char *p = NULL, *v = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, g->path, "memory.current", &p);
+ r = cg_get_path(g->path, "memory.current", &p);
if (r < 0)
return r;
assert(g);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, g->path, "io.stat", &p);
+ r = cg_get_path(g->path, "io.stat", &p);
if (r < 0)
return r;
} else {
_cleanup_free_ char *p = NULL, *v = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "pids.current", &p);
+ r = cg_get_path(path, "pids.current", &p);
if (r < 0)
return r;
if (r < 0)
return log_error_errno(r, "Extending device control BPF program failed: %m");
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup_path, NULL, &controller_path);
+ r = cg_get_path(cgroup_path, /* suffix = */ NULL, &controller_path);
if (r < 0)
return log_error_errno(r, "Failed to determine cgroup path: %m");
return log_unit_debug_errno(u, SYNTHETIC_ERRNO(EOPNOTSUPP),
"bpf-firewall: BPF firewalling not supported, proceeding without.");
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, NULL, &path);
+ r = cg_get_path(crt->cgroup_path, /* suffix = */ NULL, &path);
if (r < 0)
return log_unit_error_errno(u, r, "bpf-firewall: Failed to determine cgroup path: %m");
if (!crt)
return 0;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, NULL, &cgroup_path);
+ r = cg_get_path(crt->cgroup_path, /* suffix = */ NULL, &cgroup_path);
if (r < 0)
return log_unit_error_errno(u, r, "bpf-foreign: Failed to get cgroup path: %m");
if (!crt)
return 0;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, NULL, &cgroup_path);
+ r = cg_get_path(crt->cgroup_path, /* suffix = */ NULL, &cgroup_path);
if (r < 0)
return log_unit_error_errno(u, r, "restrict-interfaces: Failed to get cgroup path: %m");
if (!crt)
return 0;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, NULL, &cgroup_path);
+ r = cg_get_path(crt->cgroup_path, /* suffix = */ NULL, &cgroup_path);
if (r < 0)
return log_unit_error_errno(u, r, "bpf-socket-bind: Failed to get cgroup path: %m");
if (r < 0)
return log_oom();
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, "cgroup.events", &events);
+ r = cg_get_path(crt->cgroup_path, "cgroup.events", &events);
if (r < 0)
return log_oom();
if (r < 0)
return log_oom();
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, "memory.events", &events);
+ r = cg_get_path(crt->cgroup_path, "memory.events", &events);
if (r < 0)
return log_oom();
CGroupRuntime *crt = ASSERT_PTR(unit_get_cgroup_runtime(u));
uint64_t cgroup_id = 0;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, NULL, &cgroup_full_path);
+ r = cg_get_path(crt->cgroup_path, /* suffix = */ NULL, &cgroup_full_path);
if (r == 0) {
r = cg_path_get_cgroupid(cgroup_full_path, &cgroup_id);
if (r < 0)
if (!FLAGS_SET(crt->cgroup_realized_mask, CGROUP_MASK_IO))
return -ENODATA;
- r = cg_get_path("io", crt->cgroup_path, "io.stat", &path);
+ r = cg_get_path(crt->cgroup_path, "io.stat", &path);
if (r < 0)
return r;
assert_not_reached();
}
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, crt->cgroup_path, "cgroup.freeze", &path);
+ r = cg_get_path(crt->cgroup_path, "cgroup.freeze", &path);
if (r < 0)
return r;
if (is_pressure_supported() > 0) {
if (cgroup_context_want_memory_pressure(cgroup_context)) {
- r = cg_get_path("memory", params->cgroup_path, "memory.pressure", &memory_pressure_path);
+ r = cg_get_path(params->cgroup_path, "memory.pressure", &memory_pressure_path);
if (r < 0) {
*exit_status = EXIT_MEMORY;
return log_oom();
* memory_pressure_path != NULL in the conditional below. */
if (memory_pressure_path && needs_sandboxing && exec_needs_cgroup_namespace(context)) {
memory_pressure_path = mfree(memory_pressure_path);
- r = cg_get_path("memory", "/", "memory.pressure", &memory_pressure_path);
+ r = cg_get_path("/", "memory.pressure", &memory_pressure_path);
if (r < 0) {
*exit_status = EXIT_MEMORY;
return log_oom();
return 0;
_cleanup_free_ char *p = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, m->cgroup, "cgroup.events", &p);
+ r = cg_get_path(m->cgroup, "cgroup.events", &p);
if (r < 0)
return log_error_errno(r, "Failed to get cgroup path for cgroup '%s': %m", m->cgroup);
return log_error_errno(r, "Failed to add cgroup %s to userns: %m", payload);
} else {
_cleanup_free_ char *fs = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, payload, NULL, &fs);
+ r = cg_get_path(payload, /* suffix = */ NULL, &fs);
if (r < 0)
return log_error_errno(r, "Failed to get file system path for container cgroup: %m");
if (dry_run) {
_cleanup_free_ char *cg_path = NULL;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &cg_path);
+ r = cg_get_path(path, /* suffix = */ NULL, &cg_path);
if (r < 0)
return r;
is_root = empty_or_root(path);
ctx->preference = MANAGED_OOM_PREFERENCE_NONE;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "memory.pressure", &p);
+ r = cg_get_path(path, "memory.pressure", &p);
if (r < 0)
return log_debug_errno(r, "Error getting cgroup memory pressure path from %s: %m", path);
_cleanup_free_ char *fs = NULL;
int r;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
_cleanup_free_ char *fs = NULL;
int r;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
assert(path);
assert(pid >= 0);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, "cgroup.procs", &fs);
+ r = cg_get_path(path, "cgroup.procs", &fs);
if (r < 0)
return r;
return 0;
/* Configure access to the cgroup itself */
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
if (!uid_is_valid(uid) && !gid_is_valid(gid))
return 0;
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &fs);
+ r = cg_get_path(path, /* suffix = */ NULL, &fs);
if (r < 0)
return r;
return 0;
}
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, p, "cgroup.subtree_control", &fs);
+ r = cg_get_path(p, "cgroup.subtree_control", &fs);
if (r < 0)
return r;
assert(path);
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, path, NULL, &p);
+ r = cg_get_path(path, /* suffix = */ NULL, &p);
if (r < 0)
return r;
free_and_replace(slice_path, slice_joined);
}
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, slice_path, controller, &pressure_path);
+ r = cg_get_path(slice_path, controller, &pressure_path);
if (r < 0)
return log_debug_errno(r, "Error getting cgroup pressure path from %s: %m", slice_path);
if (r < 0)
return log_tests_skipped_errno(r, "Failed to prepare cgroup subtree");
- r = cg_get_path(SYSTEMD_CGROUP_CONTROLLER, cgroup, NULL, &controller_path);
+ r = cg_get_path(cgroup, /* suffix = */ NULL, &controller_path);
ASSERT_OK(r);
_cleanup_(bpf_program_freep) BPFProgram *prog = NULL;
ASSERT_TRUE(path_equal(path, test_d));
free(path);
- ASSERT_OK_ZERO(cg_get_path(SYSTEMD_CGROUP_CONTROLLER, test_d, NULL, &path));
+ ASSERT_OK_ZERO(cg_get_path(test_d, /* suffix = */ NULL, &path));
log_debug("test_d: %s", path);
ASSERT_TRUE(path_equal(path, strjoina("/sys/fs/cgroup", test_d)));
free(path);