pub struct ApfsContainer<R: Read + Seek> { /* private fields */ }Expand description
An open APFS container, the entry point for navigation.
Opening walks the checkpoint ring to the live container::NxSuperblock
(highest valid xid, checksum + magic validated before trust), resolves the
container object map, and enumerates volumes.
Implementations§
Source§impl<R: Read + Seek> ApfsContainer<R>
impl<R: Read + Seek> ApfsContainer<R>
Sourcepub fn open(reader: R) -> Result<Self>
pub fn open(reader: R) -> Result<Self>
Open a container from a Read + Seek source, validating the bootstrap.
Reads block zero (a copy of the container superblock; Apple “Mounting an APFS Partition” step 1), validates its magic + Fletcher-64, walks the checkpoint descriptor ring to the live superblock (highest valid xid), and re-reads that superblock as the live container state.
§Errors
ApfsError::NoValidSuperblock if block zero is malformed or the
checkpoint ring holds no cksum-valid, correctly-magicked NXSB;
ApfsError::CheckpointTreeUnsupported for a tree-backed descriptor
area (phase P2); ApfsError::Io on a read/seek failure.
Sourcepub fn checkpoint_mappings(&self) -> &[CheckpointMapping]
pub fn checkpoint_mappings(&self) -> &[CheckpointMapping]
The live checkpoint-map mappings (ephemeral oid → paddr). Pass these to
reaper::pending_objects to walk the reaper’s ephemeral reap lists.
Sourcepub fn spaceman_paddr(&self) -> Option<u64>
pub fn spaceman_paddr(&self) -> Option<u64>
Physical block of the live space manager (nx_spaceman_oid resolved
through the checkpoint map), or None if it is not mapped. Feed it to
spaceman::is_block_free.
Sourcepub fn reaper_paddr(&self) -> Option<u64>
pub fn reaper_paddr(&self) -> Option<u64>
Physical block of the live reaper (nx_reaper_oid resolved through the
checkpoint map), or None if it is not mapped. Feed it to
reaper::pending_objects.
Sourcepub fn superblock(&self) -> &NxSuperblock
pub fn superblock(&self) -> &NxSuperblock
The live container superblock resolved from the checkpoint ring.
Sourcepub fn live_superblock_paddr(&self) -> u64
pub fn live_superblock_paddr(&self) -> u64
Block address of the live superblock within the checkpoint descriptor area.
Sourcepub fn volume_superblock_addrs(&mut self) -> Result<Vec<u64>>
pub fn volume_superblock_addrs(&mut self) -> Result<Vec<u64>>
Resolve the physical block address of each volume superblock (APSB).
The live NXSB names its volumes by virtual oid (nx_fs_oid[]). Each is
resolved through the container object map (nx_omap_oid, a physical
omap object whose B-tree is stored physically) at the container’s
transaction id, yielding the physical block address of that volume’s
apfs_superblock_t. These paddrs feed volume parsing (phase P3).
Resolution is deterministic and leaves the reader position arbitrary (it seeks as it walks), so callers should not assume a cursor position after.
§Errors
ApfsError::FieldOutOfRange if nx_block_size is outside the spec
range; ApfsError::UnexpectedObjectType if nx_omap_oid does not point
at an omap object; ApfsError::OmapUnresolved if a nx_fs_oid has no
mapping; ApfsError::ChecksumMismatch / ApfsError::CycleGuard /
ApfsError::Io on a structurally invalid omap or a read failure.
Sourcepub fn into_reader(self) -> R
pub fn into_reader(self) -> R
Consume the container, returning the underlying reader.