chiark / gitweb /
tmpfiles: remove unnecessary function
[elogind.git] / src / tmpfiles / tmpfiles.c
index d68693f829589d9c8b1c9596cc1a1221ef35e68f..b80731d470eae158b2158dd58d45790cad48ab38 100644 (file)
@@ -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;
@@ -447,17 +449,15 @@ finish:
         return r;
 }
 
-static int item_set_perms_full(Item *i, const char *path, bool ignore_enoent) {
+static int item_set_perms(Item *i, const char *path) {
         assert(i);
         assert(path);
 
         /* not using i->path directly because it may be a glob */
         if (i->mode_set)
                 if (chmod(path, i->mode) < 0) {
-                        if (errno != ENOENT || !ignore_enoent) {
-                                log_error("chmod(%s) failed: %m", path);
-                                return -errno;
-                        }
+                        log_error("chmod(%s) failed: %m", path);
+                        return -errno;
                 }
 
         if (i->uid_set || i->gid_set)
@@ -465,17 +465,11 @@ static int item_set_perms_full(Item *i, const char *path, bool ignore_enoent) {
                           i->uid_set ? i->uid : (uid_t) -1,
                           i->gid_set ? i->gid : (gid_t) -1) < 0) {
 
-                        if (errno != ENOENT || !ignore_enoent) {
-                                log_error("chown(%s) failed: %m", path);
-                                return -errno;
-                        }
+                        log_error("chown(%s) failed: %m", path);
+                        return -errno;
                 }
 
-        return label_fix(path, ignore_enoent, false);
-}
-
-static int item_set_perms(Item *i, const char *path) {
-        return item_set_perms_full(i, path, false);
+        return label_fix(path, false, false);
 }
 
 static int write_one_file(Item *i, const char *path) {
@@ -977,9 +971,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;