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 has_cow_modifications(&self) -> Result<bool, Errno>
pub fn has_cow_modifications(&self) -> Result<bool, Errno>
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.
Writable private file mappings created by default_mmap() are backed by a copy-on-write
child of the file’s memory, created for each mmap() call. This over-approximates the
modified pages to the whole region that was mapped, rather than just the pages of this
mapping. Read-only ones (MappingFlags::LAZY_PRIVATE_FILE) are backed by the file’s memory
until they are written, so they have no modified pages.
Zircon only reports the number of pages that a memory object holds, not which ones, so the whole memory object is considered.
TODO(https://fxbug.dev/409256444): This also reports pages that were committed without
being written (e.g. with MAP_POPULATE), and, for files whose memory isn’t pager-backed
(e.g. tmpfs), pages that the file stopped sharing because the file was modified.
§Errors
Fails if the information about the memory object can’t be retrieved (e.g. if its handle
lacks Rights::INSPECT), in which case whether it holds modified pages is unknown.
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 is_known_cow_modified(&self) -> bool
pub fn is_known_cow_modified(&self) -> bool
Returns whether the memory of this mapping is already known to hold pages modified via copy-on-write.
pub fn private_anonymous(&self) -> bool
pub fn vm_flags(&self) -> String
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
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