summaryrefslogtreecommitdiff
path: root/src/tmpfiles/tmpfiles.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-06-11 01:37:35 +0200
committerLennart Poettering <lennart@poettering.net>2014-06-11 01:37:35 +0200
commit1910cd0e05f7661986680e0a4472f4e857f90787 (patch)
tree16473328c50e5376e365e948c20e3d795284153c /src/tmpfiles/tmpfiles.c
parent7bc040fab802ff20eacd1745e393f1766c8c35d9 (diff)
tmpfiles: when processing lines, always process prefixes before suffixes
If two lines refer to paths that are suffix and prefix of each other, then always process the prefix first, the suffix second. In all other cases strictly process rules in the order they appear in the files. This makes creating /var/run as symlink to /run a lot more fun, since it is automatically created first.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r--src/tmpfiles/tmpfiles.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index d68693f829..c6121bccf3 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -101,6 +101,8 @@ typedef struct Item {
bool age_set:1;
bool keep_first_level:1;
+
+ bool done:1;
} Item;
static bool arg_create = false;
@@ -977,9 +979,23 @@ static int clean_item(Item *i) {
static int process_item(Item *i) {
int r, q, p;
+ char prefix[PATH_MAX];
assert(i);
+ if (i->done)
+ return 0;
+
+ i->done = true;
+
+ PATH_FOREACH_PREFIX(prefix, i->path) {
+ Item *j;
+
+ j = hashmap_get(items, prefix);
+ if (j)
+ process_item(j);
+ }
+
r = arg_create ? create_item(i) : 0;
q = arg_remove ? remove_item(i) : 0;
p = arg_clean ? clean_item(i) : 0;