Skip to main content

ApfsContainer

Struct ApfsContainer 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn superblock(&self) -> &NxSuperblock

The live container superblock resolved from the checkpoint ring.

Source

pub fn live_superblock_paddr(&self) -> u64

Block address of the live superblock within the checkpoint descriptor area.

Source

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.

Source

pub fn into_reader(self) -> R

Consume the container, returning the underlying reader.

Auto Trait Implementations§

§

impl<R> Freeze for ApfsContainer<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for ApfsContainer<R>
where R: RefUnwindSafe,

§

impl<R> Send for ApfsContainer<R>
where R: Send,

§

impl<R> Sync for ApfsContainer<R>
where R: Sync,

§

impl<R> Unpin for ApfsContainer<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for ApfsContainer<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for ApfsContainer<R>
where R: UnwindSafe,

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> 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, 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.