From: Carl Worth Date: Sun, 22 Mar 2009 22:17:08 +0000 (-0700) Subject: Add an fsync (Ted T'so would be pleased) X-Git-Url: https://git.cworth.org/git?p=mnemon;a=commitdiff_plain;h=bc28e389a7758c1450a90bf5290ba216d5ea1abe;hp=ccc2a54bb3a687478f3fadc0648a603e515e4970 Add an fsync (Ted T'so would be pleased) 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. --- diff --git a/mnemon.c b/mnemon.c index db8f62f..5ce7364 100644 --- a/mnemon.c +++ b/mnemon.c @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -730,6 +731,7 @@ mnemon_save (mnemon_t *mnemon) category_print (category, file); + fsync (fileno (file)); fclose (file); err = rename (lock_filename, filename);