Skip to content

Commit

Permalink
Rollup merge of #77900 - Thomasdezeeuw:fdatasync, r=dtolnay
Browse files Browse the repository at this point in the history
Use fdatasync for File::sync_data on more OSes

Add support for the following OSes:
 * Android
 * FreeBSD: https://www.freebsd.org/cgi/man.cgi?query=fdatasync&sektion=2
 * OpenBSD: https://man.openbsd.org/OpenBSD-5.8/fsync.2
 * NetBSD: https://man.netbsd.org/fdatasync.2
 * illumos: https://illumos.org/man/3c/fdatasync
  • Loading branch information
JohnTitor committed Oct 16, 2020
2 parents 75ef735 + 8c0c7ec commit 9abf81a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions library/std/src/sys/unix/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,25 @@ impl File {
unsafe fn os_datasync(fd: c_int) -> c_int {
libc::fcntl(fd, libc::F_FULLFSYNC)
}
#[cfg(target_os = "linux")]
#[cfg(any(
target_os = "freebsd",
target_os = "linux",
target_os = "android",
target_os = "netbsd",
target_os = "openbsd"
))]
unsafe fn os_datasync(fd: c_int) -> c_int {
libc::fdatasync(fd)
}
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
#[cfg(not(any(
target_os = "android",
target_os = "freebsd",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
)))]
unsafe fn os_datasync(fd: c_int) -> c_int {
libc::fsync(fd)
}
Expand Down

0 comments on commit 9abf81a

Please sign in to comment.