#[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
impl ObjectMap
Sourcepub fn parse(block: &[u8]) -> Result<Self>
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.
Sourcepub fn tree_oid(&self) -> u64
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.
Sourcepub fn tree_type(&self) -> u32
pub fn tree_type(&self) -> u32
om_tree_type (storage flags in the high bits | object type in the low).
Sourcepub fn snapshot_tree_oid(&self) -> u64
pub fn snapshot_tree_oid(&self) -> u64
om_snapshot_tree_oid — 0 when the omap has no snapshot tree.
Sourcepub fn resolve<R: Read + Seek>(
&self,
reader: &mut R,
oid: u64,
xid: u64,
block_size: usize,
) -> Result<OmapEntry>
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_xid ≤ xid 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.