* [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path
@ 2026-10-21 15:39 Stephen Hemminger
2026-10-22 18:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Stephen Hemminger @ 2026-10-21 15:39 UTC (permalink / raw)
To: netdev; +Cc: dsahern, Stephen Hemminger
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path
2026-10-21 15:39 [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path Stephen Hemminger
@ 2026-10-22 18:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-22 18:30 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, dsahern
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-10-22 18:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-21 15:39 [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path Stephen Hemminger
2026-10-22 18:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox