From 311b1ceb2cc3e69130c46b0485b2c55a1b166d62 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Wed, 30 Aug 2017 07:49:50 +0200 Subject: Prep v235: Apply pending upstream updates in src/basic [1/4] --- src/basic/fileio.c | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) (limited to 'src/basic/fileio.c') diff --git a/src/basic/fileio.c b/src/basic/fileio.c index 13b2e312f..7edc31d0a 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -70,7 +70,7 @@ int write_string_stream_ts(FILE *f, const char *line, bool enforce_newline, stru return fflush_and_check(f); } -static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline, bool do_fsync) { +static int write_string_file_atomic(const char *fn, const char *line, bool enforce_newline) { _cleanup_fclose_ FILE *f = NULL; _cleanup_free_ char *p = NULL; int r; @@ -85,9 +85,6 @@ static int write_string_file_atomic(const char *fn, const char *line, bool enfor (void) fchmod_umask(fileno(f), 0644); r = write_string_stream(f, line, enforce_newline); - if (r >= 0 && do_fsync) - r = fflush_sync_and_check(f); - if (r >= 0) { if (rename(p, fn) < 0) r = -errno; @@ -106,14 +103,10 @@ int write_string_file_ts(const char *fn, const char *line, WriteStringFileFlags assert(fn); assert(line); - /* We don't know how to verify whether the file contents was already on-disk. */ - assert(!((flags & WRITE_STRING_FILE_VERIFY_ON_FAILURE) && (flags & WRITE_STRING_FILE_SYNC))); - if (flags & WRITE_STRING_FILE_ATOMIC) { assert(flags & WRITE_STRING_FILE_CREATE); - r = write_string_file_atomic(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE), - flags & WRITE_STRING_FILE_SYNC); + r = write_string_file_atomic(fn, line, !(flags & WRITE_STRING_FILE_AVOID_NEWLINE)); if (r < 0) goto fail; @@ -150,12 +143,6 @@ int write_string_file_ts(const char *fn, const char *line, WriteStringFileFlags if (r < 0) goto fail; - if (flags & WRITE_STRING_FILE_SYNC) { - r = fflush_sync_and_check(f); - if (r < 0) - return r; - } - return 0; fail: @@ -1144,21 +1131,6 @@ int fflush_and_check(FILE *f) { return 0; } -int fflush_sync_and_check(FILE *f) { - int r; - - assert(f); - - r = fflush_and_check(f); - if (r < 0) - return r; - - if (fsync(fileno(f)) < 0) - return -errno; - - return 0; -} - /* This is much like mkostemp() but is subject to umask(). */ int mkostemp_safe(char *pattern) { _cleanup_umask_ mode_t u = 0; -- cgit v1.2.3