diff options
author | Michael Marineau <michael.marineau@coreos.com> | 2014-06-19 19:07:04 -0700 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2014-06-20 00:10:47 -0400 |
commit | cba2ef02722114da2b730d57f1e3bb43013d8921 (patch) | |
tree | ac9c2f54223fc47fc5a3739a0c2adeb9e4110c51 /src/shared/conf-files.c | |
parent | 3e8a78c8dceedb001587cb6c1eaa31cb8aa56729 (diff) |
conf-files: include root in returned file paths
This restores the original root handling logic that was present prior to
112cfb18 when path expansion moved to path_strv_canonicalize_absolute.
That behavior partially went away in 12ed81d9.
Alternatively all users of conf_files_list* could be updated to
concatenate the paths themselves as unit_file_query_preset did but since
no user needs the un-concatenated form that is pointless duplication.
Diffstat (limited to 'src/shared/conf-files.c')
-rw-r--r-- | src/shared/conf-files.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/shared/conf-files.c b/src/shared/conf-files.c index 44e137e84c..64ce8a0e57 100644 --- a/src/shared/conf-files.c +++ b/src/shared/conf-files.c @@ -37,20 +37,16 @@ #include "hashmap.h" #include "conf-files.h" -static int files_add(Hashmap *h, const char *dirpath, const char *suffix, const char *root) { +static int files_add(Hashmap *h, const char *root, const char *path, const char *suffix) { _cleanup_closedir_ DIR *dir = NULL; + char *dirpath; - assert(dirpath); + assert(path); assert(suffix); - if (isempty(root)) - dir = opendir(dirpath); - else { - const char *p; + dirpath = strappenda(root ? root : "", path); - p = strappenda3(root, "/", dirpath); - dir = opendir(p); - } + dir = opendir(dirpath); if (!dir) { if (errno == ENOENT) return 0; @@ -118,7 +114,7 @@ static int conf_files_list_strv_internal(char ***strv, const char *suffix, const return -ENOMEM; STRV_FOREACH(p, dirs) { - r = files_add(fh, *p, suffix, root); + r = files_add(fh, root, *p, suffix); if (r == -ENOMEM) { hashmap_free_free(fh); return r; |