diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-02-19 18:24:36 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-05-30 07:59:00 +0200 |
commit | ca62631389dbc038c84a321f80e303f8903b7ea7 (patch) | |
tree | d176a5f956979514d4434ded94cb4aefd52a0243 | |
parent | 71b2b9d7412a0f916f5be02c73f8b12e531babf8 (diff) |
tree-wide: make use of fsync_directory_of_file() all over the place
Let's make use this at various places we call fsync(), to make things
fully reliable, as the kernel devs suggest to first fsync() files and
then fsync() the directories they are located in.
-rw-r--r-- | src/basic/fileio.c | 4 | ||||
-rw-r--r-- | src/libelogind/sd-id128/id128-util.c | 7 |
2 files changed, 10 insertions, 1 deletions
diff --git a/src/basic/fileio.c b/src/basic/fileio.c index c16ef3b1e..484355652 100644 --- a/src/basic/fileio.c +++ b/src/basic/fileio.c @@ -1193,6 +1193,10 @@ int fflush_sync_and_check(FILE *f) { if (fsync(fileno(f)) < 0) return -errno; + r = fsync_directory_of_file(fileno(f)); + if (r < 0) + return r; + return 0; } diff --git a/src/libelogind/sd-id128/id128-util.c b/src/libelogind/sd-id128/id128-util.c index bdadf3efa..95cda2943 100644 --- a/src/libelogind/sd-id128/id128-util.c +++ b/src/libelogind/sd-id128/id128-util.c @@ -23,6 +23,7 @@ #include <unistd.h> #include "fd-util.h" +//#include "fs-util.h" #include "hexdecoct.h" #include "id128-util.h" #include "io-util.h" @@ -180,9 +181,13 @@ int id128_write_fd(int fd, Id128Format f, sd_id128_t id, bool do_sync) { if (do_sync) { if (fsync(fd) < 0) return -errno; + + r = fsync_directory_of_file(fd); + if (r < 0) + return r; } - return r; + return 0; } #if 0 /// UNNEEDED by elogind |