Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum

fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD

supporting this flag.
This commit is contained in:
Yuki Okushi 2022-10-10 00:09:39 +09:00 committed by GitHub
commit d0f1cf5de7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1240,7 +1240,14 @@ impl fmt::Debug for File {
None
}
#[cfg(any(target_os = "linux", target_os = "macos", target_os = "vxworks"))]
#[cfg(any(
target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "vxworks"
))]
fn get_mode(fd: c_int) -> Option<(bool, bool)> {
let mode = unsafe { libc::fcntl(fd, libc::F_GETFL) };
if mode == -1 {
@ -1254,7 +1261,14 @@ impl fmt::Debug for File {
}
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "vxworks")))]
#[cfg(not(any(
target_os = "linux",
target_os = "macos",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "vxworks"
)))]
fn get_mode(_fd: c_int) -> Option<(bool, bool)> {
// FIXME(#24570): implement this for other Unix platforms
None