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.
This commit is contained in:
commit
3bee49f42b
1 changed files with 9 additions and 2 deletions
|
@ -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<()> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue