| 1 |
use crate::{backend, io}; |
| 2 |
use backend::fd::AsFd; |
| 3 |
use backend::fs::types::Advice; |
| 4 |
use core::num::NonZeroU64; |
| 5 |
|
| 6 |
/// `posix_fadvise(fd, offset, len, advice)`—Declares an expected access |
| 7 |
/// pattern for a file. |
| 8 |
/// |
| 9 |
/// If `len` is `None`, the advice extends to the end of the file. |
| 10 |
/// |
| 11 |
/// # References |
| 12 |
/// - [POSIX] |
| 13 |
/// - [Linux] |
| 14 |
/// - [FreeBSD] |
| 15 |
/// |
| 16 |
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_fadvise.html |
| 17 |
/// [Linux]: https://man7.org/linux/man-pages/man2/posix_fadvise.2.html |
| 18 |
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=posix_fadvise&sektion=2 |
| 19 |
#[inline] |
| 20 |
#[doc(alias = "posix_fadvise")] |
| 21 |
pub fn fadvise<Fd: AsFd>( |
| 22 |
fd: Fd, |
| 23 |
offset: u64, |
| 24 |
len: Option<NonZeroU64>, |
| 25 |
advice: Advice, |
| 26 |
) -> io::Result<()> { |
| 27 |
backend::fs::syscalls::fadvise(fd.as_fd(), offset, len, advice) |
| 28 |
} |