From: Michael Tremer Date: Tue, 10 Dec 2024 15:27:26 +0000 (+0000) Subject: cgroups: Store the path to the cgroup X-Git-Tag: 0.9.30~730 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9760be9975f45f48343c274190f2ccb28448b35c;p=pakfire.git cgroups: Store the path to the cgroup This is only used for debugging. Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/cgroup.c b/src/libpakfire/cgroup.c index 45941a677..5b4900973 100644 --- a/src/libpakfire/cgroup.c +++ b/src/libpakfire/cgroup.c @@ -67,8 +67,9 @@ struct pakfire_cgroup { // Flags int flags; - // Store the name - char name[PATH_MAX]; + // Store the name & path + char name[NAME_MAX]; + char path[PATH_MAX]; // File descriptor to cgroup int fd; @@ -84,6 +85,13 @@ static const char* pakfire_cgroup_name(struct pakfire_cgroup* cgroup) { return cgroup->name; } +static const char* pakfire_cgroup_path(struct pakfire_cgroup* cgroup) { + if (!*cgroup->path) + return "(root)"; + + return cgroup->path; +} + static int pakfire_cgroup_setup_devices(struct pakfire_cgroup* cgroup) { static char bpf_log_buffer[BPF_LOG_BUF_SIZE]; @@ -331,6 +339,13 @@ static int pakfire_cgroup_open(struct pakfire_cgroup** cgroup, if (r < 0) goto ERROR; + // Store path + if (c->parent) { + r = pakfire_path_append(c->path, c->parent->path, c->name); + if (r < 0) + goto ERROR; + } + // Copy flags c->flags = flags; @@ -351,6 +366,8 @@ static int pakfire_cgroup_open(struct pakfire_cgroup** cgroup, goto ERROR; #endif + DEBUG(c->ctx, "Created cgroup %s\n", pakfire_cgroup_path(c)); + // Return the pointer *cgroup = pakfire_cgroup_ref(c);