chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dbus: properly serialize calendar timer data
[elogind.git]
/
src
/
shared
/
conf-files.c
diff --git
a/src/shared/conf-files.c
b/src/shared/conf-files.c
index 019fadcf5ee5bb22f2c50ff8a63727362d67c603..34b86293d3a246b9703a36eab41f8f020de4ff38 100644
(file)
--- a/
src/shared/conf-files.c
+++ b/
src/shared/conf-files.c
@@
-33,12
+33,12
@@
#include "missing.h"
#include "log.h"
#include "strv.h"
#include "missing.h"
#include "log.h"
#include "strv.h"
+#include "path-util.h"
#include "hashmap.h"
#include "conf-files.h"
static int files_add(Hashmap *h, const char *path, const char *suffix) {
DIR *dir;
#include "hashmap.h"
#include "conf-files.h"
static int files_add(Hashmap *h, const char *path, const char *suffix) {
DIR *dir;
- struct dirent buffer, *de;
int r = 0;
dir = opendir(path);
int r = 0;
dir = opendir(path);
@@
-49,10
+49,12
@@
static int files_add(Hashmap *h, const char *path, const char *suffix) {
}
for (;;) {
}
for (;;) {
+ struct dirent *de;
+ union dirent_storage buf;
int k;
char *p;
int k;
char *p;
- k = readdir_r(dir, &buf
fer
, &de);
+ k = readdir_r(dir, &buf
.de
, &de);
if (k != 0) {
r = -k;
goto finish;
if (k != 0) {
r = -k;
goto finish;
@@
-69,7
+71,7
@@
static int files_add(Hashmap *h, const char *path, const char *suffix) {
goto finish;
}
goto finish;
}
- if (hashmap_put(h,
file_name_from_path
(p), p) <= 0) {
+ if (hashmap_put(h,
path_get_file_name
(p), p) <= 0) {
log_debug("Skip overridden file: %s.", p);
free(p);
}
log_debug("Skip overridden file: %s.", p);
free(p);
}
@@
-85,14
+87,14
@@
static int base_cmp(const void *a, const void *b) {
s1 = *(char * const *)a;
s2 = *(char * const *)b;
s1 = *(char * const *)a;
s2 = *(char * const *)b;
- return strcmp(
file_name_from_path(s1), file_name_from_path
(s2));
+ return strcmp(
path_get_file_name(s1), path_get_file_name
(s2));
}
int conf_files_list_strv(char ***strv, const char *suffix, const char **dirs) {
Hashmap *fh = NULL;
char **files = NULL;
const char **p;
}
int conf_files_list_strv(char ***strv, const char *suffix, const char **dirs) {
Hashmap *fh = NULL;
char **files = NULL;
const char **p;
- int r
= 0
;
+ int r;
assert(dirs);
assert(dirs);
@@
-103,11
+105,10
@@
int conf_files_list_strv(char ***strv, const char *suffix, const char **dirs) {
}
STRV_FOREACH(p, dirs) {
}
STRV_FOREACH(p, dirs) {
- if (files_add(fh, *p, suffix) < 0) {
- log_error("Failed to search for files.");
- r = -EINVAL;
- goto finish;
- }
+ r = files_add(fh, *p, suffix);
+ if (r < 0)
+ log_warning("Failed to search for files in %s: %s",
+ *p, strerror(-r));
}
files = hashmap_get_strv(fh);
}
files = hashmap_get_strv(fh);
@@
-117,6
+118,7
@@
int conf_files_list_strv(char ***strv, const char *suffix, const char **dirs) {
goto finish;
}
qsort(files, hashmap_size(fh), sizeof(char *), base_cmp);
goto finish;
}
qsort(files, hashmap_size(fh), sizeof(char *), base_cmp);
+ r = 0;
finish:
hashmap_free(fh);
finish:
hashmap_free(fh);
@@
-137,7
+139,7
@@
int conf_files_list(char ***strv, const char *suffix, const char *dir, ...) {
goto finish;
}
goto finish;
}
- if (!
strv_path
_canonicalize(dirs)) {
+ if (!
path_strv
_canonicalize(dirs)) {
r = -ENOMEM;
goto finish;
}
r = -ENOMEM;
goto finish;
}