Skip to contentSkip to conversation

lib/fs: drop unused full argument from get_cgroup2_path

PATCH Applied Stephen Hemminger 2 participants 2 messages Oct 21 – Oct 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/fs: drop unused full argument from get_cgroup2_path

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
---
 include/utils.h |  2 +-
 lib/cg_map.c    |  2 +-
 lib/fs.c        | 21 +++++++++------------
 3 files changed, 11 insertions(+), 14 deletions(-)
include/utils.h +1 -1
index f0d45bad..5812d1a8 100644
@@ -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);
 
lib/cg_map.c +1 -1
index 0feb854f..9c92b2eb 100644
@@ -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);
lib/fs.c +9 -12
index 1562d25c..86f9fb65 100644
@@ -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");
Signature · 1 line
2.53.0
#1 lore raw
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Hello:

This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:

Quoted 8 lines · 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

[...]

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html