Skip to content

VFS: honor read-only attributes in DeleteFileW - #2809

Closed
CryingLaughing wants to merge 1 commit into
xcl-dev:mainfrom
CryingLaughing:fix/vfs-readonly-delete
Closed

CryingLaughing wants to merge 1 commit into
xcl-dev:mainfrom
CryingLaughing:fix/vfs-readonly-delete

Conversation

@CryingLaughing

@CryingLaughing CryingLaughing commented Nov 26, 2026 •

Copy link
Copy Markdown

DeleteFileW on a virtual game path could report success for a read-only file. Reject deletion of a read-only original with ERROR_ACCESS_DENIED and use native deletion semantics for an overlay copy. A rejected deletion leaves the file visible and preserves its contents. Related delete-by-handle PR #1054

What is in it

  • In crates/xcl/src/vfs.rs, check the original’s read-only attribute before recording a deletion marker. Preserve the move behavior for a read-only original.
  • In crates/xcl/src/vfs_hooks.rs, use native DeleteFileW for overlay deletion, with an extended path when needed. The crates/xcl/tests/vfs_readonly_delete.rs integration test exercises the installed hooks in a child process with synthetic files.

Tested

  • Revision 80cf435643189a0ea2ec31f4e4e5642539b47815 on b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7. Its tree 8a2dc2fcc438ce0c4a94554b5d5ae5d80fd4b8a5 matches the tested overlay. Windows 11 25H2 build 26200.9974, Intel Core i5-13600K, RTX 4080 driver 621.01, Rust 1.100.0 x64 MSVC, and DXC 1.8.2502.11. Debug build and test profiles.
  • The focused delete_file_respects_readonly_attribute test in vfs_readonly_delete failed on the parent (0 passed, 1 failed) because virtual DeleteFileW reported success for readonly-original.txt. The fixed tree passed 1/1. Both readonly-original.txt and readonly-overlay.txt returned ERROR_ACCESS_DENIED and kept their contents. Writable deletion, a path longer than MAX_PATH, a read-only move, native-path behavior, and deletion markers checked after reopening also passed.
  • cargo build --workspace --locked -j 4 passed. cargo test --workspace --locked -j 4 -- --test-threads=4 --show-output reported 1,436 passed, 0 failed, 47 ignored, with 29 explicit skip messages in the pass count across 38 harnesses.

Regression run

Independent retail smoke by Anon64 compared release builds of main and this exact head on an RTX 3060 12 GB (driver 581.80), Core i9-14900KF, and Windows 11 build 26200. The 60-second runs used the same title. The head retained 99.5% of the baseline frames and used 103.1% of its peak commit, with zero crashes or device removals. The run did not establish whether the title reached the changed code.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1461 (PresentX 1462)
presents per 2 s (last 3): 10 1 1
device removals: 0
crashes: 0
peak commit: 23855 MB

PR:

xcl-smoke v1
commit: 80cf435643189a0ea2ec31f4e4e5642539b47815
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1454 (PresentX 1455)
presents per 2 s (last 3): 13 0 1
device removals: 0
crashes: 0
peak commit: 24590 MB

Not tested

  • Retail game file deletion. The integration test used synthetic local files.

@CryingLaughing
CryingLaughing marked this pull request as ready for review November 26, 2026 14:17
@Anon64

Anon64 commented Nov 26, 2026

Copy link
Copy Markdown

Regression run of 80cf435 on a newer retail title: no device removal, no crash, frames and commit within the limits.

Setup: RTX 3060 12 GB (NVIDIA 581.80), i9-14900KF, Windows 11 26200, release builds of main b49be18 (this PR's base) and of this PR's exact head, scripts/smoke.ps1 -Game <title> for 60 s with XCL_NETWORK=0 and A pressed every 4 s from 20 s. Main ran before and after a batch of 11 PRs and peaked at 23,855 and 23,844 MB, so the baseline held steady over the batch.

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1461 (PresentX 1462)
presents per 2 s (last 3): 10 1 1
device removals: 0
crashes: 0
peak commit: 23855 MB

this PR:

xcl-smoke v1
commit: 80cf435643189a0ea2ec31f4e4e5642539b47815
gpu: NVIDIA GeForce RTX 3060
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1454 (PresentX 1455)
presents per 2 s (last 3): 13 0 1
device removals: 0
crashes: 0
peak commit: 24590 MB

99 % of main's frames, 103 % of its peak commit. One run each.

Not tested: the suite on this head; whether the title reaches the code this PR changes in its first 60 s; AMD.

AI use: Claude Code (Claude Opus 5.5) ran these runs on this machine and wrote this report.

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…t, readonly-aware delete)

Port upstream xcl-dev#2708 (live head 15393dc): the MAXIMUM_ALLOWED bit itself
landed earlier via xcl-dev#2694 (91e37a8); this takes the remaining regression
test a_maximum_allowed_open_takes_the_write_path verbatim into vfs.rs,
pinning the write-path overlay copy plus the read-only-bit read path.

Port upstream xcl-dev#2809 (live head 80cf435): whiteout_original_file(rel,
check_readonly) verbatim into shared vfs.rs (Linux containment via
checked_original_path), with delete_file delegating the hide-original
half with check_readonly=false (move-retire keeps its policy, as
upstream). The Windows-native hook half (MAX_PATH/extended-prefix
juggling, native DeleteFileW sharing checks) stays out; the Linux twin
vfs_hooks_linux::delete_file carries the readonly-check shape
(symlink_metadata dir/readonly gates, overlay remove + commit, else
whiteout_original_file(rel, true)), and kernelx_linux DeleteFileA/W
route Game deletes through it. Close-time/best-effort removals and
move_impl retire keep Vfs::delete_file directly (no readonly gate).

Tests: vfs::tests +1, vfs_hooks_linux::tests +1 (Linux twin of the
cfg(windows) vfs_readonly_delete: readonly original/overlay denied and
still visible, writable paths unchanged, retire-after-move unaffected).
Failing-first: readonly delete returned Ok before (scratch test), both
upstream artifacts absent (grep 0).

Gates: both checks 0 errors; lib 766/0/1 threads=4 (+2); title e2e 12
unique FAILs all D3D12.X 0 non-GPU; retail fresh root SIGSEGV
exe+0x2237320 fault 0x0 unmapped stubs 20 xgr exactly 3 HOLDS.
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.

2 participants