Skip to content

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

Open
Koaio wants to merge 1 commit into
xcl-dev:mainfrom
Koaio:vfs/delete-readonly-file
Open

Koaio wants to merge 1 commit into
xcl-dev:mainfrom
Koaio:vfs/delete-readonly-file

Conversation

@Koaio

@Koaio Koaio commented Nov 27, 2026 •

Copy link
Copy Markdown

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.

…dev#2945)

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 xcl-dev#2945

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luckyteagirl

Copy link
Copy Markdown
Contributor

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.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 27, 2026
…ia remove_moved_file

Port upstream 5f18eff (xcl-dev#2945): Vfs::delete_file splits into
remove_file_entry(rel, ignore_readonly); delete checks readonly on
overlay AND original, move path uses remove_moved_file (skips check,
matching MoveFileW). Linux adaptation keeps clean_rel containment +
checked_overlay_path + write_lock + whiteout helper (check_readonly =
!ignore_readonly); vfs_hooks.rs move path + kernelx_linux.rs both move
retire paths switched; vfs_hooks_linux move-policy test updated.

Failing-first: new vfs::tests::delete_file_refuses_readonly_but_move_
still_retires failed pre-fix in worktree (overlay-readonly delete
returned Ok, expected ACCESS_DENIED); passes post-fix. Linux DeleteFile
entry was already correct via vfs_hooks_linux::delete_file — this closes
the Vfs::delete_file retire primitive the move paths use.

Gates: check -p xcl --tests pass; check --workspace pass; lib 821/0/1;
launcher_e2e 5 passed 2 failed — identical on clean-tip stash (pre-existing
message-string + shader-pack failures, unrelated); retail fresh-root
exit 139 HOLDS at exe+0x2237320, 20 stubs (no-regress).
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

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.

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.

VFS DeleteFileW hides a read-only original and reports success

3 participants