VFS: a write below a missing parent fails with ERROR_PATH_NOT_FOUND instead of conjuring the folder #1249

Open
pickles976 wants to merge 1 commit from upstream-pr/1259 into main
pickles976 commented 2026-11-24 13:55:00 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T13:55:00Z.


What: prepare_write ran create_dir_all on the overlay parent with no merged-view check. So CreateFileW("G:\nodir\f.bin", CREATE_ALWAYS) — parent in neither layer — created nodir and succeeded where Windows fails ERROR_PATH_NOT_FOUND; and a write below a removed directory resurrected the folder via commit_write → remove_whiteout (children staying whited out). stage_write (the copy/move path) already carries exactly the guard being added here, so the two entry points currently disagree on the same path. Found by @emirduran707's static audit (their #577 comment, 11:53Z); this implements the prepare_write half of their suggested fix.

What is in it

  • prepare_write: reject with ERROR_PATH_NOT_FOUND unless the virtual parent is a folder in the merged view (is_dir, matching stage_write's check line-for-line) — before anything is created on disk;
  • 3 tests: missing parent fails and creates nothing; removed (whited-out) dir is not resurrected and keeps its whiteout; a game-folder-only parent still works (the case the create_dir_all was there for).
  • Deliberately not included: the create_dir multi-level case from the same report — vfs::tests::directories codifies multi-level creation as the contract (create_dir("saves\slot1") == Ok(())), and whether the emulated console should match CreateDirectoryW's one-level semantics is a maintainer call, not a silent test rewrite. Details in my #577 reply.

Tested

  • hardware (GPU + driver, CPU), Rust version, debug / release: CPU-only host (i7-4770K), no GPU use — Linux dev box cross-building x86_64-pc-windows-gnu (llvm-mingw toolchain, clang+lld, static libunwind), release test profile, rustc stable; lib tests executed under Wine 9 (wine via CARGO_TARGET_..._RUNNER):
  • cargo test -p xcl --lib vfs::tests --target x86_64-pc-windows-gnu -- --test-threads=1: 15 passed, 0 failed, 0 ignored (12 pre-existing + 3 new; no GPU tests in the filtered set). The full cargo test --workspace from Linux requires the same cross + Wine setup (lib does not link natively here — retour); CI covers the workspace.

Regression run
Requesting the test-only label: CPU-only host, no title package or Windows desktop here, so no smoke.ps1 blocks — same lane @ryosen0 used with the recent VFS PR; happy to have it smoke-partnered if a reviewer wants title evidence beyond the unit level.

Not tested

  • smoke.ps1 on a real title (see above); the vfs_hooks CreateFileW end-to-end path under Wine (the two known Wine-9 CopyFile2 blockers in that suite are unrelated to this change and still abort on base).

AI use

  • none beyond static reading of our source.
<!-- greyfinch-sync:ivall/xcl:issue:5473499280 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1259). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T13:55:00Z. --- **What:** `prepare_write` ran `create_dir_all` on the overlay parent with no merged-view check. So `CreateFileW("G:\nodir\f.bin", CREATE_ALWAYS)` — parent in neither layer — **created `nodir` and succeeded** where Windows fails `ERROR_PATH_NOT_FOUND`; and a write below a **removed** directory resurrected the folder via `commit_write → remove_whiteout` (children staying whited out). `stage_write` (the copy/move path) already carries exactly the guard being added here, so the two entry points currently disagree on the same path. Found by @emirduran707's static audit (their #577 comment, 11:53Z); this implements the `prepare_write` half of their suggested fix. **What is in it** - `prepare_write`: reject with `ERROR_PATH_NOT_FOUND` unless the virtual parent is a folder in the merged view (`is_dir`, matching `stage_write`'s check line-for-line) — before anything is created on disk; - 3 tests: missing parent fails and creates nothing; removed (whited-out) dir is not resurrected and keeps its whiteout; a **game-folder-only parent still works** (the case the `create_dir_all` was there for). - Deliberately **not** included: the `create_dir` multi-level case from the same report — `vfs::tests::directories` codifies multi-level creation as the contract (`create_dir("saves\slot1") == Ok(())`), and whether the emulated console should match `CreateDirectoryW`'s one-level semantics is a maintainer call, not a silent test rewrite. Details in my #577 reply. **Tested** - hardware (GPU + driver, CPU), Rust version, debug / release: CPU-only host (i7-4770K), no GPU use — **Linux dev box cross-building `x86_64-pc-windows-gnu`** (llvm-mingw toolchain, clang+lld, static libunwind), release test profile, rustc stable; lib tests executed under Wine 9 (`wine` via `CARGO_TARGET_..._RUNNER`): - `cargo test -p xcl --lib vfs::tests --target x86_64-pc-windows-gnu -- --test-threads=1`: **15 passed, 0 failed, 0 ignored** (12 pre-existing + 3 new; no GPU tests in the filtered set). The full `cargo test --workspace` from Linux requires the same cross + Wine setup (lib does not link natively here — `retour`); CI covers the workspace. **Regression run** Requesting the **`test-only` label**: CPU-only host, no title package or Windows desktop here, so no `smoke.ps1` blocks — same lane @ryosen0 used with the recent VFS PR; happy to have it smoke-partnered if a reviewer wants title evidence beyond the unit level. **Not tested** - `smoke.ps1` on a real title (see above); the `vfs_hooks` CreateFileW end-to-end path under Wine (the two known Wine-9 `CopyFile2` blockers in that suite are unrelated to this change and still abort on base). **AI use** - none beyond static reading of our source.
dcastell1 commented 2026-11-24 14:06:49 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T14:01:14Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@930e8b4 (baseline 751 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
754 passed; 0 failed; 41 ignored   (exit 0)

Three more than the baseline; a write below a missing parent failing with the right error is covered and green.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7133704857 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1259#issuecomment-7133704857). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T14:01:14Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on `main@930e8b4` (baseline **751 passed, 0 failed, 41 ignored** on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 754 passed; 0 failed; 41 ignored (exit 0) ``` Three more than the baseline; a write below a missing parent failing with the right error is covered and green. Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
pickles976 commented 2026-11-24 14:06:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T14:02:56Z.


Thanks @dcastell1 — full-workspace green on native Windows (754 vs 751 baseline) is stronger unit evidence than my Wine cross-run, and the clean-patch/revert discipline is noted.\n\nTo the maintainers: the two xcl-smoke lint failures are the known Linux-contributor wall — this box has no title package and no Windows desktop, and the change is CPU-only VFS error-path logic with no GPU or title interaction. Requesting the test-only label for this PR (the lane established when #763 was reviewed): the risk surface is exactly what the 3 new unit tests + dcastell1's full-suite native run cover; a title regression beyond that would need the fix to corrupt the overlay, which the whited-out and game-only-parent tests are precisely about. Happy to add smoke blocks later if a reviewer wants them before merge.

<!-- greyfinch-sync:ivall/xcl:comment:7133753056 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1259#issuecomment-7133753056). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T14:02:56Z. --- Thanks @dcastell1 — full-workspace green on native Windows (754 vs 751 baseline) is stronger unit evidence than my Wine cross-run, and the clean-patch/revert discipline is noted.\n\nTo the maintainers: the two `xcl-smoke` lint failures are the known Linux-contributor wall — this box has no title package and no Windows desktop, and the change is CPU-only VFS error-path logic with no GPU or title interaction. **Requesting the `test-only` label** for this PR (the lane established when #763 was reviewed): the risk surface is exactly what the 3 new unit tests + dcastell1's full-suite native run cover; a title regression beyond that would need the fix to corrupt the overlay, which the whited-out and game-only-parent tests are precisely about. Happy to add smoke blocks later if a reviewer wants them before merge.
DavidM1911 commented 2026-11-24 14:06:53 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T14:05:36Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl lib vfs: 25 passed, 0 failed.

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7133827604 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1259#issuecomment-7133827604). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T14:05:36Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl lib vfs: 25 passed, 0 failed. Thanks!
pickles976 commented 2026-11-24 16:07:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T15:20:36Z.


Sequencing note for the reviewer from my side of the VFS lane: #1362 (staged whiteout preservation) and this PR are complementary halves of the same #577 third-party audit — theirs fixes failed-open resurrection, this one missing-parent conjuring. The textual conflict is one renamed function: my guard slots at the top of prepare_write_staged after their rename with zero semantic change, and the joint test set (their whiteout tests + this PR's 3) covers both halves. Whichever merges second rebases onto the other — flagging so it is a plan, not a surprise.

<!-- greyfinch-sync:ivall/xcl:comment:7135863766 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/1259#issuecomment-7135863766). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T15:20:36Z. --- Sequencing note for the reviewer from my side of the VFS lane: #1362 (staged whiteout preservation) and this PR are **complementary halves of the same #577 third-party audit** — theirs fixes failed-open resurrection, this one missing-parent conjuring. The textual conflict is one renamed function: my guard slots at the top of `prepare_write_staged` after their rename with zero semantic change, and the joint test set (their whiteout tests + this PR's 3) covers both halves. Whichever merges second rebases onto the other — flagging so it is a plan, not a surprise.
Toons29 commented 2026-11-25 04:10:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:20:08Z.


Regression run of 3460d080 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 3460d08008d2fcc8ac2af28278bc896d99c36986
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1626 (PresentX 1626)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14813 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151817289 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1259#issuecomment-7151817289). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:20:08Z. --- Regression run of `3460d080` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 3460d08008d2fcc8ac2af28278bc896d99c36986 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1626 (PresentX 1626) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14813 MB ``` Against the limits in CONTRIBUTING.md: 100 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
github-actions[bot] commented 2026-11-28 08:01:38 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-28T08:01:38Z.


Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

<!-- greyfinch-sync:ivall/xcl:comment:7236313591 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1259#issuecomment-7236313591). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-28T08:01:38Z. --- Nothing has happened on this PR for 3 days, so it is marked `stale` and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto `main` if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.
Foniass commented 2026-12-01 05:15:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:15:55Z.


Triage (#1607) – head 3460d08

#618 changes the same function (vfs.rs:Vfs::prepare_write) differently: it rejects only a parent that is an existing file (also in create_dir) and keeps creating missing parents. This PR requires the parent to be a directory, which also rejects a file parent in prepare_write and matches Win32 (missing parent -> ERROR_PATH_NOT_FOUND, as stage_write already does on main).
The two conflict: #618's test missing_or_hidden_file_parents_can_be_recreated expects G:\new\nested\save.bin to be created, which this PR refuses. Only one of the two semantics can be merged.
The PR description check is failing.
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:7301588592 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1259#issuecomment-7301588592). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:15:55Z. --- **Triage (#1607)** – head 3460d08 #618 changes the same function (vfs.rs:Vfs::prepare_write) differently: it rejects only a parent that is an existing file (also in `create_dir`) and keeps creating missing parents. This PR requires the parent to be a directory, which also rejects a file parent in `prepare_write` and matches Win32 (missing parent -> ERROR_PATH_NOT_FOUND, as `stage_write` already does on main). The two conflict: #618's test `missing_or_hidden_file_parents_can_be_recreated` expects `G:\new\nested\save.bin` to be created, which this PR refuses. Only one of the two semantics can be merged. The PR description check is failing. 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/1259:upstream-pr/1259'
git switch 'upstream-pr/1259'

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/1259'
git switch 'upstream-pr/1259'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/1259'
git switch 'upstream-pr/1259'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/1259'
git switch 'main'
git merge --squash 'upstream-pr/1259'
git switch 'main'
git merge --ff-only 'upstream-pr/1259'
git switch 'main'
git merge 'upstream-pr/1259'
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!1249
No description provided.