diff options
author | Chris Lesiak <chris.lesiak@licor.com> | 2018-04-24 09:50:42 -0500 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 85faeee71899e061f7ccc2360ff4a7a250e83c95 (patch) | |
tree | 0a38f082d32fcde975888e23dcd31b77c1ae344e /src/basic/fileio.c | |
parent | 047e7ea06ef10bbf8df8e565b2ed3e0cdedf6e9a (diff) |
fileio.c: fix incorrect mtime
A regression was introduced that caused the mtime of /etc/.updated
and /var/.updated to be the current time when systemd-update-done
ran instead of being copied from /usr.
This was nearly fixed, but due to fflush being called after mtime
was carefully set, it was overwritten with the current time.
Regression introduced in 872c40396384f9fa89b01baf4e739d28ed590299
A fix was just missed in 39c38d773fbe2b4f76ff29ecd3344640efb9a86c
Fixes #8806
Diffstat (limited to 'src/basic/fileio.c')
-rw-r--r-- | src/basic/fileio.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c index a145fd4d4..43c804472 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -50,6 +50,7 @@ int write_string_stream_ts( struct timespec *ts) { bool needs_nl; + int r; assert(f); assert(line); @@ -74,6 +75,13 @@ int write_string_stream_ts( if (fputc('\n', f) == EOF) return -errno; + if (flags & WRITE_STRING_FILE_SYNC) + r = fflush_sync_and_check(f); + else + r = fflush_and_check(f); + if (r < 0) + return r; + if (ts) { struct timespec twice[2] = {*ts, *ts}; @@ -81,10 +89,7 @@ int write_string_stream_ts( return -errno; } - if (flags & WRITE_STRING_FILE_SYNC) - return fflush_sync_and_check(f); - else - return fflush_and_check(f); + return 0; } static int write_string_file_atomic( |