Skip to content

VFS: a write below a missing parent fails with ERROR_PATH_NOT_FOUND instead of conjuring the folder - #1259

Open
pickles976 wants to merge 1 commit into
xcl-dev:mainfrom
pickles976:vfs-write-parent-check
Open

pickles976 wants to merge 1 commit into
xcl-dev:mainfrom
pickles976:vfs-write-parent-check

Conversation

@pickles976

Copy link
Copy Markdown

What: prepare_write ran create_dir_all on the overlay parent with no merged-view check. So CreateFileW("G:\nodir\f.bin", CREATE_ALWAYS) — parent in neither layer — created nodir and succeeded where Windows fails ERROR_PATH_NOT_FOUND; and a write below a removed directory resurrected the folder via commit_write → remove_whiteout (children staying whited out). stage_write (the copy/move path) already carries exactly the guard being added here, so the two entry points currently disagree on the same path. Found by @emirduran707's static audit (their #577 comment, 11:53Z); this implements the prepare_write half of their suggested fix.

What is in it

  • prepare_write: reject with ERROR_PATH_NOT_FOUND unless the virtual parent is a folder in the merged view (is_dir, matching stage_write's check line-for-line) — before anything is created on disk;
  • 3 tests: missing parent fails and creates nothing; removed (whited-out) dir is not resurrected and keeps its whiteout; a game-folder-only parent still works (the case the create_dir_all was there for).
  • Deliberately not included: the create_dir multi-level case from the same report — vfs::tests::directories codifies multi-level creation as the contract (create_dir("saves\slot1") == Ok(())), and whether the emulated console should match CreateDirectoryW's one-level semantics is a maintainer call, not a silent test rewrite. Details in my VFS: CREATE_ALWAYS on a game directory, or a write below a game file, leaves an overlay entry that hides the original #577 reply.

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: CPU-only host (i7-4770K), no GPU use — Linux dev box cross-building x86_64-pc-windows-gnu (llvm-mingw toolchain, clang+lld, static libunwind), release test profile, rustc stable; lib tests executed under Wine 9 (wine via CARGO_TARGET_..._RUNNER):
  • cargo test -p xcl --lib vfs::tests --target x86_64-pc-windows-gnu -- --test-threads=1: 15 passed, 0 failed, 0 ignored (12 pre-existing + 3 new; no GPU tests in the filtered set). The full cargo test --workspace from Linux requires the same cross + Wine setup (lib does not link natively here — retour); CI covers the workspace.

Regression run
Requesting the test-only label: CPU-only host, no title package or Windows desktop here, so no smoke.ps1 blocks — same lane @ryosen0 used with the recent VFS PR; happy to have it smoke-partnered if a reviewer wants title evidence beyond the unit level.

Not tested

  • smoke.ps1 on a real title (see above); the vfs_hooks CreateFileW end-to-end path under Wine (the two known Wine-9 CopyFile2 blockers in that suite are unrelated to this change and still abort on base).

AI use

  • none beyond static reading of our source.

…lder

prepare_write create_dir_all'd the overlay parent with no merged-view
check, so CreateFileW CREATE_ALWAYS on G:\nodir\f.bin created 'nodir'
where Win32 fails with ERROR_PATH_NOT_FOUND, and a write below a
removed directory resurrected the folder through commit_write's
remove_whiteout. stage_write (copy/move) already had exactly this
guard, so CreateFileW and CopyFileW disagreed on the same path.

Same case as reported in xcl-dev#577 (third-party static find); the
create_dir multi-level behaviour is deliberately untouched - the
'directories' test codifies multi-level creation as the contract,
and that is a separate maintainer call (see the xcl-dev#577 comment).
@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@930e8b4 (baseline 751 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
754 passed; 0 failed; 41 ignored   (exit 0)

Three more than the baseline; a write below a missing parent failing with the right error is covered and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@pickles976

Copy link
Copy Markdown
Author

Thanks @dcastell1 — full-workspace green on native Windows (754 vs 751 baseline) is stronger unit evidence than my Wine cross-run, and the clean-patch/revert discipline is noted.\n\nTo the maintainers: the two xcl-smoke lint failures are the known Linux-contributor wall — this box has no title package and no Windows desktop, and the change is CPU-only VFS error-path logic with no GPU or title interaction. Requesting the test-only label for this PR (the lane established when #763 was reviewed): the risk surface is exactly what the 3 new unit tests + dcastell1's full-suite native run cover; a title regression beyond that would need the fix to corrupt the overlay, which the whited-out and game-only-parent tests are precisely about. Happy to add smoke blocks later if a reviewer wants them before merge.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl lib vfs: 25 passed, 0 failed.

Thanks!

@pickles976

Copy link
Copy Markdown
Author

Sequencing note for the reviewer from my side of the VFS lane: #1362 (staged whiteout preservation) and this PR are complementary halves of the same #577 third-party audit — theirs fixes failed-open resurrection, this one missing-parent conjuring. The textual conflict is one renamed function: my guard slots at the top of prepare_write_staged after their rename with zero semantic change, and the joint test set (their whiteout tests + this PR's 3) covers both halves. Whichever merges second rebases onto the other — flagging so it is a plan, not a surprise.

@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of 3460d080 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 3460d08008d2fcc8ac2af28278bc896d99c36986
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1626 (PresentX 1626)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants