feat(vfs): decode UDF PATH_COMPONENT symlinks - #14
Open
frankmanzhu wants to merge 3 commits into
Open
Conversation
The vfs adapter now classifies ICB file type 0x0c (symbolic link) as NodeKind::Symlink and implements FileSystem::read_link by decoding the ECMA-167 4/14.16.2 PATH_COMPONENT record chain with the Linux kernel's udf_pc_to_char semantics (4-byte records: type, length, __le16 version; types 1-5: root/parent/.. /./CS0 name; trailing slash trimmed). Verified against a mkudffs 2.01 image whose symlink was authored by the Linux 6.8 UDF driver (target '../README.txt'); macOS hdiutil resolves the same record identically.
- Committed udf_symlink.img (mkudffs 2.01 + Linux-driver-authored PATH_COMPONENT symlink; provenance in tests/data/README.md, seeds the fuzz corpus like the other images). - Integration test walks the committed image: Symlink classification and read_link == '../README.txt' (the Linux driver's own resolution). - Synthetic test_support image now carries a symlink File Entry (type 0x0c, inline PATH_COMPONENT data) plus its root FID; the root directory moved to its own block behind a short allocation descriptor since the inline area overflowed. New vfs tests cover classification, decode, the FID-fallback path (BROKEN_DIR_FE), and the loud error when a symlink's allocation descriptors are unreadable. - Decoder tests cover the agreed-location break, current-dir records, and the parent reset. - llvm-cov --workspace --all-features: 96.36% lines (floor 96).
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.
feat(vfs): decode UDF PATH_COMPONENT symlinks
What this does
The
vfsadapter now classifies UDF symbolic links (ICB Tag File Type 0x0c) asNodeKind::Symlinkand implementsFileSystem::read_linkby decoding the ECMA-167 4/14.16.2 PATH_COMPONENT record chain with the Linux kernel'sudf_pc_to_charsemantics (fs/udf/symlink.c + unicode.c).Why it currently fails
read_linkwas unimplemented (returned an empty target) and symlink nodes were surfaced asNodeKind::Filewith the raw 19-byte PATH_COMPONENT record as file content. A consumer that extracts files from a UDF image containing symlinks silently writes the record bytes as a regular file — wrong data with no error or warning. Verified against a real Linux-driver-authored symlink: macOS'shdiutil attachresolves the same record to../README.txt, while the unpatched adapter read it as a 19-byte file.Why it needs fixing
The
forensic-vfs::FileSystemcontract promisesNodeKind::Symlink+read_linkas first-class. Extraction tools (7-Zip, macOS, the Linux UDF driver itself) all handle UDF symlinks; the adapter was the odd one out, and the failure mode (silent junk bytes as a file) is the worst kind for a forensic/extraction consumer.Implementation notes
componentType,lengthComponentIdent,__le16 componentFileVersionNum— stable across kernel v6.6/v6.8/v6.14), types 1–5 (root/parent/.././CS0 name), the trailing-slash trim, and the type-1-with-location break (an agreed media-specific location yields an empty target — never a fabricated path).Test coverage
tests/data/udf_symlink.img(provenance + verbatim mint command intests/data/README.md): a mkudffs 2.01 volume with a Linux-driver-authored symlink; the integration test assertsNodeKind::Symlink+read_link == b"../README.txt"— the Linux driver's own resolution as ground truth. The image also seeds the fuzz corpus automatically.test_support): the in-memory image now carries a symlink File Entry (covering classification, decode, the FID-fallback path via the existingBROKEN_DIR_FE, and the loud error when a symlink's allocation descriptors are unreadable).cargo llvm-cov --workspace --all-features: 96.36% lines (the repo's CI floor is 96).Code quality
cargo clippy --workspace --all-targets --all-features: clean.cargo test --workspace --all-features: all green (67 lib tests + integration + doc).unsafe, nounwrap/expectin production code; failure paths returnVfsErrorwith layer/offset context.