Respect the persistent local storage quota in GetDiskFreeSpaceEx #231

Manually merged
github merged 2 commits from gh-pr/231/head into gh-pr/231/base 2026-11-26 04:16:56 +00:00
Owner

@⁠ZekkJJ on GitHub · 2026-11-23 21:25 UTC · original
ZekkJJ:codex/pls-disk-space-quota → main · +365 −29 · 6 files · 2 commits · merged 2026-11-23 21:29 UTC

Refs #106 (persistent local storage reporting).

XPersistentLocalStorageGetPath exposes the title’s PLS folder through S:\ by default. The GetDiskFreeSpaceExW/A hooks resolve that mount to the host directory, where Windows reports capacity for the entire volume. A title can therefore see the host’s capacity even when its PLS quota is nearly full.

For a translated PLS path, cap the reported total at the smaller of the configured quota and the Windows caller-visible total. Subtract the logical sizes of existing PLS files from the configured quota, then cap caller-available and volume-free bytes independently using their native values. Count files from the PLS root even when the query names a child directory. The hooks use the same quota conversion and usage traversal as XPersistentLocalStorageGetSpaceInfo.

The translated directory still goes through the native Win32 query. The hooks preserve native failure codes and optional outputs. The ANSI hook uses Windows’ active file code page. Ordinary host paths keep their native capacity figures. Queries that omit both free-space outputs skip the usage walk.

Regression evidence

The synthetic fixture resolves a 1 MiB MicrosoftGame.Config quota and writes 579 bytes of files across two directories.

Measurement Before on 956a476 After
Total bytes 1,021,821,579,264 1,048,576
Caller-available bytes 172,265,959,424 1,047,997
Volume-free bytes 172,265,959,424 1,047,997

The final regression exercises both detours, including a Unicode child directory and an OEM-encoded ANSI path on code page 437. It also checks an alias mount, an exhausted quota, ordinary host paths, null arguments, and a missing directory. A separate unit test checks the zero-config fallback, saturating conversion of oversized quotas, and independent host limits for caller-available and volume-free bytes.

Verification on Windows with Rust 1.95.0

Validated against main at eaa36b6.

  • cargo +1.95.0 build --locked --workspace passed.
  • cargo +1.95.0 test --locked -p xcl --test pls_quota -- --nocapture passed.
  • cargo +1.95.0 test --locked --workspace -- --test-threads=4 --nocapture reported 586 passed, 0 failed, and 39 ignored. Two wave64 cases reported runtime skips. The opt-in retail sample variables were unset.
  • cargo +1.95.0 clippy --locked --workspace --all-targets passed with the same diagnostics as clean main.
  • cargo +1.95.0 fmt --all --check reported existing formatting differences on both clean main and the patch. Rustfmt was applied to the changed lines. git diff --check passed.

After merging main at af20b4b, all 10 VFS hook unit tests and the native PLS regression passed again. The contribution diff is identical to the reviewed commit.

**@⁠ZekkJJ** on GitHub · 2026-11-23 21:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/231) `ZekkJJ:codex/pls-disk-space-quota` → `main` · +365 −29 · 6 files · 2 commits · merged 2026-11-23 21:29 UTC Refs #106 (persistent local storage reporting). `XPersistentLocalStorageGetPath` exposes the title’s PLS folder through `S:\` by default. The `GetDiskFreeSpaceExW/A` hooks resolve that mount to the host directory, where Windows reports capacity for the entire volume. A title can therefore see the host’s capacity even when its PLS quota is nearly full. For a translated PLS path, cap the reported total at the smaller of the configured quota and the Windows caller-visible total. Subtract the logical sizes of existing PLS files from the configured quota, then cap caller-available and volume-free bytes independently using their native values. Count files from the PLS root even when the query names a child directory. The hooks use the same quota conversion and usage traversal as `XPersistentLocalStorageGetSpaceInfo`. The translated directory still goes through the native Win32 query. The hooks preserve native failure codes and optional outputs. The ANSI hook uses Windows’ active file code page. Ordinary host paths keep their native capacity figures. Queries that omit both free-space outputs skip the usage walk. ## Regression evidence The synthetic fixture resolves a 1 MiB `MicrosoftGame.Config` quota and writes 579 bytes of files across two directories. | Measurement | Before on `956a476` | After | | --- | ---: | ---: | | Total bytes | 1,021,821,579,264 | 1,048,576 | | Caller-available bytes | 172,265,959,424 | 1,047,997 | | Volume-free bytes | 172,265,959,424 | 1,047,997 | The final regression exercises both detours, including a Unicode child directory and an OEM-encoded ANSI path on code page 437. It also checks an alias mount, an exhausted quota, ordinary host paths, null arguments, and a missing directory. A separate unit test checks the zero-config fallback, saturating conversion of oversized quotas, and independent host limits for caller-available and volume-free bytes. ## Verification on Windows with Rust 1.95.0 Validated against `main` at `eaa36b6`. - `cargo +1.95.0 build --locked --workspace` passed. - `cargo +1.95.0 test --locked -p xcl --test pls_quota -- --nocapture` passed. - `cargo +1.95.0 test --locked --workspace -- --test-threads=4 --nocapture` reported 586 passed, 0 failed, and 39 ignored. Two wave64 cases reported runtime skips. The opt-in retail sample variables were unset. - `cargo +1.95.0 clippy --locked --workspace --all-targets` passed with the same diagnostics as clean `main`. - `cargo +1.95.0 fmt --all --check` reported existing formatting differences on both clean `main` and the patch. Rustfmt was applied to the changed lines. `git diff --check` passed. After merging `main` at `af20b4b`, all 10 VFS hook unit tests and the native PLS regression passed again. The contribution diff is identical to the reviewed commit.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:16:54 +00:00
github manually merged commit 05a5fd587b into gh-pr/231/base 2026-11-26 04:16:56 +00:00
Author
Owner

@⁠ivall on GitHub · 2026-11-23 21:29 UTC · original

Merged (main 0f34407). Checked on an RX 9070 (RDNA4) with 6 PRs merged together on main d4f17ca: cargo build --workspace && cargo test --workspace -- --test-threads=4 - 611 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed; and the retail game still reaches its first menu at 30 fps.

**@⁠ivall** on GitHub · 2026-11-23 21:29 UTC · [original](https://github.com/xcl-dev/xcl/pull/231#issuecomment-7114540445) Merged (main 0f34407). Checked on an RX 9070 (RDNA4) with 6 PRs merged together on main d4f17ca: `cargo build --workspace && cargo test --workspace -- --test-threads=4` - 611 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed; and the retail game still reaches its first menu at 30 fps.
This discussion has been locked. Commenting is limited to contributors.
No description provided.