VFS: DeleteFileW refuses read-only files instead of hiding them (#2945) #2982

Open
Koaio wants to merge 1 commit from upstream-pr/2982 into main
Koaio commented 2026-11-27 07:08:15 +00:00 (Migrated from github.com)

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_file and the new remove_moved_file share remove_file_entry. delete_file returns ERROR_ACCESS_DENIED for a read-only overlay file or original, with no whiteout and no change on disk. remove_moved_file skips the check.
  • crates/xcl/src/vfs_hooks.rs: the copy-and-remove fallback of move_file_vfs removes its source with remove_moved_file.
  • Test vfs::tests::delete_file_respects_readonly_attribute: a native DeleteFileW control, 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

  • <GPU + driver>, , Windows , Rust , debug
  • cargo test --workspace -- --test-threads=4: passed, failed, ignored (SKIPPED: <list, or none>)
  • Independent run by a reviewer (comment above; RX 6800M, Ryzen 9 5980HX, Windows 11 26200.9711, Rust 1.99.0, debug): cargo test --locked -j 1 -p xcl --lib vfs -- --test-threads=1: 23 passed on 5f18eff, 22 passed on main 83b0081, 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

  • A physical cross-volume move. The copy-and-remove fallback was only reached with an injected ERROR_NOT_SAME_DEVICE (reviewer's fixture).
  • A retail title that deletes or moves read-only files.
  • <GPU vendor you did not run, e.g. NVIDIA>

AI use

  • Claude Code (Opus 5.5) the code, the test and the description were written by me together with Claude; I read and checked every line of the diff. Tests and the regression run were run by me on the hardware above.
<!-- greyfinch-sync:ivall/xcl:issue:5522685744 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2982). Originally posted by [Koaio](https://github.com/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_file` and the new `remove_moved_file` share `remove_file_entry`. `delete_file` returns ERROR_ACCESS_DENIED for a read-only overlay file or original, with no whiteout and no change on disk. `remove_moved_file` skips the check. - `crates/xcl/src/vfs_hooks.rs`: the copy-and-remove fallback of `move_file_vfs` removes its source with `remove_moved_file`. - Test `vfs::tests::delete_file_respects_readonly_attribute`: a native `DeleteFileW` control, 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** - <GPU + driver>, <CPU>, Windows <build>, Rust <version>, debug - `cargo test --workspace -- --test-threads=4`: <N> passed, <N> failed, <N> ignored (SKIPPED: <list, or none>) - Independent run by a reviewer (comment above; RX 6800M, Ryzen 9 5980HX, Windows 11 26200.9711, Rust 1.99.0, debug): `cargo test --locked -j 1 -p xcl --lib vfs -- --test-threads=1`: 23 passed on 5f18eff, 22 passed on main 83b0081, 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** - A physical cross-volume move. The copy-and-remove fallback was only reached with an injected ERROR_NOT_SAME_DEVICE (reviewer's fixture). - A retail title that deletes or moves read-only files. - <GPU vendor you did not run, e.g. NVIDIA> **AI use** - Claude Code (Opus 5.5) the code, the test and the description were written by me together with Claude; I read and checked every line of the diff. Tests and the regression run were run by me on the hardware above.
luckyteagirl commented 2026-11-27 07:29:57 +00:00 (Migrated from github.com)

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=1 on clean detached worktrees:

  • PR 5f18eff14855d9bc532ca30d4b85f363a06ea9fc — 23 passed, including the new read-only deletion test.
  • Main 83b008188efbf954b846667f48d75e3fa9310a01 — 22 passed.
  • Both runs had 0 failures, 0 ignored and 0 capability skips.

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.

  • The native NTFS control returned ERROR_ACCESS_DENIED from DeleteFileW. MoveFileW then moved the same file and preserved its contents and read-only attribute.
  • On main, VFS deletion reported success and whiteouted the path for both a read-only original and a read-only overlay over an original. The PR returned ERROR_ACCESS_DENIED and preserved the visible contents without a whiteout.
  • Both revisions preserved the move behavior through move_file_vfs. A read-only original went through copy and whiteout. For a read-only overlay over an original, an injected ERROR_NOT_SAME_DEVICE from 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.

<!-- greyfinch-sync:ivall/xcl:comment:7212529560 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2982#issuecomment-7212529560). Originally posted by [luckyteagirl](https://github.com/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=1` on clean detached worktrees: - PR `5f18eff14855d9bc532ca30d4b85f363a06ea9fc` — 23 passed, including the new read-only deletion test. - Main `83b008188efbf954b846667f48d75e3fa9310a01` — 22 passed. - Both runs had 0 failures, 0 ignored and 0 capability skips. 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. - The native NTFS control returned `ERROR_ACCESS_DENIED` from `DeleteFileW`. `MoveFileW` then moved the same file and preserved its contents and read-only attribute. - On main, VFS deletion reported success and whiteouted the path for both a read-only original and a read-only overlay over an original. The PR returned `ERROR_ACCESS_DENIED` and preserved the visible contents without a whiteout. - Both revisions preserved the move behavior through `move_file_vfs`. A read-only original went through copy and whiteout. For a read-only overlay over an original, an injected `ERROR_NOT_SAME_DEVICE` from 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.
Foniass commented 2026-12-01 09:16:41 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:16:41Z.


Triage (#1607) – head 5f18eff

No other open PR fixes #2945. #2809 made a similar change and is closed. On main, Vfs::delete_file still whiteouts a read-only original, and std::fs::remove_file deletes a read-only overlay file. The change refuses both with ERROR_ACCESS_DENIED, as DeleteFileW does. Moves go through remove_moved_file, which skips the read-only check, because MoveFileW can move read-only files. The test checks both cases against native DeleteFileW. 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.

<!-- greyfinch-sync:ivall/xcl:comment:7306469721 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/2982#issuecomment-7306469721). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T09:16:41Z. --- **Triage (#1607)** – head 5f18eff No other open PR fixes #2945. #2809 made a similar change and is closed. On main, `Vfs::delete_file` still whiteouts a read-only original, and `std::fs::remove_file` deletes a read-only overlay file. The change refuses both with `ERROR_ACCESS_DENIED`, as `DeleteFileW` does. Moves go through `remove_moved_file`, which skips the read-only check, because `MoveFileW` can move read-only files. The test checks both cases against native `DeleteFileW`. 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.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2982:upstream-pr/2982'
git switch 'upstream-pr/2982'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2982'
git switch 'upstream-pr/2982'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2982'
git switch 'upstream-pr/2982'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2982'
git switch 'main'
git merge --squash 'upstream-pr/2982'
git switch 'main'
git merge --ff-only 'upstream-pr/2982'
git switch 'main'
git merge 'upstream-pr/2982'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!2982
No description provided.