Skip to content

Commit 9abf81a

Browse files
authored
Rollup merge of #77900 - Thomasdezeeuw:fdatasync, r=dtolnay
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
2 parents 75ef735 + 8c0c7ec commit 9abf81a

File tree

1 file changed

+16
-2
lines changed
  • library/std/src/sys/unix

1 file changed

+16
-2
lines changed

library/std/src/sys/unix/fs.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,25 @@ impl File {
787787
unsafe fn os_datasync(fd: c_int) -> c_int {
788788
libc::fcntl(fd, libc::F_FULLFSYNC)
789789
}
790-
#[cfg(target_os = "linux")]
790+
#[cfg(any(
791+
target_os = "freebsd",
792+
target_os = "linux",
793+
target_os = "android",
794+
target_os = "netbsd",
795+
target_os = "openbsd"
796+
))]
791797
unsafe fn os_datasync(fd: c_int) -> c_int {
792798
libc::fdatasync(fd)
793799
}
794-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
800+
#[cfg(not(any(
801+
target_os = "android",
802+
target_os = "freebsd",
803+
target_os = "ios",
804+
target_os = "linux",
805+
target_os = "macos",
806+
target_os = "netbsd",
807+
target_os = "openbsd"
808+
)))]
795809
unsafe fn os_datasync(fd: c_int) -> c_int {
796810
libc::fsync(fd)
797811
}

0 commit comments

Comments
 (0)