Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/2480.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add fcntl constant `F_RDADVISE` for Apple target
13 changes: 13 additions & 0 deletions src/fcntl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
use crate::errno::Errno;
#[cfg(all(target_os = "freebsd", target_arch = "x86_64"))]
use core::slice;
#[cfg(apple_targets)]
use libc::off_t;
use libc::{c_int, c_uint, size_t, ssize_t};
#[cfg(any(
target_os = "netbsd",
Expand Down Expand Up @@ -797,6 +799,9 @@ pub enum FcntlArg<'a> {
/// Return the full path without firmlinks of the fd.
#[cfg(apple_targets)]
F_GETPATH_NOFIRMLINK(&'a mut PathBuf),
/// Issue an advisory read async with no copy to user
#[cfg(apple_targets)]
F_RDADVISE(off_t, c_int),
// TODO: Rest of flags
}

Expand Down Expand Up @@ -905,6 +910,14 @@ pub fn fcntl<Fd: std::os::fd::AsFd>(fd: Fd, arg: FcntlArg) -> Result<c_int> {
*path = PathBuf::from(OsString::from(optr.to_str().unwrap()));
return Ok(ok_res)
},
#[cfg(apple_targets)]
F_RDADVISE(offset, count) => {
let rad = libc::radvisory {
ra_offset: offset,
ra_count: count,
};
libc::fcntl(fd, libc::F_RDADVISE, &rad)
}
}
};

Expand Down