apfs
Cross-platform Rust library for reading Apple File System (APFS) containers
Parse APFS volumes from raw disk images on any platform — no kernel drivers or FUSE required.
Pure Rust, zero unsafe — works everywhere Rust compiles.
Why apfs?
apfs is a standalone pure-Rust library for reading APFS filesystems with full B-tree traversal and object map resolution.
| Feature | apfs | fal-backend-apfs | apfs-fuse | libfsapfs |
|---|---|---|---|---|
| Pure Rust | ✓ | ✓ | ❌ (C++) | ❌ (C) |
| Standalone | ✓ | ❌ (fal ecosystem) | ❌ (FUSE) | ❌ (system lib) |
Generic Read+Seek |
✓ | ❌ | ❌ | ❌ |
| Streaming reads | ✓ | ❌ | ✓ | ✓ |
| Container parsing | ✓ | ✓ | ✓ | ✓ |
| Object map resolution | ✓ | ✓ | ✓ | ✓ |
| Catalog B-tree | ✓ | ✓ | ✓ | ✓ |
| Checkpoint scanning | ✓ | partial | ✓ | ✓ |
| Fletcher-64 checksums | ✓ | ✓ | ✓ | ✓ |
| Encryption | ❌ | ❌ | ✓ | ✓ |
| Compression | ❌ | ❌ | ✓ | ✓ |
| Permissive license | MIT | MIT | GPL-2.0 | LGPL-3.0 |
* Only byteorder and thiserror — no compression, no FFI, no system libs.
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 | ApfsForkReader provides Read+Seek access without buffering |
| File metadata | BSD permissions, creation/modification dates, inode info |
| Recursive walk | Walk entire filesystem tree with full paths |
| Path resolution | Navigate by Unix-style paths (/Applications/Upscayl.app/Contents/Info.plist) |
| Checksums | Fletcher-64 verification on all on-disk objects |
| Checkpoint scanning | Finds latest valid container superblock |
Format Support
| Feature | Support | Notes |
|---|---|---|
| Read-only volumes | ✓ | Full directory listing, file reading, metadata |
| Multiple volumes | First only | Reads the first non-empty volume in the container |
| Encryption | ❌ | Encrypted volumes not supported |
| Snapshots | ❌ | Snapshot browsing not supported |
| Clones | ❌ | Clone resolution not supported |
| Compression | ❌ | Compressed extents not supported |
Quick Start
Open and Browse
use ApfsVolume;
use File;
use BufReader;
let file = open?;
let mut vol = open?;
// Volume info
let info = vol.volume_info;
println!;
// 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;
let mut reader = vol.open_file?;
let mut buf = ;
let n = reader.read?;
File Metadata
let stat = vol.stat?;
println!;
println!;
println!;
Architecture
Container (NXSB)
├── Checkpoint descriptor area → latest valid superblock
├── Container OMAP → resolves volume OIDs to physical blocks
└── Volume (APSB)
├── Volume OMAP → resolves catalog OIDs to physical blocks
└── Catalog B-tree (virtual, keyed by OID then type)
├── Inodes (type 3) — file/directory metadata
├── Xattrs (type 4) — extended attributes
├── File extents (type 8) — physical data locations
└── Directory records (type 9) — name → inode mapping
Modules
| Module | Description |
|---|---|
fletcher |
Fletcher-64 checksum computation and verification |
object |
32-byte object header parsing, type constants |
superblock |
Container (NXSB) and volume (APSB) superblock parsing, checkpoint scanning |
omap |
Object Map B-tree lookup — virtual OID to physical block |
btree |
Generic APFS B-tree node parsing, search, and range scan |
catalog |
Catalog record types: inodes, directory records, file extents, path resolution |
extents |
File data reading from physical extents, ApfsForkReader |
Limitations
- Read-only — no write support
- No encryption — cannot read FileVault or per-file encrypted volumes
- No compression — transparent compression (lzvn, lzfse, zlib) not decompressed
- No snapshots — snapshot browsing not implemented
- Single volume — reads only the first volume in a multi-volume container
- No extended attributes — xattr values not exposed through the public API
Next Steps
- Pipeline integration with
dppfor DMG → APFS workflows - Encryption support (FileVault, per-file)
- Compressed extent decompression (lzvn, lzfse, zlib)
- Snapshot browsing
- Multi-volume support
- Extended attribute access
License
MIT