]> arthur.barton.de Git - bup.git/commitdiff
fdatasync: call F_FULLFSYNC fcntl on OS X
authorRob Browning <rlb@defaultvalue.org>
Fri, 1 Jan 2016 20:04:09 +0000 (14:04 -0600)
committerRob Browning <rlb@defaultvalue.org>
Fri, 1 Jan 2016 20:12:41 +0000 (14:12 -0600)
Apparently fsync doesn't guarantee to actually sync all the way to disk
on OS X, for that you have to use this fcntl.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/helpers.py

index 5bae5dee943d477a97f6dd65c73cc154eec089f8..377678bf39332db1fa245d63cb979eee2591e615 100644 (file)
@@ -41,11 +41,15 @@ def atof(s):
 buglvl = atoi(os.environ.get('BUP_DEBUG', 0))
 
 
-# If the platform doesn't have fdatasync (OS X), fall back to fsync.
-try:
-    fdatasync = os.fdatasync
-except AttributeError:
-    fdatasync = os.fsync
+if sys.platform.startswith('darwin'):
+    # Apparently fsync on OS X doesn't guarantee to sync all the way down
+    import fcntl
+    fdatasync = lambda fd : fcntl.fcntl(fd, fcntl.F_FULLFSYNC)
+else: # If the platform doesn't have fdatasync, fall back to fsync
+    try:
+        fdatasync = os.fdatasync
+    except AttributeError:
+        fdatasync = os.fsync
 
 
 # Write (blockingly) to sockets that may or may not be in blocking mode.