chase: replace path_prefix_root_cwd() with chaseat_prefix_root()

The function path_prefix_root_cwd() was introduced for prefixing the
result from chaseat() with root, but
- it is named slightly generic,
- the logic is different from what chase() does.

This makes the name more explanative and specific for the result of the
chaseat(), and make the logic consistent with chase().

Fixes https://github.com/systemd/systemd/pull/27199#issuecomment-1511387731.

Follow-up for #27199.
This commit is contained in:
Yu Watanabe
2023-04-19 03:38:59 +09:00
parent 8d3c49b168
commit 60e761d8f3
8 changed files with 74 additions and 72 deletions
-28
View File
@@ -100,34 +100,6 @@ int path_make_absolute_cwd(const char *p, char **ret) {
return 0;
}
int path_prefix_root_cwd(const char *p, const char *root, char **ret) {
_cleanup_free_ char *root_abs = NULL;
char *c;
int r;
assert(p);
assert(ret);
/* Unlike path_make_absolute(), this always prefixes root path if specified.
* The root path is always simplified, but the provided path will not.
* This is useful for prefixing the result of chaseat(). */
if (empty_or_root(root))
return path_make_absolute_cwd(p, ret);
r = path_make_absolute_cwd(root, &root_abs);
if (r < 0)
return r;
path_simplify(root_abs);
c = path_join(root_abs, p);
if (!c)
return -ENOMEM;
*ret = c;
return 0;
}
int path_make_relative(const char *from, const char *to, char **ret) {
_cleanup_free_ char *result = NULL;
unsigned n_parents;