Skip to main content

ObjectMap

Struct ObjectMap 

Source
#[non_exhaustive]
pub struct ObjectMap { /* private fields */ }
Expand description

An object map header (omap_phys_t): the entry point into a volume/container object map’s backing B-tree.

Implementations§

Source§

impl ObjectMap

Source

pub fn parse(block: &[u8]) -> Result<Self>

Parse and validate an omap_phys_t header from a block.

Validates magic-by-type (o_type & 0xffff == OBJECT_TYPE_OMAP) and the Fletcher-64 checksum before trusting any field (checksum-before-trust).

§Errors

crate::ApfsError::NoValidSuperblock-style failures are not used here; instead crate::ApfsError::UnexpectedObjectType is returned for a short block or a non-omap object (carrying the offending type), and crate::ApfsError::ChecksumMismatch for a Fletcher-64 failure.

Source

pub fn tree_oid(&self) -> u64

om_tree_oid — the oid of the B-tree backing this object map. For a container omap the tree is stored physically (om_tree_type carries the physical storage flag), so this oid is also the tree root’s block address.

Source

pub fn tree_type(&self) -> u32

om_tree_type (storage flags in the high bits | object type in the low).

Source

pub fn flags(&self) -> u32

om_flags (OMAP_MANUALLY_MANAGED 0x1, OMAP_ENCRYPTING 0x2, …).

Source

pub fn snapshot_tree_oid(&self) -> u64

om_snapshot_tree_oid0 when the omap has no snapshot tree.

Source

pub fn resolve<R: Read + Seek>( &self, reader: &mut R, oid: u64, xid: u64, block_size: usize, ) -> Result<OmapEntry>

Resolve a virtual oid at transaction xid to a physical block address by walking the omap B-tree, choosing the entry with the largest ok_xidxid for the matching ok_oid (the most-recent state at or before the requested transaction).

The container omap tree is stored physically, so Self::tree_oid is the root node’s block address; the walk reads each node by its physical address, verifying its Fletcher-64 checksum and guarding against cyclic node links.

§Errors

crate::ApfsError::OmapUnresolved if no mapping for oid at or before xid exists; crate::ApfsError::ChecksumMismatch / crate::ApfsError::CycleGuard / crate::ApfsError::Io on a structurally invalid tree or a read failure.

Trait Implementations§

Source§

impl Clone for ObjectMap

Source§

fn clone(&self) -> ObjectMap

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 Copy for ObjectMap

Source§

impl Debug for ObjectMap

Source§

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

Formats the value using the given formatter. 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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.