[systemd-commits] 2 commits - man/tmpfiles.d.xml src/tmpfiles

Lennart Poettering lennart at kemper.freedesktop.org
Wed Apr 22 09:27:28 PDT 2015


 man/tmpfiles.d.xml      |    9 ++++++---
 src/tmpfiles/tmpfiles.c |   36 ++++++++++++++++++------------------
 2 files changed, 24 insertions(+), 21 deletions(-)

New commits:
commit 6d785b6d07767834a7a00209b5de376ea42075fe
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Apr 22 18:24:47 2015 +0200

    man: elaborate on the order by which tmpfiles operations are executed

diff --git a/man/tmpfiles.d.xml b/man/tmpfiles.d.xml
index 971b142..8d3ed37 100644
--- a/man/tmpfiles.d.xml
+++ b/man/tmpfiles.d.xml
@@ -101,9 +101,12 @@
     the lexicographically earliest name will be applied.  All other
     conflicting entries will be logged as errors. When two lines are
     prefix and suffix of each other, then the prefix is always
-    processed first, the suffix later. Otherwise, the
-    files/directories are processed in the order they are
-    listed.</para>
+    processed first, the suffix later. Lines that take globs are
+    applied after those accepting no globs. If multiple operations
+    shall be applied on the same file (such as ACL, xattr, file
+    attribute adjustments) these are always done in the same fixed
+    order. Otherwise, the files/directories are processed in the order
+    they are listed.</para>
 
     <para>If the administrator wants to disable a configuration file
     supplied by the vendor, the recommended way is to place a symlink

commit ef43a39176616e545ceb9f4c3ac03fd78fd5e4a6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Apr 22 18:18:56 2015 +0200

    tmpfiles: use an ordered hashmap for the tmpfiles items
    
    We should try to execute them in the same order they appear in the
    configuration files, as it is documented. Hence move to an ordered
    hashmap.
    
    (Note though, that this still doesn't execute them completely in order:
    we will still apply non-glob lines before glob-lines, and reorder lines
    prefixing each other and that apply to the same paths).
    
    http://lists.freedesktop.org/archives/systemd-devel/2015-March/029055.html

diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c
index 8cbeb67..d574254 100644
--- a/src/tmpfiles/tmpfiles.c
+++ b/src/tmpfiles/tmpfiles.c
@@ -145,7 +145,7 @@ static const char conf_file_dirs[] = CONF_DIRS_NULSTR("tmpfiles");
 
 #define MAX_DEPTH 256
 
-static Hashmap *items = NULL, *globs = NULL;
+static OrderedHashmap *items = NULL, *globs = NULL;
 static Set *unix_sockets = NULL;
 
 static const Specifier specifier_table[] = {
@@ -193,11 +193,11 @@ static bool takes_ownership(ItemType t) {
                       RECURSIVE_REMOVE_PATH);
 }
 
-static struct Item* find_glob(Hashmap *h, const char *match) {
+static struct Item* find_glob(OrderedHashmap *h, const char *match) {
         ItemArray *j;
         Iterator i;
 
-        HASHMAP_FOREACH(j, h, i) {
+        ORDERED_HASHMAP_FOREACH(j, h, i) {
                 unsigned n;
 
                 for (n = 0; n < j->count; n++) {
@@ -408,7 +408,7 @@ static int dir_cleanup(
                 }
 
                 /* Is there an item configured for this path? */
-                if (hashmap_get(items, sub_path)) {
+                if (ordered_hashmap_get(items, sub_path)) {
                         log_debug("Ignoring \"%s\": a separate entry exists.", sub_path);
                         continue;
                 }
@@ -1602,7 +1602,7 @@ static int process_item(Item *i) {
         PATH_FOREACH_PREFIX(prefix, i->path) {
                 ItemArray *j;
 
-                j = hashmap_get(items, prefix);
+                j = ordered_hashmap_get(items, prefix);
                 if (j) {
                         int s;
 
@@ -1735,7 +1735,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
         _cleanup_free_ char *action = NULL, *mode = NULL, *user = NULL, *group = NULL, *age = NULL, *path = NULL;
         _cleanup_(item_free_contents) Item i = {};
         ItemArray *existing;
-        Hashmap *h;
+        OrderedHashmap *h;
         int r, pos;
         bool force = false, boot = false;
 
@@ -1987,7 +1987,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
 
         h = needs_glob(i.type) ? globs : items;
 
-        existing = hashmap_get(h, i.path);
+        existing = ordered_hashmap_get(h, i.path);
         if (existing) {
                 unsigned n;
 
@@ -2000,7 +2000,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
                 }
         } else {
                 existing = new0(ItemArray, 1);
-                r = hashmap_put(h, i.path, existing);
+                r = ordered_hashmap_put(h, i.path, existing);
                 if (r < 0)
                         return log_oom();
         }
@@ -2163,14 +2163,14 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
         }
 
         /* we have to determine age parameter for each entry of type X */
-        HASHMAP_FOREACH(i, globs, iterator) {
+        ORDERED_HASHMAP_FOREACH(i, globs, iterator) {
                 Iterator iter;
                 Item *j, *candidate_item = NULL;
 
                 if (i->type != IGNORE_DIRECTORY_PATH)
                         continue;
 
-                HASHMAP_FOREACH(j, items, iter) {
+                ORDERED_HASHMAP_FOREACH(j, items, iter) {
                         if (j->type != CREATE_DIRECTORY && j->type != TRUNCATE_DIRECTORY && j->type != CREATE_SUBVOLUME)
                                 continue;
 
@@ -2216,8 +2216,8 @@ int main(int argc, char *argv[]) {
 
         mac_selinux_init(NULL);
 
-        items = hashmap_new(&string_hash_ops);
-        globs = hashmap_new(&string_hash_ops);
+        items = ordered_hashmap_new(&string_hash_ops);
+        globs = ordered_hashmap_new(&string_hash_ops);
 
         if (!items || !globs) {
                 r = log_oom();
@@ -2254,7 +2254,7 @@ int main(int argc, char *argv[]) {
 
         /* The non-globbing ones usually create things, hence we apply
          * them first */
-        HASHMAP_FOREACH(a, items, iterator) {
+        ORDERED_HASHMAP_FOREACH(a, items, iterator) {
                 k = process_item_array(a);
                 if (k < 0 && r == 0)
                         r = k;
@@ -2262,21 +2262,21 @@ int main(int argc, char *argv[]) {
 
         /* The globbing ones usually alter things, hence we apply them
          * second. */
-        HASHMAP_FOREACH(a, globs, iterator) {
+        ORDERED_HASHMAP_FOREACH(a, globs, iterator) {
                 k = process_item_array(a);
                 if (k < 0 && r == 0)
                         r = k;
         }
 
 finish:
-        while ((a = hashmap_steal_first(items)))
+        while ((a = ordered_hashmap_steal_first(items)))
                 item_array_free(a);
 
-        while ((a = hashmap_steal_first(globs)))
+        while ((a = ordered_hashmap_steal_first(globs)))
                 item_array_free(a);
 
-        hashmap_free(items);
-        hashmap_free(globs);
+        ordered_hashmap_free(items);
+        ordered_hashmap_free(globs);
 
         free(arg_include_prefixes);
         free(arg_exclude_prefixes);



More information about the systemd-commits mailing list