pub trait Mapper {
// Required methods
fn map(
&self,
mem_offset: u64,
size: usize,
fd: &dyn AsRawFd,
file_offset: u64,
prot: Protection
) -> Result<()>;
fn unmap(&self, offset: u64, size: u64) -> Result<()>;
}
Expand description
A trait for memory mapping for DAX.
For some transports (like virtio) it may be possible to share a region of memory with the FUSE kernel driver so that it can access file contents directly without issuing read or write requests. In this case the driver will instead send requests to map a section of a file into the shared memory region.
Required Methods§
sourcefn map(
&self,
mem_offset: u64,
size: usize,
fd: &dyn AsRawFd,
file_offset: u64,
prot: Protection
) -> Result<()>
fn map( &self, mem_offset: u64, size: usize, fd: &dyn AsRawFd, file_offset: u64, prot: Protection ) -> Result<()>
Maps size
bytes starting at file_offset
bytes from within the given fd
at mem_offset
bytes from the start of the memory region with prot
protections. mem_offset
must be
page aligned.
§Arguments
mem_offset
- Page aligned offset into the memory region in bytes.size
- Size of memory region in bytes.fd
- File descriptor to mmap from.file_offset
- Offset in bytes from the beginning offd
to start the mmap.prot
- Protection of the memory region.