Skip to content

Decode LZFSE; read LZFSE-compressed files on HFS+ and APFS - #172

Merged
switch-nz merged 1 commit into
mainfrom
claude/lzfse
Oct 1, 2026
Merged

switch-nz merged 1 commit into
mainfrom
claude/lzfse

Conversation

@switch-nz

Copy link
Copy Markdown
Owner

Part of #47 and #50: first of three PRs agreed for #47 (LZFSE, then DMG, then AFF4). #47 and #50 stay open.

What changes for examiners

  • Files that macOS compresses with LZFSE (decmpfs types 11 and 12) on HFS+ and APFS are now decompressed like zlib and LZVN ones, instead of being listed with a note and no content.
  • Still listed without content: files stored raw (types 9 and 10).
  • engine/lzfse.py is a pure-Python decoder for raw, LZVN, v1 and v2 LZFSE blocks. It is also what DMG's ULFO chunks will use in the next PR.

Verification

  • Decoder checked against Apple's reference encoder (liblzfse) on empty, tiny, text, zeros, random and large inputs; small encoder-written streams (v2, LZVN and raw blocks, and all three in one stream) are embedded in tests/lzfse_vectors.py so CI needs no dependency. The reference decoder source was used to write the layouts and FSE tables.
  • v1 (bvx1) blocks, which this encoder no longer writes, are tested by rewriting a v2 header in v1 layout. That is a self-consistency check, not an independent one.
  • Hardening: output cap, truncation always refused, damage raises only LzfseError; fuzz target added (3000 cases, no findings).
  • HFS+ and APFS volume tests now cover LZFSE in the attribute and in the resource fork; raw (type 9) remains the "listed, not faked" case.
  • Tree cache version 3 → 4 so a cached 0.8.0 listing shows these files' sizes.
  • Full suite 1294 tests OK (14 skipped), smoke passes.
  • Synthetic volumes only; no real macOS volume with LZFSE-compressed files was available.

🤖 Generated with Claude Code

https://claude.ai/code/session_017DPjyZZHvaivtvJ3N4hZhz


Generated by Claude Code

Part of #47 and #50. A pure-Python LZFSE decoder (raw, LZVN, v1 and v2
blocks) checked against Apple's reference encoder, used for decmpfs types
11 and 12. The tree cache version is raised so cached listings show the
size of these files.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017DPjyZZHvaivtvJ3N4hZhz
@switch-nz
switch-nz merged commit fcfb0e3 into main Oct 1, 2026
32 checks passed
@switch-nz
switch-nz deleted the claude/lzfse branch October 1, 2026 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants