Skip to content

VFS: keep game files hidden after delete-on-close - #1038

Open
gloger2003 wants to merge 1 commit into
xcl-dev:mainfrom
gloger2003:fix/vfs-delete-on-close
Open

gloger2003 wants to merge 1 commit into
xcl-dev:mainfrom
gloger2003:fix/vfs-delete-on-close

Conversation

@gloger2003

@gloger2003 gloger2003 commented Nov 24, 2026 •

Copy link
Copy Markdown

Part of #998. Opening a mounted game file with FILE_FLAG_DELETE_ON_CLOSE used to remove the overlay copy and expose the original again.

What is in it

  • Record a whiteout after a successful delete-on-close open of an overlay file that covers an original game file. Keep the whiteout when a second writable handle reopens the existing overlay file.
  • Exercise both handles in the in-tree test title and verify the original game directory stays byte-identical.

Tested

  • Windows 11 build 26300.9974, AMD Radeon RX 7800 XT (32.0.32029.2010), Ryzen 7 5700X, Rust 1.100.0 MSVC, Windows SDK DXC 1.9.2602.17.

  • cargo build --locked --workspace and cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output on the source in 7f93905: 727 passed, 0 failed, 41 ignored, no explicit GPU capability skips.

  • The new test reproduced the original resurfacing, including after a second writable open. The release build with the fix completed the in-tree title with zero failures.

  • Local merge of this exact head into main 47efa2e (tree bbccc1d): rebuilt the workspace, then ran all tests on the RX 7800 XT. 741 passed, 0 failed, 41 ignored, no explicit GPU capability skips. The delete-on-close e2e test and the previously failing truncate_existing_validation_errors test both passed.

  • Also checked a local combination with VFS: a delete through a handle hides the game file (#998) #1054 at 7ecc08f. In that combination, opening with FILE_FLAG_DELETE_ON_CLOSE, calling FileDispositionInfo(FALSE), then closing made the original visible again. Windows still deletes the overlay copy, but the explicit-disposition hook clears the whiteout. This is an interaction between the two PRs.

Regression run
Independent runs by Curry-976 on a GeForce RTX 4050 Laptop GPU. The contributor reports 727 passed, 0 failed, 41 ignored in the workspace suite, with two wave64 capability skips. The smoke runs were back to back.

main:

xcl-smoke v1
commit: 67a3735177f42cf8e5c886e67a974da7f87541b3
gpu: NVIDIA GeForce RTX 4050 Laptop GPU
title: mon jeu
seconds: 60
exit: 0x0
frames shown: 393 (PresentX 393)
presents per 2 s (last 3): 18 18 17
device removals: 0
crashes: 0
peak commit: 15279 MB

PR:

xcl-smoke v1
commit: 7f939053fe3dc83d17a337ece7f7731960cd279a
gpu: NVIDIA GeForce RTX 4050 Laptop GPU
title: mon jeu
seconds: 60
exit: 0x0
frames shown: 409 (PresentX 409)
presents per 2 s (last 3): 18 17 19
device removals: 0
crashes: 0
peak commit: 15277 MB

Not tested

  • Locally, Minecraft Preview 1.18.3064.0 lost the D3D12 device during startup on the RX 7800 XT with both the main baseline and this PR. The independent NVIDIA runs above are separate. Tests that require XCL_SAMPLE_* files.
  • This change covers FILE_FLAG_DELETE_ON_CLOSE for files. Deletion or renaming via SetFileInformationByHandle remains separate.

AI use

  • OpenAI Codex (GPT-6 family, exact model variant unavailable) implemented the change, added the regression test, ran the checks, and drafted this description.

An open with FILE_FLAG_DELETE_ON_CLOSE removes only the overlay file on close. Record a whiteout after the native open succeeds and retain it when another handle opens the existing overlay entry.

Exercise two handles in the test title and check that the original game tree stays byte-identical. The Windows workspace suite passed on an RX 7800 XT.
@dcastell1

Copy link
Copy Markdown

The new e2e expectation in this PR fails on the current base:

cargo test --workspace -- --test-threads=4
test result: FAILED. 712 passed; 1 failed; 25 ignored   (exit 101)

thread 'test_title_runs_and_game_folder_is_untouched' panicked at crates\xcl\tests\e2e.rs:159:5:
whiteouts: data\delete_me.txt

The title itself finishes clean (xcl_testtitle: done, failures: 0, Game exited with code 0x0 (0), report.json exit_code = 0), so this is the file state, not the run. The whiteout file at data\XCL.TestTitle\overlay\.xcl_whiteouts is 19 bytes:

data\delete_me.txt\n

i.e. the delete_me.txt entry is there and the new one the test asks for two lines later — data\delete_on_close.txt — is not, which is the second assert! at that spot (e2e.rs:159, right after the delete_me.txt line). So the close-with-delete path is not reaching the whiteout list on this run, which is exactly what the PR is for.

Environment: Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, clean main@67a3735 (735 passed, 0 failed, 41 ignored) with this PR at 7f939053 applied with patch -p1 (clean, no fuzz). Tree restored afterwards; no game data.

AI-assisted (opencode): applied the patch to a built tree, ran the suite, inspected the overlay's whiteout file, reverted it.

@Curry-976

Copy link
Copy Markdown

Test report for this PR's head 7f939053fe3dc83d17a337ece7f7731960cd279a (checked out with gh pr checkout 1038, no local changes), with the two smoke blocks the description is waiting for.

Tested

  • NVIDIA GeForce RTX 4050 Laptop GPU (driver 32.0.16.1742, 32-lane waves), Intel Core i5-12450HX, Windows 11 26300, Rust 1.100.0 stable-x86_64-pc-windows-msvc.
  • cargo build --workspace && cargo test --workspace -- --test-threads=4 (debug): 727 passed, 0 failed, 41 ignored. SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64). test_title_runs_and_game_folder_is_untouched, with the new delete-on-close check, passes.
  • scripts/smoke.ps1 -Game <retail title folder> (60 s, cargo build --release -p xcl), the two runs back to back:

main:

xcl-smoke v1
commit: 67a3735177f42cf8e5c886e67a974da7f87541b3
gpu: NVIDIA GeForce RTX 4050 Laptop GPU
title: mon jeu
seconds: 60
exit: 0x0
frames shown: 393 (PresentX 393)
presents per 2 s (last 3): 18 18 17
device removals: 0
crashes: 0
peak commit: 15279 MB

PR:

xcl-smoke v1
commit: 7f939053fe3dc83d17a337ece7f7731960cd279a
gpu: NVIDIA GeForce RTX 4050 Laptop GPU
title: mon jeu
seconds: 60
exit: 0x0
frames shown: 409 (PresentX 409)
presents per 2 s (last 3): 18 17 19
device removals: 0
crashes: 0
peak commit: 15277 MB

This laptop's frame rate drops from run to run as it heats up (an earlier main run on the same commit showed 554 frames), so the two blocks above are the pair taken back to back. The title was not checked for delete-on-close opens: the runs are a regression check only.

Not tested

  • AMD GPUs, a release build of the test suite, directories opened with FILE_FLAG_DELETE_ON_CLOSE.

AI use

  • Claude Code (Claude Opus 5.5) ran the commands above on this machine and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (clean merge).

Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.

AI use: test runs by Devin (Cognition, SWE-2); no code changes.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (7f93905)

Hardware / environment

  • Windows x64, OS build 10.0.26200.0. AMD CPU reported as family 23, model 113, stepping 0, with 12 logical processors.
  • Test profile with debug info and incremental compilation disabled. rustc 1.100.0 (0ef1bc386 2026-11-09). dxc --version reported 1.9.2609.5 (01b62ad47).
  • CPU-only execution outside Invoke-ArcTest.ps1, with zero Arc GPU mutex hold. The focused commands used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1.

Commands and results

  • cargo test --workspace --no-run exited 0 at 7f939053fe3dc83d17a337ece7f7731960cd279a.
  • cargo test -p xcl --lib vfs -- --nocapture exited 101. The log recorded 19 passed, 1 failed, 0 ignored, and 0 SKIPPED lines. The filter selected the vfs and vfs_hooks library tests.
  • cargo test -p xcl --lib vfs::tests::truncate_existing_validation_errors -- --nocapture exited 101 on both the PR head and its parent e74dda2d4b5c28a81cfa971d14bc417a6be966aa. Each isolated run recorded 0 passed, 1 failed, 0 ignored, and 0 skips.

Observed behavior

  • Existing CPU checks passed for overlay copy-on-write, whiteout persistence across VFS reinitialization, and hiding original children after directory recreation.
  • The same native error-code assertion failed on both commits. It read Win32 error 127 (ERROR_PROC_NOT_FOUND) where it expected 5 (ERROR_ACCESS_DENIED).

Not tested

The full GPU workspace suite and game smoke runs were omitted. The PR adds its two-handle delete-on-close regression check inside the D3D12-dependent test title. The workspace build compiled that check, and the CPU VFS filter left it unexecuted.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr1038-focused.log and published.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 25, 2026
…stream xcl-dev#1038)

Only a new overlay entry may clear a whiteout: prepare_write_staged
returns is_new threading through OpenCommit, and reopening an existing
entry keeps the delete-on-close whiteout (was: commit_write_unlocked
cleared it unconditionally, resurrecting the original after close).
Successful opens with FILE_FLAG_DELETE_ON_CLOSE record the whiteout at
open; the last close deletes the overlay copy (handle->rel tracking in
kernelx_linux, last-close semantics).

Also fixes a self-deadlock the port introduced: a map-guard temporary
in an if-let scrutinee lives through the body and deadlocks on the
last-close re-lock of the same map (std mutexes are not reentrant);
bind before the if-let.

Gates: check --tests + --workspace 0 errors; lib 622/0/1;
title e2e 12 GPU FAILs = baseline, 0 non-GPU; retail frontier holds
(SIGSEGV exe+0x2237320, exit 139). Title e2e delete-on-close coverage
needs a Windows cross-build (link.exe absent here) — not included.
rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…upstream xcl-dev#1038)

Reference-only on Linux (vfs_hooks.rs is cfg(windows)): apply_open_decision
takes Option<OpenCommit> and commits via commit_open(rel, is_new) so only a
new overlay entry clears a whiteout; new open_file wrapper stages via
open_decision_staged_for (keeps xcl-dev#1362 fail-before-commit + xcl-dev#1433 CreateFile2
flags validation a verbatim open_decision_for port would regress) and records
the whiteout via commit_overlay_removal on successful DELETE_ON_CLOSE open of
a game-original file. README 2-line hunk verbatim.

Title/e2e delete-on-close hunks NOT ported: title is cfg(windows) using
std::os::windows APIs (link.exe absent per PROMPT.md 0.9); the prebuilt PE is
stale so the e2e whiteout assert would newly FAIL. Linux behavior for the same
shape is pinned by vfs.rs reopening-keeps-whiteout + vfs_hooks_linux +
kernelx_linux delete-on-close tests.
@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…dev#1054)

Windows vfs_hooks.rs hunks reference-only (cfg(windows), never compiled on
Linux): overlay_file_rel + set_file_info_vfs + hk_set_file_info_by_handle
handling classes 4 (FILE_DISPOSITION_INFO, byte != 0) and 21
(FILE_DISPOSITION_INFO_EX, DELETE without ON_CLOSE), hook-table row, both
tests. Byte-identical to pr1054head except the tests' open_for_delete helper,
which passes the staged tuple to this tree's reconciled (xcl-dev#1038)
apply_open_decision(vfs, staged, ...) signature, as all hk_create_file call
sites do (upstream's 4-arg form predates the xcl-dev#1038 reconcile).

Linux twin in hle/kernelx_linux.rs: SetFileInformationByHandle resolves the
game rel BEFORE the mark via /proc/self/fd + overlay-root prefix (skip dirs
via file metadata; read-only original-pointing handles resolve via the game
root so the game folder is never deleted directly; host files resolve to no
rel). A successful disposition-delete records the whiteout at set time and
removes the overlay copy when the marking handle closes (Windows deletes at
close, which also keeps a taken-back delete reversible); a taken-back delete
records a write. Last error is preserved across the bookkeeping and a
successful call leaves the caller's last error alone. Marks finalise
best-effort in close_file_handle (bind-before-use, same non-reentrant-mutex
rule as delete_on_close). Export-table row added for GetProcAddress probes.

Failing-first: new tests fail pre-fix (E0425, no such function); grafted onto
pre-fix HEAD in an isolated worktree with a neutered always-fail stub both
fail at runtime (0 passed / 1 failed each), green with the fix.

Gates: cargo check -p xcl --tests + --workspace 0 errors; lib 624/0/1
threads=4 (was 622, +2, zero regressions); fresh-root title ExitProcess(0xc),
12 unique FAILs all D3D12.X GPU-only, 0 non-GPU (e2e wrapper FAILs by design);
retail SIGSEGV game_scarlett_master.exe+0x2237320 fault 0x0 exit 139,
called_stubs 20, xgr exactly 3 apis — frontier HOLDS, M1-RE TERMINAL.
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.

5 participants