Skip to content

Commit 211f1ab

Browse files
authored
fcntl adding F_RDAHEAD for apple targets. (#2482)
Enable/disable read ahead globally on the file descriptor. When on, the os preemptively reads data in cache to anticipate future read operations.
1 parent e599223 commit 211f1ab

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

changelog/2482.added.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add fcntl constant `F_RDAHEAD` for Apple target

src/fcntl.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,9 @@ pub enum FcntlArg<'a> {
800800
/// Issue an advisory read async with no copy to user
801801
#[cfg(apple_targets)]
802802
F_RDADVISE(libc::radvisory),
803+
/// Turn read ahead off/on
804+
#[cfg(apple_targets)]
805+
F_RDAHEAD(bool)
803806
// TODO: Rest of flags
804807
}
805808

@@ -912,6 +915,11 @@ pub fn fcntl<Fd: std::os::fd::AsFd>(fd: Fd, arg: FcntlArg) -> Result<c_int> {
912915
F_RDADVISE(rad) => {
913916
libc::fcntl(fd, libc::F_RDADVISE, &rad)
914917
}
918+
#[cfg(apple_targets)]
919+
F_RDAHEAD(on) => {
920+
let val = if on { 1 } else { 0 };
921+
libc::fcntl(fd, libc::F_RDAHEAD, val)
922+
}
915923
}
916924
};
917925

0 commit comments

Comments
 (0)