VFS: deleting a game file through a handle only deletes an overlay copy, and the original comes back #998
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl#998
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@Conrage on GitHub · 2026-11-24 10:07 UTC · original
Deleting a game file by handle doesn't go through the
DeleteFileWhook, so no whiteout is added. Two common ways to do that:std::filesystem::removein the MSVC STL:CreateFile2(DELETE | FILE_READ_ATTRIBUTES | FILE_WRITE_ATTRIBUTES, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT)thenSetFileInformationByHandle(FileDispositionInfoEx)CreateFileW(..., FILE_FLAG_DELETE_ON_CLOSE)for temp or lock filesWhat happens under XCL:
DELETEis inWRITE_ACCESSandFILE_FLAG_DELETE_ON_CLOSEcounts as a write, soopen_decision_fortreats the open as a write. WithOPEN_EXISTINGit callsprepare_write(rel, keep = true), which copies the whole original into the overlay:github.com/ivall/xcl@9aec53d/crates/xcl/src/vfs.rs (L530-L534)github.com/ivall/xcl@9aec53d/crates/xcl/src/vfs.rs (L584-L592)SetFileInformationByHandle/NtSetInformationFile, and nothing adds a whiteout on close, so the original is visible again.Result: the delete reports success, but the next
GetFileAttributesW/CreateFileW/FindFirstFileWstill sees the original. The title can also wait on a full copy of a large file it only wanted to delete. Folders behave the same way:BACKUP_SEMANTICScreates an empty overlay folder, which is then deleted, and the game folder stays visible.Related: a rename by handle (
SetFileInformationByHandle(FileRenameInfo)) also bypasses theMoveFileExWhook. It renames the overlay copy and leaves the original at its old name, so the file ends up at both names.Expected: a delete by handle of a game path leaves the file hidden, like
DeleteFileWdoes (whiteout plus removal of any overlay copy), without copying the original first.Suggested fix: hook
SetFileInformationByHandle(FileDispositionInfo/Ex, FileRenameInfo/Ex) for handles that came from a game path, and add the whiteout on delete-on-close. Opens whose only "write" access isDELETEcould also skip the content copy.Not tested: found by reading the code and the MSVC STL
filesystem.cpp; not run (no Windows machine).AI use: found, checked and written up by Claude Code (Claude Opus 5.5) at my request.
@CharlyRien on GitHub · 2026-11-24 10:34 UTC · original
I'm taking the delete-by-handle part: a hook on
SetFileInformationByHandlethat, forFileDispositionInfo/FileDispositionInfoExon a handle to the overlay copy of a game file, adds the whiteout once the delete succeeds (through the existingcommit_overlay_removal). With a unit test that fails onmain.Not in this PR:
FILE_FLAG_DELETE_ON_CLOSE, rename by handle, and skipping the content copy for aDELETE-only open. Each can be its own PR.AI use: Claude Code with Claude Fable 5.2.
@vladbondarenko97 on GitHub · 2026-11-24 14:01 UTC · original
I'm taking the rename-by-handle part:
SetFileInformationByHandle(FileRenameInfo / FileRenameInfoEx)on a handle to a game path is routed through the same overlay move as theMoveFileExWhook, so the original is whited out and the file ends up only at the new name. It will be stacked on #1054 (it reuses that hook), with a unit test that fails onmain. Retail regression runs on an RTX 3080 Ti.Not in it: delete-on-close (#1038) and the copy-skip for
DELETE-only opens.AI use: Claude Code (Claude Opus 5.5 plans and reviews, Claude Sonnet 5.5 implements).