cgroup: port some code over to path_startswith_full()

This commit is contained in:
Lennart Poettering
2025-05-23 06:51:43 +02:00
parent ee19edbb9f
commit 482107724f
2 changed files with 6 additions and 18 deletions
+2 -8
View File
@@ -959,13 +959,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 */
@@ -977,12 +976,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;
}