diff options
Diffstat (limited to 'src/update-done/update-done.c')
-rw-r--r-- | src/update-done/update-done.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/src/update-done/update-done.c b/src/update-done/update-done.c index 561963e5eb..01bbde8455 100644 --- a/src/update-done/update-done.c +++ b/src/update-done/update-done.c @@ -20,7 +20,6 @@ ***/ #include "util.h" -#include "label.h" #include "selinux-util.h" #define MESSAGE \ @@ -29,22 +28,28 @@ "was updated. See systemd-update-done.service(8).\n" static int apply_timestamp(const char *path, struct timespec *ts) { - struct timespec twice[2]; + struct timespec twice[2] = { + *ts, + *ts + }; struct stat st; assert(path); assert(ts); if (stat(path, &st) >= 0) { - /* Is the timestamp file already newer than the OS? If so, there's nothing to do. */ - if (st.st_mtim.tv_sec > ts->tv_sec || - (st.st_mtim.tv_sec == ts->tv_sec && st.st_mtim.tv_nsec >= ts->tv_nsec)) + /* Is the timestamp file already newer than the OS? If + * so, there's nothing to do. We ignore the nanosecond + * component of the timestamp, since some file systems + * do not support any better accuracy than 1s and we + * have no way to identify the accuracy + * available. Most notably ext4 on small disks (where + * 128 byte inodes are used) does not support better + * accuracy than 1s. */ + if (st.st_mtim.tv_sec > ts->tv_sec) return 0; /* It is older? Then let's update it */ - twice[0] = *ts; - twice[1] = *ts; - if (utimensat(AT_FDCWD, path, twice, AT_SYMLINK_NOFOLLOW) < 0) { if (errno == EROFS) @@ -75,9 +80,6 @@ static int apply_timestamp(const char *path, struct timespec *ts) { (void) loop_write(fd, MESSAGE, strlen(MESSAGE), false); - twice[0] = *ts; - twice[1] = *ts; - if (futimens(fd, twice) < 0) return log_error_errno(errno, "Failed to update timestamp on %s: %m", path); } else |