]> git.cworth.org Git - mnemon/commitdiff
Add an fsync (Ted T'so would be pleased)
authorCarl Worth <cworth@cworth.org>
Sun, 22 Mar 2009 22:17:08 +0000 (15:17 -0700)
committerCarl Worth <cworth@cworth.org>
Sun, 22 Mar 2009 22:17:08 +0000 (15:17 -0700)
We've been using open;write;close;rename for udpating mnemon files,
but with recent discussion of ext4 failure modes, Ted has taught
that the only reliable way of getting the desired results is to
fsync before the close. That fsync does more than we really want
here, but there's no way to ask for a less heavy version of what
we want.

mnemon.c

index db8f62fe87c917de251bcb4537c65eed7f65c15c..5ce736433eed2cff4c931dde86a39c490f8f15f0 100644 (file)
--- a/mnemon.c
+++ b/mnemon.c
@@ -26,6 +26,7 @@
 
 #include <sys/types.h>
 #include <sys/time.h>
+#include <unistd.h>
 #include <dirent.h>
 #include <errno.h>
 #include <string.h>
@@ -730,6 +731,7 @@ mnemon_save (mnemon_t *mnemon)
 
        category_print (category, file);
 
+       fsync (fileno (file));
        fclose (file);
 
        err = rename (lock_filename, filename);