richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From 6503fbef433da29fe1f450e44c8eaca61888bcda Mon Sep 17 00:00:00 2001
803fb7
From: Lennart Poettering <lennart@poettering.net>
803fb7
Date: Mon, 27 Apr 2015 17:25:57 +0200
803fb7
Subject: [PATCH] update-done: ignore nanosecond file timestamp components,
803fb7
 they are not reliable
803fb7
803fb7
https://bugs.freedesktop.org/show_bug.cgi?id=90192
803fb7
(cherry picked from commit 329c542585cd92cb905990e3bf59eda16fd88cfb)
803fb7
803fb7
Cherry-picked from: a38a3e0
803fb7
Resolves: #1222517
803fb7
---
803fb7
 src/update-done/update-done.c | 12 +++++++++---
803fb7
 1 file changed, 9 insertions(+), 3 deletions(-)
803fb7
803fb7
diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c
803fb7
index 561963e5e..cb5cd6f4a 100644
803fb7
--- a/src/update-done/update-done.c
803fb7
+++ b/src/update-done/update-done.c
803fb7
@@ -36,9 +36,15 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
803fb7
         assert(ts);
803fb7
 
803fb7
         if (stat(path, &st) >= 0) {
803fb7
-                /* Is the timestamp file already newer than the OS? If so, there's nothing to do. */
803fb7
-                if (st.st_mtim.tv_sec > ts->tv_sec ||
803fb7
-                    (st.st_mtim.tv_sec == ts->tv_sec && st.st_mtim.tv_nsec >= ts->tv_nsec))
803fb7
+                /* Is the timestamp file already newer than the OS? If
803fb7
+                 * so, there's nothing to do. We ignore the nanosecond
803fb7
+                 * component of the timestamp, since some file systems
803fb7
+                 * do not support any better accuracy than 1s and we
803fb7
+                 * have no way to identify the accuracy
803fb7
+                 * available. Most notably ext4 on small disks (where
803fb7
+                 * 128 byte inodes are used) does not support better
803fb7
+                 * accuracy than 1s. */
803fb7
+                if (st.st_mtim.tv_sec > ts->tv_sec)
803fb7
                         return 0;
803fb7
 
803fb7
                 /* It is older? Then let's update it */