summaryrefslogtreecommitdiff
path: root/src/shared/conf-files.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-05-13 17:42:10 +0200
committerLennart Poettering <lennart@poettering.net>2015-05-13 17:42:10 +0200
commit1d13f648d0fade38194db74b4f82ca68c8a26856 (patch)
treeb85c22b0007e0c8c6e612b8c9f5606bcd84f0451 /src/shared/conf-files.c
parent8b44a3d22c1fdfc5ce5fcb77e38a90ec02ba8019 (diff)
util: add generic calls for prefixing a root directory to a path
So far a number of utilities implemented their own calls for this, unify them in prefix_root() and prefix_roota(). The former uses heap memory, the latter allocates from the stack via alloca(). Port over most users of a --root= logic.
Diffstat (limited to 'src/shared/conf-files.c')
-rw-r--r--src/shared/conf-files.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c
index 9ab08355e3..da8745b284 100644
--- a/src/shared/conf-files.c
+++ b/src/shared/conf-files.c
@@ -36,12 +36,13 @@
static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) {
_cleanup_closedir_ DIR *dir = NULL;
- char *dirpath;
+ const char *dirpath;
+ int r;
assert(path);
assert(suffix);
- dirpath = strjoina(root ? root : "", path);
+ dirpath = prefix_roota(root, path);
dir = opendir(dirpath);
if (!dir) {
@@ -53,7 +54,6 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char
for (;;) {
struct dirent *de;
char *p;
- int r;
errno = 0;
de = readdir(dir);