diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-06 15:53:12 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2015-01-06 15:57:40 +0100 |
commit | 1db50423ba427565f92c05f3aaeab351860e30bc (patch) | |
tree | 1bf1882d6bb5fb0a1292b1f2441c01431a604a63 /src | |
parent | tree-wide: remove unnecessary LOG_PRI (diff) | |
download | systemd-1db50423ba427565f92c05f3aaeab351860e30bc.tar.xz systemd-1db50423ba427565f92c05f3aaeab351860e30bc.zip |
tmpfiles: finish with EXIT_FAILURE if anything failed
Return value is successful only if everything succeeded.
Diffstat (limited to 'src')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index f5b32c2ba8..ea1d11c425 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -1123,7 +1123,7 @@ static int clean_item(Item *i) { } static int process_item(Item *i) { - int r, q, p; + int r, q, p, s, t = 0; _cleanup_free_ char *prefix = NULL; assert(i); @@ -1141,21 +1141,23 @@ static int process_item(Item *i) { Item *j; j = hashmap_get(items, prefix); - if (j) - process_item(j); + if (j) { + int s; + + s = process_item(j); + if (s < 0 && t == 0) + t = s; + } } r = arg_create ? create_item(i) : 0; q = arg_remove ? remove_item(i) : 0; p = arg_clean ? clean_item(i) : 0; - if (r < 0) - return r; - - if (q < 0) - return q; - - return p; + return t < 0 ? t : + r < 0 ? r : + q < 0 ? q : + p; } static void item_free(Item *i) { @@ -1735,11 +1737,17 @@ int main(int argc, char *argv[]) { } } - HASHMAP_FOREACH(i, globs, iterator) - process_item(i); + HASHMAP_FOREACH(i, globs, iterator) { + k = process_item(i); + if (k < 0 && r == 0) + r = k; + } - HASHMAP_FOREACH(i, items, iterator) - process_item(i); + HASHMAP_FOREACH(i, items, iterator) { + k = process_item(i); + if (k < 0 && r == 0) + r = k; + } finish: while ((i = hashmap_steal_first(items))) |