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§
- Catalog
Loc - Located catalog B-tree geometry within an HFS+ volume.
- HfsEntry
- An entry in an HFS+ directory.
- HfsPath
Entry - 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 (
u32seconds 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.
- HfsXattr
Error - Why an extended-attribute question could not be answered.
- HfsXattr
Value - How HFS+ chose to store an extended attribute’s value.
Constants§
- MAX_
LEAF_ NODES - Bound on catalog leaf nodes walked, guarding against a corrupt
fLinkchain. - 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.decmpfsextended attribute forcnidby walking the attributes B-tree. ReturnsNoneif 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
fwith each record slice. - list_
dir - List the immediate children of the folder
parent_cnidby 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
Nonewhen 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
Noneif 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
HfsStatof 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.