Skip to content

Commit

Permalink
Rollup merge of #101118 - devnexen:fs_getmode_bsd, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
fs::get_mode enable getting the data via fcntl/F_GETFL on major BSD

supporting this flag.
  • Loading branch information
JohnTitor authored Oct 9, 2022
2 parents 79a664d + c8f73e7 commit d0f1cf5
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 @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit d0f1cf5

Please sign in to comment.