summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2018-05-31 23:39:31 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2018-06-03 23:39:26 +0900
commit858d36c1ec7cd1173c60e8ab17b8425325253e38 (patch)
tree147284bf1b34c8917aa67bfdd2c15f672a0471af /src/shared
parentaff443013640ba783c89c9032ebd5a557f2fc11e (diff)
downloadsystemd-858d36c1ec7cd1173c60e8ab17b8425325253e38.tar.gz
path-util: introduce path_simplify()
The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/conf-parser.c2
-rw-r--r--src/shared/install.c8
-rw-r--r--src/shared/machine-image.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index c74c83ba5b..f10366c265 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -740,7 +740,7 @@ int config_parse_path(
if (!n)
return log_oom();
- path_kill_slashes(n);
+ path_simplify(n, false);
finalize:
free(*s);
diff --git a/src/shared/install.c b/src/shared/install.c
index ecda662f28..46e07ebb98 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -309,9 +309,9 @@ int unit_file_changes_add(
if (!p || (source && !s))
return -ENOMEM;
- path_kill_slashes(p);
+ path_simplify(p, false);
if (s)
- path_kill_slashes(s);
+ path_simplify(s, false);
c[*n_changes] = (UnitFileChange) { type, p, s };
p = s = NULL;
@@ -516,7 +516,7 @@ static int mark_symlink_for_removal(
if (!n)
return -ENOMEM;
- path_kill_slashes(n);
+ path_simplify(n, false);
r = set_consume(*remove_symlinks_to, n);
if (r == -EEXIST)
@@ -598,7 +598,7 @@ static int remove_marked_symlinks_fd(
p = path_make_absolute(de->d_name, path);
if (!p)
return -ENOMEM;
- path_kill_slashes(p);
+ path_simplify(p, false);
q = readlink_malloc(p, &dest);
if (q == -ENOENT)
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index e67f1f0645..404dd2aace 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -170,7 +170,7 @@ static int image_new(
if (!i->path)
return -ENOMEM;
- path_kill_slashes(i->path);
+ path_simplify(i->path, false);
*ret = TAKE_PTR(i);