pub unsafe fn mmap<Fd: AsFd>(
ptr: *mut c_void,
len: usize,
prot: ProtFlags,
flags: MapFlags,
fd: Fd,
offset: u64,
) -> Result<*mut c_void>
Expand description
mmap(ptr, len, prot, flags, fd, offset)
—Create a file-backed memory
mapping.
For anonymous mappings (MAP_ANON
/MAP_ANONYMOUS
), see
mmap_anonymous
.
§Safety
If ptr
is not null, it must be aligned to the applicable page size, and
the range of memory starting at ptr
and extending for len
bytes,
rounded up to the applicable page size, must be valid to mutate using
ptr
’s provenance.
If there exist any Rust references referring to the memory region, or if you subsequently create a Rust reference referring to the resulting region, it is your responsibility to ensure that the Rust reference invariants are preserved, including ensuring that the memory is not mutated in a way that a Rust reference would not expect.