rustix/fs/
fadvise.rs

1use crate::{backend, io};
2use backend::fd::AsFd;
3use backend::fs::types::Advice;
4
5/// `posix_fadvise(fd, offset, len, advice)`—Declares an expected access
6/// pattern for a file.
7///
8/// # References
9///  - [POSIX]
10///  - [Linux]
11///
12/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_fadvise.html
13/// [Linux]: https://man7.org/linux/man-pages/man2/posix_fadvise.2.html
14#[inline]
15#[doc(alias = "posix_fadvise")]
16pub fn fadvise<Fd: AsFd>(fd: Fd, offset: u64, len: u64, advice: Advice) -> io::Result<()> {
17    backend::fs::syscalls::fadvise(fd.as_fd(), offset, len, advice)
18}