]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: treat masked files as "unchanged"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 Mar 2016 04:22:33 +0000 (00:22 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 31 Mar 2016 04:38:50 +0000 (00:38 -0400)
systemctl prints the "unit file changed on disk" warning
for a masked unit. I think it's better to print nothing in that
case.

When a masked unit is loaded, set mtime as 0. When checking
if a unit with mtime of 0 needs reload, check that the mask
is still in place.

src/core/load-fragment.c
src/core/unit.c

index d078924c5ba981d8538229d8df0be69cf598e101..f1a874cfdfbfe9e39180f54e2e46bb5063aa16b8 100644 (file)
@@ -3620,10 +3620,12 @@ static int load_from_path(Unit *u, const char *path) {
         if (fstat(fileno(f), &st) < 0)
                 return -errno;
 
-        if (null_or_empty(&st))
+        if (null_or_empty(&st)) {
                 u->load_state = UNIT_MASKED;
-        else {
+                u->fragment_mtime = 0;
+        } else {
                 u->load_state = UNIT_LOADED;
+                u->fragment_mtime = timespec_load(&st.st_mtim);
 
                 /* Now, parse the file contents */
                 r = config_parse(u->id, filename, f,
@@ -3638,8 +3640,6 @@ static int load_from_path(Unit *u, const char *path) {
         u->fragment_path = filename;
         filename = NULL;
 
-        u->fragment_mtime = timespec_load(&st.st_mtim);
-
         if (u->source_path) {
                 if (stat(u->source_path, &st) >= 0)
                         u->source_mtime = timespec_load(&st.st_mtim);
index 64d5ed04c990267e55947d8cbe7477e35018d930..70175557f74db5aa1781a3d606aa1c38909b5211 100644 (file)
@@ -2934,7 +2934,11 @@ static bool fragment_mtime_changed(const char *path, usec_t mtime) {
                 /* What, cannot access this anymore? */
                 return true;
 
-        if (mtime > 0 && timespec_load(&st.st_mtim) != mtime)
+        if (mtime > 0)
+                /* For non-empty files check the mtime */
+                return timespec_load(&st.st_mtim) != mtime;
+        else if (!null_or_empty(&st))
+                /* For masked files check if they are still so */
                 return true;
 
         return false;