lookup: drop empty directories from search paths

This commit is contained in:
Lennart Poettering 2011-04-28 04:55:05 +02:00
parent ac3f50caa5
commit a9dd208208
4 changed files with 25 additions and 2 deletions

2
TODO
View File

@ -34,8 +34,6 @@ Features:
* Maybe merge nss-myhostname into systemd?
* ensure we strip empty directories from search path
* GC unreferenced jobs (such as .device jobs)
* support wildcard expansion in ListenStream= and friends

View File

@ -205,6 +205,7 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
return -ENOMEM;
strv_uniq(p->unit_path);
strv_path_remove_empty(p->unit_path);
if (!strv_isempty(p->unit_path)) {
@ -259,6 +260,9 @@ int lookup_paths_init(LookupPaths *p, ManagerRunningAs running_as) {
strv_uniq(p->sysvinit_path);
strv_uniq(p->sysvrcnd_path);
strv_path_remove_empty(p->sysvinit_path);
strv_path_remove_empty(p->sysvrcnd_path);
if (!strv_isempty(p->sysvinit_path)) {
if (!(t = strv_join(p->sysvinit_path, "\n\t")))

View File

@ -1209,6 +1209,26 @@ char **strv_path_canonicalize(char **l) {
return l;
}
char **strv_path_remove_empty(char **l) {
char **f, **t;
if (!l)
return NULL;
for (f = t = l; *f; f++) {
if (dir_is_empty(*f) > 0) {
free(*f);
continue;
}
*(t++) = *f;
}
*t = NULL;
return l;
}
int reset_all_signal_handlers(void) {
int sig;

View File

@ -224,6 +224,7 @@ char *path_make_absolute_cwd(const char *p);
char **strv_path_make_absolute_cwd(char **l);
char **strv_path_canonicalize(char **l);
char **strv_path_remove_empty(char **l);
int reset_all_signal_handlers(void);