Skip to main content

Mapping

Struct Mapping 

Source
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

Source

pub fn name(&self) -> MappingNameRef<'_>

Source

pub fn set_name(&mut self, new: MappingName)

Source§

impl Mapping

Source

pub fn new( backing: MappingBacking, flags: MappingFlags, mode: MappingMode, ) -> Mapping

Source

pub fn with_name( backing: MappingBacking, flags: MappingFlags, name: MappingName, mode: MappingMode, ) -> Mapping

Source

pub fn flags(&self) -> MappingFlags

Source

pub fn mapping_mode(&self) -> MappingMode

Source

pub fn set_mapping_mode(&mut self, mode: MappingMode)

Source

pub fn set_flags(&mut self, new_flags: MappingFlags)

Source

pub fn get_backing_internal(&self) -> &MappingBacking

Source

pub fn set_backing_internal(&mut self, backing: MappingBacking)

Source

pub fn set_uffd(&mut self, mode: FaultRegisterMode)

Source

pub fn clear_uffd(&mut self)

Source

pub fn set_mlock(&mut self)

Source

pub fn clear_mlock(&mut self)

Source

pub fn new_private_anonymous( flags: MappingFlags, name: MappingName, mode: MappingMode, ) -> Mapping

Source

pub fn inflate_to_include_guard_pages( &self, range: &Range<UserAddress>, ) -> Range<UserAddress> ⓘ

Source

pub fn address_to_offset(&self, addr: UserAddress) -> u64

Converts a UserAddress to an offset in this mapping’s memory object.

Source

pub fn can_read(&self) -> bool

Source

pub fn can_write(&self) -> bool

Source

pub fn can_exec(&self) -> bool

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn private_anonymous(&self) -> bool

Source

pub fn vm_flags(&self) -> String

Trait Implementations§

Source§

impl Clone for Mapping

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Mapping

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Mapping

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Eq for Mapping

Source§

impl PartialEq for Mapping

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<F, N> FidlIntoNative<Box<N>> for F
where F: FidlIntoNative<N>,

§

fn fidl_into_native(self) -> Box<N>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
Source§

impl<T, U> Into32<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_32(self) -> U

Source§

impl<T, U> Into64<U> for T
where U: MultiArchFrom<T>,

Source§

fn into_64(self) -> U

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

Source§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Cast the given object into a dyn std::any::Any.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T, U> IntoExt<U> for T
where U: FromExt<T>,

§

fn into_ext(self) -> U

Performs the conversion.
Source§

impl<T, U> IntoFidl<U> for T
where U: FromFidl<T>,

Source§

fn into_fidl(self) -> U

Source§

impl<T, U> MultiArchFrom<T> for U
where U: From<T>,

Source§

fn from_64(value: T) -> U

Source§

fn from_32(value: T) -> U

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T, U> TryIntoExt<U> for T
where U: TryFromExt<T>,

§

type Error = <U as TryFromExt<T>>::Error

§

fn try_into_ext(self) -> Result<U, <T as TryIntoExt<U>>::Error>

Tries to perform the conversion.
§

impl<St> WithTag for St

§

fn tagged<T>(self, tag: T) -> Tagged<T, St> ⓘ

Produce a new stream from this one which yields item tupled with a constant tag