various: don't say that the timestamp 'changed' on initial load
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 1 Jun 2021 15:40:51 +0000 (17:40 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Jul 2021 15:46:24 +0000 (17:46 +0200)
I always found this a bit annoying.
With the patch:

$ SYSTEMD_LOG_LEVEL=debug build/udevadm test /sys/class/block/dm-1
...
Loaded timestamp for '/etc/systemd/network'.
Loaded timestamp for '/usr/lib/systemd/network'.
Parsed configuration file /usr/lib/systemd/network/99-default.link
Parsed configuration file /etc/systemd/network/10-eth0.link
Created link configuration context.
Loaded timestamp for '/etc/udev/rules.d'.
Loaded timestamp for '/usr/lib/udev/rules.d'.
...

(cherry picked from commit 0d5a24beaedb161d4f7fe07361d2a5abdbd6e736)
(cherry picked from commit 688b311f5c6c0b20a3811f6a135bf87e11f36502)

src/basic/path-util.c

index 794599a172b5ed788ea75ddaffe29aca621d67c8..8012fca5898858585036c93cd7f2a2a0771952a6 100644 (file)
@@ -659,7 +659,7 @@ int find_executable_full(const char *name, bool use_path_envvar, char **ret) {
 }
 
 bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool update) {
-        bool changed = false;
+        bool changed = false, originally_unset;
         const char* const* i;
 
         assert(timestamp);
@@ -667,6 +667,8 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
         if (!paths)
                 return false;
 
+        originally_unset = *timestamp == 0;
+
         STRV_FOREACH(i, paths) {
                 struct stat stats;
                 usec_t u;
@@ -676,11 +678,11 @@ bool paths_check_timestamp(const char* const* paths, usec_t *timestamp, bool upd
 
                 u = timespec_load(&stats.st_mtim);
 
-                /* first check */
+                /* check first */
                 if (*timestamp >= u)
                         continue;
 
-                log_debug("timestamp of '%s' changed", *i);
+                log_debug(originally_unset ? "Loaded timestamp for '%s'." : "Timestamp of '%s' changed.", *i);
 
                 /* update timestamp */
                 if (update) {