VFS: reject removal of non-empty virtual directories #1016

Closed
github-bot wants to merge 1 commit from gh-pr/1016/head into gh-pr/1016/base
Owner

@⁠anakatt on GitHub · 2026-11-24 10:24 UTC · original
anakatt:vfs/reject-nonempty-directories → main · +76 −2 · 3 files · 1 commits · closed without merging

RemoveDirectoryW could hide a non-empty game directory permanently because removal checked only overlay contents. This change checks visible original children before changing the overlay or publishing a whiteout. Fixes #997.

What is in it

  • crates/xcl/src/vfs.rs: reject visible original children, preserve the overlay on failure, and cover merged contents, whiteouts, subdirectories and persistence.
  • crates/xcl/src/vfs_hooks.rs: update directory-enumeration coverage to empty a directory before removing it.
  • README.md: document directory-removal behavior.

Tested

  • I ran the tests on Windows 11 in a VM through Parallels. All tests passed. I have not included the exact command, hardware details or passed/ignored/SKIPPED counts yet.
  • rust-analyzer reported no issues in the two changed Rust files.
  • An earlier AI-assisted attempt to run cargo test -p xcl --lib vfs -- --test-threads=4 on macOS exited with code 101 while compiling Windows dependencies. No tests executed in that attempt.

Regression run

  • I still need to attach the generated xcl-smoke blocks from main and clean PR head ac25fd121b7761605955491accf4e2c208f9ebaa, using the same title and duration.

Not tested

  • Main-versus-head title regression measurements are not documented here yet: frame counts, peak commit and device-removal/crash comparisons remain unverified.

AI use

  • I used omp (openai-codex/gpt-6-astra) to investigate the issue, write the implementation, regression tests and documentation, attempt local validation, and prepare this description. I ran the Windows 11 tests myself.
**@⁠anakatt** on GitHub · 2026-11-24 10:24 UTC · [original](https://github.com/xcl-dev/xcl/pull/1016) `anakatt:vfs/reject-nonempty-directories` → `main` · +76 −2 · 3 files · 1 commits · closed without merging RemoveDirectoryW could hide a non-empty game directory permanently because removal checked only overlay contents. This change checks visible original children before changing the overlay or publishing a whiteout. Fixes #997. **What is in it** - `crates/xcl/src/vfs.rs`: reject visible original children, preserve the overlay on failure, and cover merged contents, whiteouts, subdirectories and persistence. - `crates/xcl/src/vfs_hooks.rs`: update directory-enumeration coverage to empty a directory before removing it. - `README.md`: document directory-removal behavior. **Tested** - I ran the tests on Windows 11 in a VM through Parallels. All tests passed. I have not included the exact command, hardware details or passed/ignored/SKIPPED counts yet. - rust-analyzer reported no issues in the two changed Rust files. - An earlier AI-assisted attempt to run `cargo test -p xcl --lib vfs -- --test-threads=4` on macOS exited with code 101 while compiling Windows dependencies. No tests executed in that attempt. **Regression run** - I still need to attach the generated `xcl-smoke` blocks from main and clean PR head `ac25fd121b7761605955491accf4e2c208f9ebaa`, using the same title and duration. **Not tested** - Main-versus-head title regression measurements are not documented here yet: frame counts, peak commit and device-removal/crash comparisons remain unverified. **AI use** - I used omp (`openai-codex/gpt-6-astra`) to investigate the issue, write the implementation, regression tests and documentation, attempt local validation, and prepare this description. I ran the Windows 11 tests myself.
Check visible original children before removing an overlay directory or
publishing a directory whiteout. Native removal checks overlay children.

Cover merged directories, whiteouts and visible subdirectories; update
existing removal tests to empty directories before removing them.

Validation: rust-analyzer reported no issues in the changed Rust files.
The focused cargo test command failed in Windows dependencies on macOS;
no tests ran. Windows tests and title smoke runs remain outstanding.

Fixes #997

Assisted-by: omp (openai-codex/gpt-6-astra)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:40:37 +00:00
github-bot closed this pull request 2026-11-26 04:40:37 +00:00
Author
Owner

@⁠emirduran707 on GitHub · 2026-11-24 10:39 UTC · original

AMD test report for ac25fd1 (this PR's head, on main 6efdabc), with the counts and smoke blocks the description still asks for. Feel free to copy them into it; they are from my machine.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.
  • cargo test --workspace -- --test-threads=4 at ac25fd1: 729 passed, 0 failed, 41 ignored; no SKIPPED lines.
  • scripts/smoke.ps1 -Game <retail title>, 60 s, no input, main then this PR, back to back. The gpu: line names a virtual display adapter of this machine (#281 / #282 / #285); XCL's log names the RX 9060 XT.

main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1561 (PresentX 1561)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 22149 MB

PR:

xcl-smoke v1
commit: ac25fd121b7761605955491accf4e2c208f9ebaa
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1577 (PresentX 1577)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 22129 MB

(On this title the peak commit swings between about 16 and 22 GB from run to run, as short peaks at about 16 s and 33 s. Here both runs caught them.)

Review: I made the same fix for #997 locally before I saw this PR, and the two check the same things: visible game children, and the overlay through fs::remove_dir. One note:

  • recreating_removed_directory_does_not_resurrect_original_children now deletes the children one by one before removing data. So it no longer covers what it was written for: a folder whited out as a whole while it still had game entries. Runs before this change saved exactly such whiteouts to .xcl_whiteouts, and remove_whiteout's push-down still has to handle them.
  • In my version I kept that case by making the whiteout directly:
    assert_eq!(v.remove_dir("data"), Err(ERROR_DIR_NOT_EMPTY));
    v.add_whiteout("data"); // as runs before this change saved it
    v.record_write("data");
    
    The rest of the test is unchanged.

Not tested: NVIDIA; Wine; a title that removes a non-empty folder of its own.

Tested and written with Claude Code (Claude Opus 5.5). The runs were made on my machine.

**@⁠emirduran707** on GitHub · 2026-11-24 10:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1016#issuecomment-7129063824) AMD test report for ac25fd1 (this PR's head, on `main` 6efdabc), with the counts and smoke blocks the description still asks for. Feel free to copy them into it; they are from my machine. **Tested** - AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 `x86_64-pc-windows-msvc`; DXC 1.9.2602.17; debug for the suite, release for the runs. - `cargo test --workspace -- --test-threads=4` at ac25fd1: 729 passed, 0 failed, 41 ignored; no `SKIPPED` lines. - `scripts/smoke.ps1 -Game <retail title>`, 60 s, no input, `main` then this PR, back to back. The `gpu:` line names a virtual display adapter of this machine (#281 / #282 / #285); XCL's log names the RX 9060 XT. main: ``` xcl-smoke v1 commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294 gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1561 (PresentX 1561) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 22149 MB ``` PR: ``` xcl-smoke v1 commit: ac25fd121b7761605955491accf4e2c208f9ebaa gpu: AMD Radeon RX 9060 XT title: retail-title seconds: 60 exit: 0x0 frames shown: 1577 (PresentX 1577) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 22129 MB ``` (On this title the peak commit swings between about 16 and 22 GB from run to run, as short peaks at about 16 s and 33 s. Here both runs caught them.) **Review:** I made the same fix for #997 locally before I saw this PR, and the two check the same things: visible game children, and the overlay through `fs::remove_dir`. One note: - `recreating_removed_directory_does_not_resurrect_original_children` now deletes the children one by one before removing `data`. So it no longer covers what it was written for: a folder whited out **as a whole** while it still had game entries. Runs before this change saved exactly such whiteouts to `.xcl_whiteouts`, and `remove_whiteout`'s push-down still has to handle them. - In my version I kept that case by making the whiteout directly: ```rust assert_eq!(v.remove_dir("data"), Err(ERROR_DIR_NOT_EMPTY)); v.add_whiteout("data"); // as runs before this change saved it v.record_write("data"); ``` The rest of the test is unchanged. **Not tested:** NVIDIA; Wine; a title that removes a non-empty folder of its own. Tested and written with Claude Code (Claude Opus 5.5). The runs were made on my machine.
Author
Owner

@⁠ivall on GitHub · 2026-11-24 11:04 UTC · original

Merged as 47efa2e (your commit, without its README sentence: the README tells users what works, and this is how Windows behaves anyway) – thanks, and thanks to @⁠emirduran707 for the counts and smoke runs. Checked: without the two check_original_dir_empty calls, 4 tests fail (directories, remove_dir_checks_both_layers_before_removing_overlay, remove_dir_rejects_visible_subdirectories, find_first_on_whited_out_and_recreated_directory). Tested on the merged batch (#990, #1037, #951, #1016): cargo test --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored, no SKIPPED. Retail title, 90 s with scripted presses, against main before the batch the same way: exit 0, no crash, no device removal, 1500 frames, peak process commit 27.7 GB against 29.2 GB.

**@⁠ivall** on GitHub · 2026-11-24 11:04 UTC · [original](https://github.com/xcl-dev/xcl/pull/1016#issuecomment-7129624958) Merged as 47efa2e (your commit, without its README sentence: the README tells users what works, and this is how Windows behaves anyway) – thanks, and thanks to @⁠emirduran707 for the counts and smoke runs. Checked: without the two `check_original_dir_empty` calls, 4 tests fail (`directories`, `remove_dir_checks_both_layers_before_removing_overlay`, `remove_dir_rejects_visible_subdirectories`, `find_first_on_whited_out_and_recreated_directory`). **Tested** on the merged batch (#990, #1037, #951, #1016): `cargo test --workspace --no-fail-fast -- --test-threads=4`: 741 passed, 0 failed, 41 ignored, no SKIPPED. Retail title, 90 s with scripted presses, against `main` before the batch the same way: exit 0, no crash, no device removal, 1500 frames, peak process commit 27.7 GB against 29.2 GB.
Author
Owner

@⁠thehollowedone on GitHub · 2026-11-24 11:20 UTC · original

I checked the pre-fix overlay case raised in the review above on Windows 11 at 47efa2e.

A synthetic fixture started with only a directory-level whiteout in .xcl_whiteouts. Recreating the directory kept the original files and nested directory hidden. An overlay file blocked removal with ERROR_DIR_NOT_EMPTY. After deleting that file, removal succeeded, the directory stayed hidden after reopening the VFS, and the original file bytes were intact.

Offline workspace build passed. All 22 stock VFS and hook tests passed, as did the separate fixture. AI-assisted. Codex (GPT-6) added and ran the scratch fixture.

**@⁠thehollowedone** on GitHub · 2026-11-24 11:20 UTC · [original](https://github.com/xcl-dev/xcl/pull/1016#issuecomment-7129966119) I checked the pre-fix overlay case raised in [the review above](https://github.com/ivall/xcl/pull/1016#issuecomment-7129063824) on Windows 11 at [47efa2e](https://github.com/ivall/xcl/commit/47efa2ecea0a12934719ae69b81930cf02a4b1c3). A synthetic fixture started with only a directory-level whiteout in `.xcl_whiteouts`. Recreating the directory kept the original files and nested directory hidden. An overlay file blocked removal with `ERROR_DIR_NOT_EMPTY`. After deleting that file, removal succeeded, the directory stayed hidden after reopening the VFS, and the original file bytes were intact. Offline workspace build passed. All 22 stock VFS and hook tests passed, as did the separate fixture. AI-assisted. Codex (GPT-6) added and ran the scratch fixture.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.