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