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.
This commit is contained in:
Lennart Poettering
2018-02-20 15:39:31 +01:00
parent 11b29a96e9
commit 8ac2f74fb6
4 changed files with 15 additions and 3 deletions
+6 -1
View File
@@ -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;
}
int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) {