feat(ubifs): recover orphaned inodes into lost+found on rootless captures - #42
Merged
Merged
Conversation
…ures A partial UBIFS capture missing its root LEB has no root inode 1 and no dentry parented at root, so the tree-only walk from root yields nothing even when valid inode/dentry/data nodes for real files are present. Add an orphan pass that re-roots everything unreachable from root inode 1 under a synthetic lost+found/: named subtrees, parent-link cycles, and data-bearing lone inodes. Lone inodes require real content so a metadata-only inode can't extract as a zero-filled shell. Status is marked partial only when the root inode was absent. Surface extraction status/warnings the human view was dropping: render a finding's own manifest-node status/warning on its row, link a finding to its extraction subtree by a unique offset when the type differs (a `ubi` finding's entry is labelled `ubifs`), and route extraction warnings and hard statuses into the diagnostics table so the NOTES column stays terse. Move the errors-only banner to just above the footer.
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.
Problem
When a UBIFS capture is missing its root LEB (common in raw flash dumps: the superblock/root LEB simply isn't in the captured region), there is no root inode 1 and no dentry parented at root. moria's tree walk starts at root inode 1, so it recovers nothing from that volume even though valid inode, dentry, and data nodes for real files are present and CRC-valid. This mirrors the failure mode of
ubireader/fsck on damaged images: return nothing rather than what could be recovered.Change
Add an orphan-recovery pass that runs after the normal root walk and re-roots everything unreachable from root inode 1 under a synthetic
lost+found/:lost+found/inode_<pino>/…, full subtree with original filenames and structure.lost+found/inode_<n>. Lone inodes require real content, so a metadata-only inode whose data nodes didn't survive is not emitted as a zero-filled shell.The pass is gated (no
lost+found/when there are no orphans). Extraction status is markedpartialonly when the root inode was genuinely absent.Human-view fixes (folded in)
The recovery signal was reaching the JSON manifest but not the human view, due to two pre-existing gaps:
ubifinding (whose top extraction entry is labelledubifs) never linked and its whole volume subtree was dropped from the human view.Fixed both, and routed extraction warnings/hard statuses into the diagnostics table so the NOTES column stays terse (
→ lost+found) while the full detail lives in one scannable place. The errors-only banner moved to just above the footer.Testing
test_ubifs_orphan_recovery: a hand-built raw UBIFS (no mkfs tools) with no root inode, exercising a named subtree, a parent-link cycle, a data-bearing lone inode, the zero-shell gate,partialstatus, and that the recovery surfaces in the human-eoutput.mkfs.ubifsround-trips unchanged.