Skip to main content

Crate hfsplus_core

Crate hfsplus_core 

Source
Expand description

HFS+ / HFSX volume-header detection (Apple TN1150).

Apple optical discs are frequently hybrids: an ISO 9660 filesystem and an HFS/HFS+ volume sharing the same disc, so a Mac and a PC each see their own filesystem. The HFS+ volume header sits at a fixed 1024-byte offset from the volume start (TN1150 §“Volume Header”), with a big-endian H+ (HFS+) or HX (HFSX) signature.

This crate reads the volume header (geometry), walks the catalog B-tree to list directories (list_root, list_dir, recursive walk), and extracts file contents (read_file) — including HFS+/APFS transparently compressed files, which it decodes via the decmpfs module (zlib / LZVN / LZFSE, inline xattr or resource fork). Journal replay is out of scope. Validated against real hdiutil/ditto-created HFS+ volumes.

Modules§

decmpfs
HFS+/APFS transparent-compression (decmpfs) decoder.

Structs§

CatalogLoc
Located catalog B-tree geometry within an HFS+ volume.
HfsEntry
An entry in an HFS+ directory.
HfsPathEntry
A path-qualified entry produced by walk.
HfsStat
Per-CNID metadata for one catalog entry: kind, data-fork size, and the three HFS+ MAC timestamps. Timestamps are raw HFS+ values (u32 seconds since the HFS+ epoch, 1904-01-01 UTC) — a consumer converts them.
HfsVolume
Parsed HFS+ volume header fields (geometry only).
HfsXattr
One extended attribute: its name and how the volume stored it.

Enums§

HfsKind
Which Apple volume signature was found.
HfsXattrError
Why an extended-attribute question could not be answered.
HfsXattrValue
How HFS+ chose to store an extended attribute’s value.

Constants§

MAX_LEAF_NODES
Bound on catalog leaf nodes walked, guarding against a corrupt fLink chain.
VOLUME_HEADER_OFFSET
Byte offset of the HFS+ volume header from the start of the volume.

Functions§

be16
be32
decmpfs_xattr
Look up the com.apple.decmpfs extended attribute for cnid by walking the attributes B-tree. Returns None if the volume has no attributes file or the file carries no such attribute (i.e. it is not transparently compressed).
decode_utf16
Decode a big-endian UTF-16 byte slice to a String (lossy).
for_each_record
Walk the catalog leaf-node chain, invoking f with each record slice.
list_dir
List the immediate children of the folder parent_cnid by walking the HFS+ catalog B-tree.
list_root
List the root directory of an HFS+ volume. See list_dir.
list_xattrs
List every extended attribute attached to cnid, in B-tree (name) order.
locate_catalog
Locate the catalog B-tree from the volume header (its first extent).
locate_extents
Locate the extents-overflow B-tree, or None when the volume has none.
parse
Parse the HFS+/HFSX volume header from a buffer that begins at the volume start (the header is read at offset 1024). Returns None if the buffer is too short or carries no HFS+ signature.
read_file
Read a file’s data-fork contents by catalog node ID.
read_xattr
Read one extended attribute’s bytes, materializing a fork-stored value from its allocation blocks.
stat
Look up the HfsStat of a catalog entry by CNID, walking the catalog B-tree to its file/folder record. Returns the entry’s kind, data-fork logical size (0 for a folder), and its three HFS+ MAC timestamps (raw, unconverted).
walk
Recursively list every file and folder in an HFS+ volume, depth-first from the root, returning /-joined paths.