about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-04-23 03:34:21 +0000
committerbors <bors@rust-lang.org>2019-04-23 03:34:21 +0000
commit3bee49f42b6dfb039d2a8e59e5181e26531c3c11 (patch)
treeaeabecc806d07ca63d3d18b1537b01ca729b94c7 /src/libstd
parent0550766699a6602a51e361e8cb2825b540b7cce8 (diff)
parentd602a6b942e32f4f9a36b6c44471cfcd80a81bb6 (diff)
downloadrust-3bee49f42b6dfb039d2a8e59e5181e26531c3c11.tar.gz
rust-3bee49f42b6dfb039d2a8e59e5181e26531c3c11.zip
Auto merge of #60121 - davazp:fix-sync-all-macos, r=KodrAus
Fix sync_all on macos/ios

`sync_all` should flush all metadata in macos/ios, so it should call `fcntl` with the `F_FULLFSYNC` flag as `sync_data` does.

Note that without this `sync_data` performs more flushes than `sync_all` on macos/ios.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/unix/fs.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/fs.rs b/src/libstd/sys/unix/fs.rs
index a14db108c34..761f1d8c673 100644
--- a/src/libstd/sys/unix/fs.rs
+++ b/src/libstd/sys/unix/fs.rs
@@ -526,8 +526,15 @@ impl File {
     }
 
     pub fn fsync(&self) -> io::Result<()> {
-        cvt_r(|| unsafe { libc::fsync(self.0.raw()) })?;
-        Ok(())
+        cvt_r(|| unsafe { os_fsync(self.0.raw()) })?;
+        return Ok(());
+
+        #[cfg(any(target_os = "macos", target_os = "ios"))]
+        unsafe fn os_fsync(fd: c_int) -> c_int {
+            libc::fcntl(fd, libc::F_FULLFSYNC)
+        }
+        #[cfg(not(any(target_os = "macos", target_os = "ios")))]
+        unsafe fn os_fsync(fd: c_int) -> c_int { libc::fsync(fd) }
     }
 
     pub fn datasync(&self) -> io::Result<()> {