Resolves: RHEL-155454, RHEL-155805, RHEL-155396, RHEL-158303, RHEL-158354, RHEL-143728, RHEL-168098, RHEL-143028
46 lines
1.5 KiB
Diff
46 lines
1.5 KiB
Diff
From 6ac39e6caa209898323dda2d907b594322ba3894 Mon Sep 17 00:00:00 2001
|
|
From: Lennart Poettering <lennart@poettering.net>
|
|
Date: Thu, 22 May 2025 18:35:25 +0200
|
|
Subject: [PATCH] cgroup: port some code over to path_startswith_full()
|
|
|
|
(cherry picked from commit 482107724f64cb8dd24db3e65b6ea3151a330301)
|
|
|
|
Related: RHEL-155396
|
|
---
|
|
src/basic/cgroup-util.c | 10 ++--------
|
|
1 file changed, 2 insertions(+), 8 deletions(-)
|
|
|
|
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
|
|
index 309dccb45a..b8a17badea 100644
|
|
--- a/src/basic/cgroup-util.c
|
|
+++ b/src/basic/cgroup-util.c
|
|
@@ -1013,13 +1013,12 @@ int cg_get_root_path(char **ret_path) {
|
|
}
|
|
|
|
int cg_shift_path(const char *cgroup, const char *root, const char **ret_shifted) {
|
|
- _cleanup_free_ char *rt = NULL;
|
|
- char *p;
|
|
int r;
|
|
|
|
assert(cgroup);
|
|
assert(ret_shifted);
|
|
|
|
+ _cleanup_free_ char *rt = NULL;
|
|
if (!root) {
|
|
/* If the root was specified let's use that, otherwise
|
|
* let's determine it from PID 1 */
|
|
@@ -1031,12 +1030,7 @@ int cg_shift_path(const char *cgroup, const char *root, const char **ret_shifted
|
|
root = rt;
|
|
}
|
|
|
|
- p = path_startswith(cgroup, root);
|
|
- if (p && p > cgroup)
|
|
- *ret_shifted = p - 1;
|
|
- else
|
|
- *ret_shifted = cgroup;
|
|
-
|
|
+ *ret_shifted = path_startswith_full(cgroup, root, PATH_STARTSWITH_RETURN_LEADING_SLASH) ?: cgroup;
|
|
return 0;
|
|
}
|
|
|