Skip to main content

mmap_madvise

Function mmap_madvise 

Source
pub fn mmap_madvise(
    fd: impl AsRawFd,
    offset: u64,
    len: usize,
    touch: bool,
) -> Result<(), CoreError>
Expand description

Map a file range, advise the kernel that it will be needed, then unmap it.

offset must be page-aligned. This low-level primitive rejects unaligned offsets with EINVAL instead of silently widening the requested range. Map a file range and advise the kernel with MADV_WILLNEED.

ยงErrors

  • EBADF: The file descriptor is invalid.
  • EINVAL: The offset is not page-aligned or the range is invalid.
  • ENOMEM: Insufficient kernel memory.