VFS: preserve whiteouts when CreateFile fails on a deleted game file #1352
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1362"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by b3IKK on 2026-11-24T15:12:43Z.
open_decision_forcalledprepare_writebeforeCreateFileW/CreateFileA/CreateFile2ran, eagerly clearing any whiteout on the target path. If the underlyingCreateFile*call then failed (e.g. sharing violation, invalid flags/attributes, orERROR_ACCESS_DENIED), no overlay file was created yet the whiteout was already gone—resurrecting the deleted original game file.This adds
prepare_write_stagedandopen_decision_staged/open_decision_staged_for(following the existingstage_write/commit_writepattern fromd903a80) and hasapply_open_decisioncallcommit_writeonly afterCreateFile*returns a valid handle, while saving and restoringGetLastError()acrosscommit_write's whiteout persistence I/O so statuses likeERROR_ALREADY_EXISTSare not clobbered.What is in it
crates/xcl/src/vfs.rs: splitprepare_write_stagedout ofprepare_writeandopen_decision_staged_for/open_decision_stagedout ofopen_decision_forso callers can defercommit_writeuntil the file open succeeds.crates/xcl/src/vfs_hooks.rs: pass staged decisions fromhk_create_file_w,hk_create_file_a, andhk_create_file_2intoapply_open_decision, committing only onhandle != INVALID_HANDLE_VALUEwhile preservingGetLastError(); add unit testfailed_create_file_preserves_whiteout_and_last_error.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignored (SKIPPED GPU tests: 2no wave64—gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask,gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware)cargo test -p xcl --lib vfs: 23 passed, 0 failedRegression run
main:
PR:
Not tested
AI use
vfs.rsandvfs_hooks.rs, wrote the staged open fix and unit test, ran the test suite andscripts/smoke.ps1regression runs, and drafted this PR description.Imported from ivall/xcl. Originally posted by futurepro62 on 2026-11-24T15:17:05Z.
Full-suite run, since this PR has no test report yet. Tested exact head
b69731e(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.failed_create_file_preserves_whiteout_and_last_error.Not tested
AI use
Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T15:20:34Z.
Review from the #1259 author — your fix and mine are complementary halves of the same third-party #577 audit, and we should sequence deliberately: you close failed-open resurrection (staging no longer removes whiteouts before the open succeeds); #1259 closes missing-parent conjuring (a guard at the top of
prepare_writereturningERROR_PATH_NOT_FOUND, plus tests that a whited-out parent stays whited out and a game-only parent still stages fine). Semantic interaction is one line: my guard belongs at the top of what you rename toprepare_write_staged— happy to rebase onto whichever lands first, and your test suite plus my three cases form the joint acceptance set. Flagging it so the reviewer does not have to rediscover the overlap.Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T16:28:13Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by xpatfussy69x on 2026-11-25T11:59:22Z.
Test report for head
b69731eas pushed (not merged onto currentmain) – NVIDIA, wave32.Tested
.\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 752 passed, 0 failed, 41 ignoredfailed_create_file_preserves_whiteout_and_last_errorran and passedXCL_SAMPLE_*data set (game-data tests not run)Not tested
mainAI use
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:42:14Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:29:32Z.
merge-check claim
head:
b69731e658Imported from ivall/xcl. Originally posted by brainhay5 on 2026-11-30T23:36:55Z.
merge-check claim
head:
b69731e658Imported from ivall/xcl. Originally posted by BBareth on 2026-11-30T23:38:10Z.
merge-check
base:
d0832e614fhead:
b69731e658merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2891 passed, 0 failed, 51 ignored; 28 SKIPPED lines, as on the base; failing: none. The base alone, run earlier today on the same commit: 2890 passed, 0 failed, 51 ignored, 28 SKIPPED lines (22 no wave64, 2 no heap windows, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 cannot disable the driver cache). The new test
failed_create_file_preserves_whiteout_and_last_errorran and passed;create_always_reports_existing_game_file(adapted to the new signature) passed.review: no blocking finding; two files (+133/-27), every line read. The three CreateFile hooks now stage the overlay write (
open_decision_staged) and call the existingcommit_write(remove the whiteout, record the write) only after the redirected open returned a valid handle, saving and restoring the last error around it soERROR_ALREADY_EXISTSsurvives;open_decision/open_decision_for/prepare_writekeep their behaviour for the other callers by committing at once. Two things to know, neither blocking: (1) forOPEN_EXISTING/OPEN_ALWAYSthe original is still copied into the overlay before the open, so a failed open can leave that copy in the overlay, as before this PR (it has the original's content, so reads do not change); (2) between the successful open andcommit_writeanother thread still sees the file as deleted for a moment. Not tested here: a retail title that hits a failing create on a deleted game file.performance: none measurable: the same work as before on a successful open, plus a
GetLastError/SetLastErrorpair.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:31:11Z.
Triage (#1607) – head
b69731eNo open or merged PR makes this change. Main already stages copy/move destinations (
stage_write+commit_write), butopen_decision_forstill callsprepare_write, which removes the whiteout before CreateFile runs; this PR defers that commit until the handle is valid and keeps the last error.No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:04:30Z.
merge-check claim
head:
b69731e658Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:18:43Z.
merge-check
base:
7d86c5d2b7head:
b69731e658(unchanged since the claim)merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2897 passed, 0 failed, 51 ignored; failing: none; base alone: 2896 passed, 0 failed, 51 ignored (the new test vfs_hooks::tests::failed_create_file_preserves_whiteout_and_last_error ran and passed)
review: Read the whole diff (nothing flagged by the diff scan). The overlay write is now staged (copy into the overlay) and commit_write (whiteout removal, write record) runs only after the real CreateFile* returns a valid handle, with GetLastError preserved across it; the old prepare_write / open_decision_for keep their behaviour for other callers. The new test drives apply_open_decision with a failing and a succeeding open and checks whiteout, write count and last-error, so it tests the change and runs unconditionally. Caveat: a failed open still leaves the staged copy in the overlay (only the whiteout and the record are protected); hk_create_file_a goes through the W original, so it is covered too.
performance: none by default; one extra GetLastError / SetLastError pair per successful redirected open.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300; Claude Code, Claude Sonnet 5.5 ran the build and the suite and read the diff; Claude Opus 5.5 checked this report (the diff review is Sonnet's)
Imported from ivall/xcl. Originally posted by throny on 2026-12-01T07:22:38Z.
Merged at the checked head after a combined trial of #1362 and #3380 on
main7d86c5d2(RTX 4080 16 GB,cargo test --workspace --no-fail-fast -- --test-threads=4: 2900 passed, 0 failed, 51 ignored, 25 SKIPPED lines). Two merge checks plus ours.AI use: Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by brainhay5 on 2026-12-01T11:48:02Z.
merge-check claim withdrawn
Our automated merge-check loop claimed this PR and then stopped before posting a check — two loops were running at once and both are now shut down. No check from us is coming, so this claim is void and the head is free for someone else to take.
AI use: an agent posted this withdrawal.