Repository navigation
reiserfs: extract 3.5/3.6 volumes (closes #63) - #66
Merged
Merged
Conversation
moria identified ReiserFS (issue #24) but had no extractor, so -e wrote nothing. Add src/extract/reiserfs.{cpp,hpp} and register it in extractor_for(). The extractor walks the S+ tree from the superblock's root block, collects every leaf item, and rebuilds the tree under a SafeRoot: regular files (direct tails plus indirect block lists, holes honored), directories, and symlinks. Item key format (v1 "old" / v2 "new") is read per item from ih_version, so a 3.6 image that mixes a v2 stat-data item with a v1 directory item in one object is handled. Tree traversal follows child pointers only and never interprets an internal-node key, so the key-format ambiguity only arises at leaf items where ih_version resolves it. The partition base is recovered for both the 64 KiB (3.6) and 8 KiB (3.5) superblock placements. All reads go through the bounds-checked Reader, so a truncated or corrupt image yields a partial result rather than a crash, and a declared file size larger than the image is clamped to avoid honoring a crafted size with a giant allocation. Tests (tests/test_reiserfs_extract.py): synthetic 3.6 (two-level tree, v2 stat-data plus v1 directory items, indirect items, a tail, a leading hole, a symlink, a nested dir) and 3.5 (single leaf, all-v1, 8 KiB superblock) images round-trip byte-for-byte; a real empty mkreiserfs image is identified and extracted (self-skips without reiserfsprogs); mangled superblock and tree inputs never crash. The hand-built layouts are modeled on real mkreiserfs output, verified with debugreiserfs. Adds fuzz/fuzz_reiserfs.cpp over the parse-only tree/item/directory/content walk.
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.
Summary
Adds read-only extraction for ReiserFS (3.5 / 3.6). Identification landed with the legacy-block-filesystem batch (#24); until now
-eon a ReiserFS image printed the summary table and wrote nothing, becauseextractor_for()had noreiserfscase. Closes #63.What it does
src/extract/reiserfs.{cpp,hpp}, registered inextractor_for():ih_version).SafeRoot: regular files (direct tails plus indirect block lists, with holes honored), directories, and symlinks. Objects are grouped by(dir_id, objectid); each child's stat-data gives its mode, and files are reconstructed from their direct/indirect items in key order.Per-item key handling matters in practice: a real 3.6 image mixes a v2 stat-data item with a v1 directory item in the same object, which this handles.
Safety
Reader; a truncated or corrupt image yields apartialresult, never an out-of-bounds read.mount/debugreiserfs).Tests
tests/test_reiserfs_extract.py(wired intorun.shand ctest):mkreiserfsoutput verified withdebugreiserfs.mkreiserfsbuilds an empty filesystem (no mount needed) and moria must identify and extract it cleanly. Self-skips ifreiserfsprogsis absent. This checks the parser against genuine on-disk bytes.A populated real round-trip is not possible unprivileged:
mkreiserfshas no populate-from-directory mode, and the kernel driver was removed in 6.13, so neither a loop mount nor a userspace populate is available. The synthetic layer (modeled on verified real bytes) plus the real empty-image check cover every code path, and all format constants come from the kernelfs/reiserfs/reiserfs.hheader.fuzz/fuzz_reiserfs.cppfuzzes the parse-only tree/item/directory/content walk (a fixed valid superblock, fuzzer-controlled tree region, both placements), plus the scan pipeline on the raw bytes.Docs
ReiserFS added to the extractable-filesystem lists in
README.mdandmoria.1.