hfsplus
Cross-platform Rust library for reading Apple HFS+ and HFSX filesystems
Parse HFS+ / HFSX volumes from raw disk images on any platform — no kernel drivers or FUSE required.
Pure Rust, zero unsafe — works everywhere Rust compiles.
Why hfsplus?
hfsplus is the only pure-Rust library for reading HFS+ filesystems with B-tree traversal and extent overflow support.
| Feature | hfsplus | hfsplus-rs | hfs-rs |
|---|---|---|---|
| HFS+ | ✓ | ✓ | ❌ |
| HFSX (case-sensitive) | ✓ | ❌ | ❌ |
| B-tree catalog | ✓ | ✓ | partial |
| Extent overflow | ✓ | ❌ | ❌ |
| Streaming reads | ✓ | ❌ | ❌ |
| Resource forks | ✓ | ❌ | ❌ |
| Unicode names | ✓ | ✓ | ❌ |
Generic Read+Seek |
✓ | ❌ | ❌ |
| Zero dependencies* | ✓ | ❌ | ❌ |
* Only byteorder and thiserror — no compression, no FFI, no system libs.
Example: macOS Kernel Debug Kit DMGs contain HFSX (case-sensitive HFS+) partitions. Most Rust HFS libraries can't read case-sensitive volumes — hfsplus handles both.
Features
| List directories | Browse filesystem tree with names, sizes, timestamps |
| Read files | Extract file contents into memory or stream to a writer |
| Streaming I/O | ForkReader provides Read+Seek access without buffering |
| File metadata | BSD permissions, creation/modification dates, fork info |
| Recursive walk | Walk entire filesystem tree with full paths |
| Path resolution | Navigate by Unix-style paths (/Library/Extensions/foo.kext) |
Format Support
| Format | Support | Description |
|---|---|---|
| HFS+ | ✓ | Standard Mac OS Extended |
| HFSX | ✓ | Case-sensitive variant |
| Legacy HFS | ❌ | Classic Mac OS (pre-1998) |
| APFS | ❌ | Apple File System (2017+) |
Quick Start
Open and Browse
use HfsVolume;
use File;
use BufReader;
let file = open?;
let mut vol = open?;
// List root directory
for entry in vol.list_directory?
Read a File
// Read into memory
let data = vol.read_file?;
// Or stream to a writer (low memory)
let mut out = create?;
vol.read_file_to?;
Walk Entire Filesystem
for entry in vol.walk?
Streaming File Access
use Read;
// Open file for random-access Read+Seek without loading into memory
let mut reader = vol.open_file?;
let mut buf = ;
let n = reader.read?;
File Metadata
let stat = vol.stat?;
println!;
println!;
println!;
println!;
Documentation
| Format Specification | HFS+ volume header, B-tree, and catalog structures |
| Implementation Notes | Tricky parts: Unicode, extent overflow, node parsing |
Example Output
Via dpp-tool hfs (which uses the hfsplus library internally):
$ dpp-tool hfs ls Kernel_Debug_Kit.dmg /
Kind Size Name
--------------------------------------------------------
dir - .HFS+ Private Directory Data\r
dir - .Trashes
dir - Library
dir - System
dir - usr
12288 .DS_Store
1 file(s), 5 directory(ies)
$ dpp-tool hfs info Kernel_Debug_Kit.dmg
HFS+ Volume: Kernel_Debug_Kit.dmg
════════════════════════════════════════════════════════════
Volume Header
────────────────────────────────────────────────────────────
Signature HFSX (case-sensitive)
Version 5
Block size 4096 bytes
Total blocks 260,608
Free blocks 6
Files 3,847
Folders 612
Alternatives
| Crate | HFS+ | HFSX | B-tree | Extents | Streaming | Generic R | Platform |
|---|---|---|---|---|---|---|---|
| hfsplus | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | All |
| hfsplus-rs | ✓ | ❌ | ✓ | ❌ | ❌ | ❌ | All |
| hfs-rs | ❌ | ❌ | partial | ❌ | ❌ | ❌ | Unix |
| hfsfuse | ✓ | ✓ | ✓ | ✓ | ✓ | N/A | Unix (C) |
Choose hfsplus if you need:
- Pure Rust with no FFI or system dependencies
- HFSX (case-sensitive) volume support
- Extent overflow file handling for large/fragmented files
- Generic
Read+Seekinterface (works with files, memory, network streams) - Integration with the
dpppipeline for DMG → HFS+ workflows
Choose hfsfuse if you need:
- FUSE mounting (kernel-level filesystem access)
- HFS+ compression support (zlib, lzvn, lzfse)
- Extended attributes and hard link support
Next Steps
- Write support — create and modify HFS+ volumes
- HFS+ compression — decompress transparent compression (zlib, lzvn, lzfse)
- Extended attributes — read xattr data from the attributes B-tree
- Hard links — resolve directory and file hard links
- Journal parsing — read the HFS+ journal for recovery scenarios
- APFS support — read Apple File System containers (separate crate likely)
- Allocation bitmap — validate filesystem consistency
License
MIT