Thread View: linux.kernel.netdev
2 messages
2 total messages
Started by Stephen Hemminger
Wed, 21 Oct 2026 15:39
[PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path
Author: Stephen Hemminger
Date: Wed, 21 Oct 2026 15:39
Date: Wed, 21 Oct 2026 15:39
88 lines
13291 bytes
13291 bytes
The only caller, cg_id_to_path(), passes false, and no caller has
ever passed true. Remove the argument and always return the path
relative to the cgroup2 mount.
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
include/utils.h | 2 +-
lib/cg_map.c | 2 +-
lib/fs.c | 21 +++++++++------------
3 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index f0d45bad..5812d1a8 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -310,7 +310,7 @@ int cmd_exec(const char *cmd, char **argv, bool do_fork,
int make_path(const char *path, mode_t mode);
char *find_cgroup2_mount(bool do_mount);
__u64 get_cgroup2_id(const char *path);
-char *get_cgroup2_path(__u64 id, bool full);
+char *get_cgroup2_path(__u64 id);
int get_command_name(const char *pid, char *comm, size_t len);
int get_task_name(pid_t pid, char *name, size_t len);
diff --git a/lib/cg_map.c b/lib/cg_map.c
index 0feb854f..9c92b2eb 100644
--- a/lib/cg_map.c
+++ b/lib/cg_map.c
@@ -118,7 +118,7 @@ const char *cg_id_to_path(__u64 id)
if (cg)
return cg->path;
- path = get_cgroup2_path(id, false);
+ path = get_cgroup2_path(id);
if (path) {
cg = cg_entry_create(id, path);
free(path);
diff --git a/lib/fs.c b/lib/fs.c
index 1562d25c..86f9fb65 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -187,7 +187,7 @@ out:
#define FILEID_INO32_GEN 1
/* caller needs to free string returned */
-char *get_cgroup2_path(__u64 id, bool full)
+char *get_cgroup2_path(__u64 id)
{
char fh_buf[sizeof(struct file_handle) + sizeof(__u64)] = { 0 };
struct file_handle *fhp = (struct file_handle *)fh_buf;
@@ -201,6 +201,7 @@ char *get_cgroup2_path(__u64 id, bool full)
char fd_path[64];
int link_len;
char *mnt = NULL;
+ size_t mnt_len;
if (!id) {
fprintf(stderr, "Invalid cgroup2 ID\n");
@@ -238,18 +239,14 @@ char *get_cgroup2_path(__u64 id, bool full)
}
link_buf[link_len] = '\0';
- if (full) {
- path = strdup(link_buf);
- } else {
- size_t mnt_len = strlen(mnt);
+ /* A cgroup outside our cgroup namespace is not under the
+ * mount and the link reads as just "/".
+ */
+ mnt_len = strlen(mnt);
+ if (strncmp(link_buf, mnt, mnt_len) != 0)
+ goto out;
- /* A cgroup outside our cgroup namespace is not under the
- * mount and the link reads as just "/".
- */
- if (strncmp(link_buf, mnt, mnt_len) != 0)
- goto out;
- path = strdup(link_buf + mnt_len);
- }
+ path = strdup(link_buf + mnt_len);
if (!path)
fprintf(stderr,
"Failed to allocate memory for cgroup2 path\n");
--
2.53.0
Re: [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path
Author: patchwork-bot+netdevbpf
Date: Thu, 22 Oct 2026 18:30
Date: Thu, 22 Oct 2026 18:30
24 lines
8523 bytes
8523 bytes
Hello:
This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:
On Wed, 21 Oct 2026 08:39:43 -0700 you wrote:
> The only caller, cg_id_to_path(), passes false, and no caller has
> ever passed true. Remove the argument and always return the path
> relative to the cgroup2 mount.
>
> Assisted-by: Claude:claude-opus-5-5
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
>
> [...]
Here is the summary with links:
- [iproute2] lib/fs: drop unused full argument from get_cgroup2_path
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=eb6a29fe096a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads