naccyde / rpms / systemd

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