Skip to content

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

Closed
anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:vfs/reject-nonempty-directories
Closed

anakatt wants to merge 1 commit into
xcl-dev:mainfrom
anakatt:vfs/reject-nonempty-directories

Conversation

@anakatt

@anakatt anakatt commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

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

Assisted-by: omp (openai-codex/gpt-6-astra)
@emirduran707

Copy link
Copy Markdown
Contributor

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

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.

@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

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.

@thehollowedone

Copy link
Copy Markdown

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.

CalvyPZ pushed a commit to CalvyPZ/xcl that referenced this pull request Nov 24, 2026
Older runs could persist a parent whiteout without hiding each child
individually. Restore that fixture so directory recreation still covers
pushing the parent's whiteout down to its original children.

Follow-up to the review of xcl-dev#1016. No runtime behavior change.
Windows tests not run: the available VM has no configured build tools.

Assisted-by: omp (openai-codex/gpt-6-astra)
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: RemoveDirectoryW on a non-empty game folder succeeds and hides the folder in every later run

4 participants