summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-id128/id128-util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-19 18:24:36 +0100
committerLennart Poettering <lennart@poettering.net>2018-02-20 15:39:31 +0100
commit8ac2f74fb6bb798db1fb3f7a7bf97f2579e963c2 (patch)
tree8f8a5c71c02e842055c90db92fc9ee9271bce9f9 /src/libsystemd/sd-id128/id128-util.c
parent11b29a96e98054ed69a2314ed71a286e852fa24e (diff)
downloadsystemd-8ac2f74fb6bb798db1fb3f7a7bf97f2579e963c2.tar.gz
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.
Diffstat (limited to 'src/libsystemd/sd-id128/id128-util.c')
-rw-r--r--src/libsystemd/sd-id128/id128-util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libsystemd/sd-id128/id128-util.c b/src/libsystemd/sd-id128/id128-util.c
index a6e38578b1..8ce012e35f 100644
--- a/src/libsystemd/sd-id128/id128-util.c
+++ b/src/libsystemd/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;
}
int id128_write(const char *p, Id128Format f, sd_id128_t id, bool do_sync) {