summaryrefslogtreecommitdiffstats
path: root/src/basic/cgroup-util.c
diff options
context:
space:
mode:
authorDaan De Meyer <daan.j.demeyer@gmail.com>2023-09-29 11:33:12 +0200
committerGitHub <noreply@github.com>2023-09-29 11:33:12 +0200
commit4444564a9545a1bfd82367a64dd454d8fac84474 (patch)
tree7e7c367a10e5a5e0656e8977abaab4f8882c1169 /src/basic/cgroup-util.c
parentMerge pull request #29241 from poettering/pidref-watch (diff)
parentRework unit_name_mangle_with_suffix() to (very slightly) simplify the path (diff)
downloadsystemd-4444564a9545a1bfd82367a64dd454d8fac84474.tar.xz
systemd-4444564a9545a1bfd82367a64dd454d8fac84474.zip
Merge pull request #29193 from keszybz/path-util-adjustment
Make unit mangling follow paths
Diffstat (limited to 'src/basic/cgroup-util.c')
-rw-r--r--src/basic/cgroup-util.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 947fb900d6..ca697ed97a 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -978,6 +978,7 @@ int cg_is_empty_recursive(const char *controller, const char *path) {
int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
_cleanup_free_ char *controller = NULL, *path = NULL;
+ int r;
assert(spec);
@@ -986,11 +987,9 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
return -EINVAL;
if (ret_path) {
- path = strdup(spec);
- if (!path)
- return -ENOMEM;
-
- path_simplify(path);
+ r = path_simplify_alloc(spec, &path);
+ if (r < 0)
+ return r;
}
} else {
@@ -1037,22 +1036,14 @@ int cg_split_spec(const char *spec, char **ret_controller, char **ret_path) {
int cg_mangle_path(const char *path, char **result) {
_cleanup_free_ char *c = NULL, *p = NULL;
- char *t;
int r;
assert(path);
assert(result);
/* First, check if it already is a filesystem path */
- if (path_startswith(path, "/sys/fs/cgroup")) {
-
- t = strdup(path);
- if (!t)
- return -ENOMEM;
-
- *result = path_simplify(t);
- return 0;
- }
+ if (path_startswith(path, "/sys/fs/cgroup"))
+ return path_simplify_alloc(path, result);
/* Otherwise, treat it as cg spec */
r = cg_split_spec(path, &c, &p);