VFS: DeleteFileW refuses read-only files instead of hiding them (#2945) #2982
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2982"
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 Koaio on 2026-11-27T07:08:15Z.
Windows DeleteFileW fails with ERROR_ACCESS_DENIED on a file that has FILE_ATTRIBUTE_READONLY. The VFS returned success instead: for a game original it added a whiteout without checking the attribute, and for an overlay file std::fs::remove_file deletes read-only files on Windows.
delete_file now checks the attribute on both the overlay and the original. The cross-volume move path removes its source through remove_moved_file, which skips the check, because MoveFileW moves read-only files.
Fixes #2945
What is in it
crates/xcl/src/vfs.rs:delete_fileand the newremove_moved_fileshareremove_file_entry.delete_filereturns ERROR_ACCESS_DENIED for a read-only overlay file or original, with no whiteout and no change on disk.remove_moved_fileskips the check.crates/xcl/src/vfs_hooks.rs: the copy-and-remove fallback ofmove_file_vfsremoves its source withremove_moved_file.vfs::tests::delete_file_respects_readonly_attribute: a nativeDeleteFileWcontrol, a read-only original and a read-only overlay file refused and kept, a move that still removes a read-only source, and a writable file that is still deleted.Tested
cargo test --workspace -- --test-threads=4: passed, failed, ignored (SKIPPED: <list, or none>)cargo test --locked -j 1 -p xcl --lib vfs -- --test-threads=1: 23 passed on5f18eff, 22 passed on main83b0081, 0 failed, 0 ignored. Their temporary fixture showed both read-only deletions report success and whiteout on main, and return ERROR_ACCESS_DENIED on this PR, with moves unchanged.Regression run
main:
<xcl-smoke block from a commit of main, pasted as printed>
PR:
<xcl-smoke block from
5f18eff, pasted as printed>Not tested
AI use
Imported from ivall/xcl. Originally posted by luckyteagirl on 2026-11-27T07:29:57Z.
Independent Windows VFS test
Windows 11 25H2 (26200.9711), NTFS, Ryzen 9 5980HX, Radeon RX 6800M (driver 30.0.13002.13003), Rust 1.99.0 x64 MSVC, debug test profile.
Tested
cargo test --locked -j 1 -p xcl --lib vfs -- --test-threads=1on clean detached worktrees:5f18eff14855d9bc532ca30d4b85f363a06ea9fc— 23 passed, including the new read-only deletion test.83b008188efbf954b846667f48d75e3fa9310a01— 22 passed.I also ran the same temporary test-only fixture against both revisions with
cargo test --locked -j 1 -p xcl --lib report_2982 -- --test-threads=1. The fixture left production code unchanged. The PR passed all 5 cases. Main passed 3 and failed both read-only deletion assertions. Both runs had 0 ignored and 0 capability skips.ERROR_ACCESS_DENIEDfromDeleteFileW.MoveFileWthen moved the same file and preserved its contents and read-only attribute.ERROR_ACCESS_DENIEDand preserved the visible contents without a whiteout.move_file_vfs. A read-only original went through copy and whiteout. For a read-only overlay over an original, an injectedERROR_NOT_SAME_DEVICEfrom the host rename triggered the copy-and-remove fallback. The overlay source was removed, its backing original stayed intact and hidden, and the destination retained the overlay bytes and read-only attribute.Not tested
Physical cross-volume move, retail-title smoke, or GPU/full workspace suite. The supplementary fixture called the move hook helper directly.
AI use
OpenAI Codex (GPT-6.2 Sol) wrote and ran the temporary diagnostic and drafted this report.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:16:41Z.
Triage (#1607) – head
5f18effNo other open PR fixes #2945. #2809 made a similar change and is closed. On main,
Vfs::delete_filestill whiteouts a read-only original, andstd::fs::remove_filedeletes a read-only overlay file. The change refuses both withERROR_ACCESS_DENIED, asDeleteFileWdoes. Moves go throughremove_moved_file, which skips the read-only check, becauseMoveFileWcan move read-only files. The test checks both cases against nativeDeleteFileW. No problems found in the diff. The failing check is the PR description check.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.