From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: dsahern@kernel.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path
Date: Wed, 21 Oct 2026 08:39:43 -0700 [thread overview]
Message-ID: <20261021153943.3754990-1-stephen@networkplumber.org> (raw)
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
next reply other threads:[~2026-10-21 15:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 15:39 Stephen Hemminger [this message]
2026-10-22 18:30 ` [PATCH iproute2] lib/fs: drop unused full argument from get_cgroup2_path patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021153943.3754990-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dsahern@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox