Add LZ4 decompression support for full lcluster layout#36
Open
katexochen wants to merge 1 commit into
Open
Conversation
Adds read support for LZ4-compressed EROFS images using the full (legacy) lcluster index layout. Compact layout, ztailpacking, fragments, big_pcluster_2, HEAD2 / LZMA / DEFLATE / Zstd remain deferred — they return clear ErrNotImplemented at read time. New internal/zerofs package owns the z_erofs read path: map-header parsing & validation, full-layout lcluster decoding, pcluster resolution (preroll + big_pcluster_1), and a partial LZ4 block decoder that handles the EROFS LZ4_0Padding variant (leading zero inputmargin + stop-at-output-cap semantics, equivalent to the kernel's LZ4_decompress_safe_partial). erofs.go gains parseComprCfgs, loadCompressedBlock, an image-level pcluster LRU, and the superblock check is relaxed: the ComprAlgs field is now correctly treated as a union (lz4_max_distance pre- COMPR_CFGS, an algorithm bitmap when COMPR_CFGS is set). Tests cover the standard TestCases run through an LZ4 converter, compressibility edge cases, multi-pcluster spanning reads, plain-vs- LZ4 cross-validation, fuzz of compressed image bytes, and a deferred-feature check asserting compact-layout images error cleanly. Assisted-by: Claude Opus 4.7 <noreply@anthropic.com> Signed-off-by: Paul Meyer <katexochen0@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is the first in a series of patches adding compression support. I tried t split this into revieweable chunks that work as stand-alone additions.
Adds read support for LZ4-compressed EROFS images using the full (legacy) lcluster index layout. Compact layout, ztailpacking, fragments, big_pcluster_2, HEAD2 / LZMA / DEFLATE / Zstd remain deferred — they return clear ErrNotImplemented at read time.
New internal/zerofs package owns the z_erofs read path: map-header parsing & validation, full-layout lcluster decoding, pcluster resolution (preroll + big_pcluster_1), and a partial LZ4 block decoder that handles the EROFS LZ4_0Padding variant (leading zero inputmargin + stop-at-output-cap semantics, equivalent to the kernel's LZ4_decompress_safe_partial).
erofs.go gains parseComprCfgs, loadCompressedBlock, an image-level pcluster LRU, and the superblock check is relaxed: the ComprAlgs field is now correctly treated as a union (lz4_max_distance pre- COMPR_CFGS, an algorithm bitmap when COMPR_CFGS is set).
Tests cover the standard TestCases run through an LZ4 converter, compressibility edge cases, multi-pcluster spanning reads, plain-vs- LZ4 cross-validation, fuzz of compressed image bytes, and a deferred-feature check asserting compact-layout images error cleanly.