pub struct MemoryMappingArena {
addr: *mut u8,
size: usize,
}
Expand description
Tracks Fixed Memory Maps within an anonymous memory-mapped fixed-sized arena in the current process.
Fields§
§addr: *mut u8
§size: usize
Implementations§
source§impl MemoryMappingArena
impl MemoryMappingArena
sourcepub fn new(size: usize) -> Result<MemoryMappingArena>
pub fn new(size: usize) -> Result<MemoryMappingArena>
sourcepub fn add_anon_protection(
&mut self,
offset: usize,
size: usize,
prot: Protection
) -> Result<()>
pub fn add_anon_protection( &mut self, offset: usize, size: usize, prot: Protection ) -> Result<()>
Anonymously maps size
bytes at offset
bytes from the start of the arena
with prot
protections. offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.prot
- Protection (e.g. readable/writable) of the memory region.
sourcepub fn add_anon(&mut self, offset: usize, size: usize) -> Result<()>
pub fn add_anon(&mut self, offset: usize, size: usize) -> Result<()>
Anonymously maps size
bytes at offset
bytes from the start of the arena.
offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.
sourcepub fn add_fd(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor
) -> Result<()>
pub fn add_fd( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor ) -> Result<()>
Maps size
bytes from the start of the given fd
at offset
bytes from
the start of the arena. offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.fd
- File descriptor to mmap from.
sourcepub fn add_fd_offset(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
fd_offset: u64
) -> Result<()>
pub fn add_fd_offset( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, fd_offset: u64 ) -> Result<()>
Maps size
bytes starting at fs_offset
bytes from within the given fd
at offset
bytes from the start of the arena. offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.fd
- File descriptor to mmap from.fd_offset
- Offset in bytes from the beginning offd
to start the mmap.
sourcepub fn add_fd_offset_protection(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
fd_offset: u64,
prot: Protection
) -> Result<()>
pub fn add_fd_offset_protection( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, fd_offset: u64, prot: Protection ) -> Result<()>
Maps size
bytes starting at fs_offset
bytes from within the given fd
at offset
bytes from the start of the arena with prot
protections.
offset
must be page aligned.
§Arguments
offset
- Page aligned offset into the arena in bytes.size
- Size of memory region in bytes.fd
- File descriptor to mmap from.fd_offset
- Offset in bytes from the beginning offd
to start the mmap.prot
- Protection (e.g. readable/writable) of the memory region.
sourcefn try_add(
&mut self,
offset: usize,
size: usize,
prot: Protection,
fd: Option<(&dyn AsRawDescriptor, u64)>
) -> Result<()>
fn try_add( &mut self, offset: usize, size: usize, prot: Protection, fd: Option<(&dyn AsRawDescriptor, u64)> ) -> Result<()>
Helper method that calls appropriate MemoryMapping constructor and adds the resulting map into the arena.
Trait Implementations§
source§impl Drop for MemoryMappingArena
impl Drop for MemoryMappingArena
source§impl From<MemoryMapping> for MemoryMappingArena
impl From<MemoryMapping> for MemoryMappingArena
source§fn from(mmap: MemoryMapping) -> Self
fn from(mmap: MemoryMapping) -> Self
source§impl From<MemoryMapping> for MemoryMappingArena
impl From<MemoryMapping> for MemoryMappingArena
source§fn from(mmap: CrateMemoryMapping) -> Self
fn from(mmap: CrateMemoryMapping) -> Self
source§impl MappedRegion for MemoryMappingArena
impl MappedRegion for MemoryMappingArena
source§fn as_ptr(&self) -> *mut u8
fn as_ptr(&self) -> *mut u8
source§fn add_fd_mapping(
&mut self,
offset: usize,
size: usize,
fd: &dyn AsRawDescriptor,
fd_offset: u64,
prot: Protection
) -> Result<()>
fn add_fd_mapping( &mut self, offset: usize, size: usize, fd: &dyn AsRawDescriptor, fd_offset: u64, prot: Protection ) -> Result<()>
size
bytes starting at fd_offset
bytes from within the given fd
at offset
bytes from the start of the region with prot
protections.
offset
must be page aligned. Read more