VFS: a delete through a handle hides the game file (#998) #1047
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1054"
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 CharlyRien on 2026-11-24T10:57:29Z.
A game file deleted through a handle came back:
SetFileInformationByHandlewas not hooked, so the delete removed only the overlay copy the handle points at and no whiteout was recorded. MSVC'sstd::filesystem::removedeletes this way. Part of #998 (the delete-by-handle case for files).What is in it
crates/xcl/src/vfs_hooks.rs: a hook onSetFileInformationByHandle. After a successfulFileDispositionInfo/FileDispositionInfoExdelete on a file inside the overlay, the whiteout is recorded through the existingcommit_overlay_removal; a disposition that takes the delete back removes it. Everything else is passed through unchanged: other information classes, handles outside the overlay, failed calls.delete_by_handle_hides_the_game_fileandset_file_info_by_handle_passes_everything_else_through.Tested
stable-x86_64-pc-windows-msvc; release; DXC 1.9.2602.17cargo test --workspace --release --no-fail-fast -- --test-threads=4on this PR's head: 729 passed, 0 failed, 41 ignored (mainat02bfd1d: 727 passed, 0 failed, 41 ignored)no wave64(gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware). With--nocapture,mainshows 3 more on this machine (no reserved cube with mips on this adapter; no D3D12 debug layer installed, twice); that run was not repeated on the PR.delete_by_handle_hides_the_game_filefails without the new logic (withset_file_info_vfsreturning the original call's result at once: 11 passed, 1 failed incargo test -p xcl --release --lib vfs_hooks, at the whiteout assertion).Regression run
main:
PR:
Not tested
dumpbin -importsshows noSetFileInformationByHandlein its exe,msvcp140.dll,XCurl.dllorlibHttpClient.GDK.dll, and itsmsvcp140.dllexports no__std_fs_*function. For files the exe importsDeleteFileW,RemoveDirectoryW,MoveFileExW,CreateFileW,CreateDirectoryW,FindFirstFileWand the CRT'sremove. A call throughGetProcAddressis not ruled out. The run'sreport.jsonhas an emptyvfssection (no redirected writes, no whiteouts). So this fixes a case found by reading the code, not one seen in a game; other titles were not checked.std::filesystem::removereaches the kernelbaseSetFileInformationByHandleexport (only the unit tests andpls_quota, which installs the hooks, cover it).FILE_FLAG_DELETE_ON_CLOSE(andFILE_DISPOSITION_FLAG_ON_CLOSE, passed through), rename by handle, skipping the content copy for aDELETE-only open.prepare_writebehaviour); not tested.vfs::tests::truncate_existing_validation_errorsfails when only thevfstests are run (cargo test -p xcl --release --lib vfs: 21 passed, 1 failed, 3 runs of 3, last error 127 where 5 is expected) and passes in the whole suite. Seen with this PR; reported by the tool as the same without it, which I did not rerun myself. Not touched here.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T11:07:16Z.
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@384f7f7(baseline 737 passed, 0 failed, 41 ignored on this box):Two more passing tests than the baseline, and the e2e that #1038 leaves red on this base passes here — the whiteout the title's delete-through-a-handle writes is in the list. Worth cross-checking with #1038's author, since both are after the same behaviour.
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.
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T13:02:28Z.
Review: COMMENTED
Review of
7ecc08fagainst its merge base02bfd1d, by reading the code; nothing was built or run here (no script of my own either; the only commands were read-onlyghandgit, including twogit merge-treetrial merges, which run no code). I found no defect in this PR on its own. The hook is narrow: only the two disposition classes are looked at, the name is taken from the handle at the time of the call, the whiteout is written only after the real call returns success, and the last error is kept on both paths. One thing has to be settled with #1038 before both are in, and one smaller note follows.CONFIRMED in the code of the two heads read together (Windows' part is from its documentation and from the run #1038's author reports, not from a run here): with #1038 merged, a
FALSEdisposition brings the game file back. This was found by the author of #1038 (gloger2003, in that PR's description); I traced it and agree. #1038 at7f93905records the whiteout when a game file is opened withFILE_FLAG_DELETE_ON_CLOSE(open_fileinvfs_hooks.rs). Here, a successfulFileDispositionInfo { DeleteFile: FALSE }(orFileDispositionInfoExwithout the delete flag) on a handle to an overlay copy callscommit_write, which removes the whiteout (crates/xcl/src/vfs_hooks.rs:612-614,crates/xcl/src/vfs.rs:497-500). Windows documents thatFALSEhas no effect on a handle opened withFILE_FLAG_DELETE_ON_CLOSE: the call succeeds and the copy is still deleted at close. Scenario: openG:\data\xwith delete-on-close, callSetFileInformationByHandle(FileDispositionInfo, FALSE), close: the copy is gone, the whiteout is gone, the original is visible again. On this PR alone nothing is lost (there is no whiteout to remove, and delete-on-close is listed under Not tested). Otherwise the two PRs agree: both go throughcommit_overlay_removal,add_whiteoutis a set insert (vfs.rs:390-395), so a file that gets both a delete-on-close open and an explicit delete is recorded once; and the two heads merge as text without conflicts (git merge-tree).CONFIRMED (minor, test coverage): the "only after success" branch is not tested for a handle that is inside the overlay. The failed call in the test uses
INVALID_HANDLE_VALUE(vfs_hooks.rs:1888-1890), for whichoverlay_file_relis alreadyNone, so the test would pass even if the whiteout were written before the call. A read-only game file gives the real case: its overlay copy is read-only, the disposition fails with access denied, and no whiteout may appear. Also untested:FileDispositionInfoExwith no delete flag, andFILE_DISPOSITION_FLAG_ON_CLOSEbeing passed through (vfs_hooks.rs:595-598). TheFileDispositionInfoExcase accepts either result (vfs_hooks.rs:1849-1856), which is honest for file systems without the class.Checked without a finding: the class numbers and flag values (4, 21, 0x1, 0x8); a handle outside the overlay, a directory, and a path that only shares the overlay's prefix all return
None(vfs_hooks.rs:566,:582-586); a path-based rename before the delete is handled because the name is read from the handle at delete time (:604); XCL's ownstd::fs::remove_fileinsidedelete_fileruns under the hook guard and is passed through (:624), soDeleteFileWis not handled twice; an overlay file with no game file behind it gets no whiteout (vfs.rs:504). Merged47efa2e(non-empty directory removal) does not overlap: it changesremove_dironly, this PR passes directories through, and the head merges intomainat47efa2ewithout conflicts (git merge-tree). A directory deleted through a handle still reports success and stays visible, as the description says, which now differs fromRemoveDirectoryWonmainreturning "not empty".Against CONTRIBUTING: Tested, Regression run (both blocks, the PR's names this head), Not tested and AI use are all there. From the two blocks, by arithmetic and not measured here: frames 1625 / 1629 = 99.8 %, peak commit 14607 / 14484 = 100.8 %. The PR adds two unit tests and no e2e case.
Verdict: fine to merge on its own from reading; decide with #1038 which of the two changes the
FALSEbranch (finding 1) before the second one goes in, and a test of a failing delete on an overlay handle (finding 2) would be a cheap addition.Review by Claude Code (written by Claude Fable 5.2, checked with Claude Opus 5.5); each point checked by a person before posting.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:04:47Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
upstream-sync referenced this pull request2026-11-25 10:09:30 +00:00
Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T07:41:07Z.
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.Pull request closed