Parse native TUX3 allocation trees and journal metadata - #362
Merged
Merged
Conversation
Hawkynt
force-pushed
the
feature/tux3-allocation-log-parser
branch
7 times, most recently
from
September 19, 2026 03:44
7f4a8e9 to
6cdfeab
Compare
The docs gate compares README.md and REFERENCE.md against the built assembly. Tux3BlockRun, Tux3JournalRecordType and Tux3JournalRecord raise the public type count from 852 to 855 and add three reference entries, so both generated files drifted. Rendered with the package-readme generator; no hand edits.
Hawkynt
force-pushed
the
feature/tux3-allocation-log-parser
branch
from
September 19, 2026 04:48
2bbeda0 to
ffc58c1
Compare
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
Design
TUX3 stores the allocation bitmap as special inode 1. This implementation independently follows the native on-disk structures required to find that inode: packed superblock root -> generic bnodes -> ileaf dictionary/attributes -> DATA_BTREE root -> dleaf/direct mapping -> bitmap data. Bitmap bits are interpreted little-endian within each byte, matching the native allocator.
The journal is read from the superblock
logchain/logcountreverse chain, validated block-by-block, decoded in chronological order, and split at the latestUNIFYmarker. Allocation-only records (BALLOC,BFREE,BFREE_RELOG; withBFREE_ON_UNIFYremaining allocated until unify) are applied to the bitmap. Log blocks are conservatively reserved.Structural records (
LEAF_*/BNODE_*) require the native structural replay phase before stale tree roots can be trusted. If any such record is active after the latestUNIFY,AllocationMapValidis false and layout/Wipe fall back to reserving the entire declared volume. This intentionally prefers false negatives over destructive false-free classification.Allocated bitmap runs are surfaced as
MetadataReserved, notUsed, because object ownership and logical file sizes are not yet resolved. Consequently the generic wipe path can zero only explicitFreeruns and cannot infer cluster-tip slack inside allocated TUX3 blocks.Tests
Added original NUnit fixtures that build a compact native metadata graph in memory and cover:
UNIFYmaking older structural records inactiveReferences / licensing
Consulted the upstream
OGAWAHirofumi/linux-tux3tree, especiallytux3.h,btree.c,ileaf.c,iattr.c/iattr.h,dleaf.c,filemap.c,balloc.c,log.c,replay.c, andsuper.c.The upstream tree is GPLv2. No expressive implementation code was copied or translated. The implementation is clean-room C#: it uses only factual/specification-defined field layouts, constants, record sizes, replay semantics, and independently written algorithms/tests. No new dependency is introduced.
Scope after this PR
This moves TUX3 beyond superblock-only maintenance: native free-space layout and Wipe work inside a clean/replayable volume. Full native R/W, purge, and defragmentation are still intentionally not advertised because safe mutation also requires directory/inode traversal, orphan/version handling, structural journal replay, and a transactional writer.