Skip to content

Commit 8c0c7ec

Browse files
committed
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
1 parent 7820135 commit 8c0c7ec

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

+16-2
Original file line numberDiff line numberDiff line change
@@ -752,11 +752,25 @@ impl File {
752752
unsafe fn os_datasync(fd: c_int) -> c_int {
753753
libc::fcntl(fd, libc::F_FULLFSYNC)
754754
}
755-
#[cfg(target_os = "linux")]
755+
#[cfg(any(
756+
target_os = "freebsd",
757+
target_os = "linux",
758+
target_os = "android",
759+
target_os = "netbsd",
760+
target_os = "openbsd"
761+
))]
756762
unsafe fn os_datasync(fd: c_int) -> c_int {
757763
libc::fdatasync(fd)
758764
}
759-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "linux")))]
765+
#[cfg(not(any(
766+
target_os = "android",
767+
target_os = "freebsd",
768+
target_os = "ios",
769+
target_os = "linux",
770+
target_os = "macos",
771+
target_os = "netbsd",
772+
target_os = "openbsd"
773+
)))]
760774
unsafe fn os_datasync(fd: c_int) -> c_int {
761775
libc::fsync(fd)
762776
}

0 commit comments

Comments
 (0)