Skip to main content

fadvise

Function fadvise 

Source
pub fn fadvise(
    fd: impl AsRawFd,
    offset: u64,
    len: usize,
    advice: i32,
) -> Result<(), CoreError>
Expand description

Advise the kernel on the expected access pattern for a file range.

offset and len define the byte range; len = 0 means “to end of file”. advice is one of the FADV_* constants.

Unlike most syscalls, posix_fadvise returns the error code directly rather than setting errno.

§Errors

  • EBADF: invalid file descriptor.
  • EINVAL: invalid advice value or unsupported len.
  • ESPIPE: the fd refers to a pipe.