pub struct Mapping { /* private fields */ }Expand description
Describes a single memory mapping entry.
The size of this type heavily influences Starnix’s heap usage in common scenarios, please think twice about increasing its size. Compiling in “release” mode includes a compile time check for size increase.
Implementations§
Source§impl Mapping
impl Mapping
pub fn name(&self) -> MappingNameRef<'_>
pub fn set_name(&mut self, new: MappingName)
Source§impl Mapping
impl Mapping
pub fn new( backing: MappingBacking, flags: MappingFlags, mode: MappingMode, ) -> Mapping
pub fn with_name( backing: MappingBacking, flags: MappingFlags, name: MappingName, mode: MappingMode, ) -> Mapping
pub fn flags(&self) -> MappingFlags
pub fn mapping_mode(&self) -> MappingMode
pub fn set_mapping_mode(&mut self, mode: MappingMode)
pub fn set_flags(&mut self, new_flags: MappingFlags)
pub fn get_backing_internal(&self) -> &MappingBacking
pub fn set_backing_internal(&mut self, backing: MappingBacking)
pub fn set_uffd(&mut self, mode: FaultRegisterMode)
pub fn clear_uffd(&mut self)
pub fn set_mlock(&mut self)
pub fn clear_mlock(&mut self)
pub fn new_private_anonymous( flags: MappingFlags, name: MappingName, mode: MappingMode, ) -> Mapping
pub fn inflate_to_include_guard_pages( &self, range: &Range<UserAddress>, ) -> Range<UserAddress> ⓘ
Sourcepub fn address_to_offset(&self, addr: UserAddress) -> u64
pub fn address_to_offset(&self, addr: UserAddress) -> u64
Converts a UserAddress to an offset in this mapping’s memory object.
pub fn can_read(&self) -> bool
pub fn can_write(&self) -> bool
pub fn can_exec(&self) -> bool
Sourcepub fn may_exec(&self) -> bool
pub fn may_exec(&self) -> bool
Returns whether this mapping is allowed to be executable, as reported by me in
/proc/[pid]/smaps. For file mappings, this is false if the file is on a noexec mount
or is sealed against execution. Security checks (see security::file_mprotect()) may still
deny making the mapping executable.
Sourcepub fn is_private_file(&self) -> bool
pub fn is_private_file(&self) -> bool
Returns whether this is a private mapping of a file (as opposed to a MAP_SHARED mapping
or an anonymous mapping).
Unlike MAP_SHARED and anonymous mappings (which access their backing pages directly),
writes to a private file mapping perform copy-on-write against the underlying file VMO.
MappingFlags::ANONYMOUS must also be checked because some anonymous mappings (such as
mmap of /dev/zero) carry MappingName::File for /proc/<pid>/maps display while
setting MappingFlags::ANONYMOUS.
Sourcepub fn is_unmodified_private_file(&self) -> bool
pub fn is_unmodified_private_file(&self) -> bool
Returns whether this is a private file mapping that is not yet recorded as holding pages modified via copy-on-write.
Sourcepub fn has_cow_modifications(&self) -> bool
pub fn has_cow_modifications(&self) -> bool
Returns whether this is a private file mapping with pages that were modified via copy-on-write, and are therefore no longer shared with the mapped file.
Copy-on-write modifications are tracked at the granularity of the backing MemoryObject
(and synchronized across all mappings sharing that backing memory when write access is
enabled), rather than per-page.
Sourcepub fn set_cow_modified(&mut self)
pub fn set_cow_modified(&mut self)
Records that the memory of this mapping holds pages modified via copy-on-write. See
Mapping::has_cow_modifications.
Sourcepub fn vmar_flags(&self) -> MappingFlags
pub fn vmar_flags(&self) -> MappingFlags
Returns the MappingFlags to apply in the user VMAR when mapping or restoring
permissions on populated pages of this mapping.
For writable private file mappings, MappingFlags::WRITE is omitted while the mapping is
unmodified (both when initially mapped and across any subsequent VMAR remaps or protection
updates) so that the first write faults. Once a write is recorded with
Mapping::set_cow_modified, vmar_flags() includes MappingFlags::WRITE.
Note that userfaultfd (MappingFlags::UFFD) strips VMAR permissions separately on
unpopulated pages via UserFault, and uses vmar_flags() when restoring permissions on
populated or unregistered ranges.
pub fn private_anonymous(&self) -> bool
pub fn write_vm_flags(&self, sink: &mut DynamicFileBuf)
Trait Implementations§
impl Eq for Mapping
Auto Trait Implementations§
impl !RefUnwindSafe for Mapping
impl !UnwindSafe for Mapping
impl Freeze for Mapping
impl Send for Mapping
impl Sync for Mapping
impl Unpin for Mapping
impl UnsafeUnpin for Mapping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more