From be1b0ff1fcd6ad820a7fd111ac671fb51cc68001 Mon Sep 17 00:00:00 2001 From: Dana Powers Date: Wed, 14 Aug 2013 22:26:11 -0700 Subject: [PATCH] On Mac OS X fsync does not guarantee write to disk. Use fcntl F_FULLFSYNC instead. --- port/port_posix.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/port/port_posix.h b/port/port_posix.h index f2b89bffb99c2..21c845e211ff0 100644 --- a/port/port_posix.h +++ b/port/port_posix.h @@ -62,12 +62,16 @@ #define fflush_unlocked fflush #endif -#if defined(OS_MACOSX) || defined(OS_FREEBSD) ||\ +#if defined(OS_FREEBSD) ||\ defined(OS_OPENBSD) || defined(OS_DRAGONFLYBSD) // Use fsync() on platforms without fdatasync() #define fdatasync fsync #endif +#if defined(OS_MACOSX) +#define fdatasync(fd) fcntl(fd, F_FULLFSYNC, 0) +#endif + #if defined(OS_ANDROID) && __ANDROID_API__ < 9 // fdatasync() was only introduced in API level 9 on Android. Use fsync() // when targetting older platforms.