summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-04-25 02:14:54 +0200
committerGitHub <noreply@github.com>2018-04-25 02:14:54 +0200
commit0d6f0ea6c1994a5769704d2150ce907a1132a8c8 (patch)
tree9f8a9483bafef2ac00e10085dfd70f094b029527
parent722df70f106d936f994f5789bd81205957a0b50c (diff)
parentbe83711c7eb6a09e0d0c529c427cebcae87c0c1f (diff)
downloadsystemd-0d6f0ea6c1994a5769704d2150ce907a1132a8c8.tar.gz
Merge pull request #8807 from ChrisLesiak/systemd-update-done-mtime-fix
fileio.c: fix incorrect mtime
-rw-r--r--src/basic/fileio.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c
index ca984aaa14..5cab4c1024 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(