XGameSave: a container name too long for a folder gets a hashed one #493

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

@⁠pablogonz12 on GitHub · 2026-11-24 01:01 UTC · original
pablogonz12:gamesave-long-names → main · +97 −9 · 1 files · 1 commits · closed without merging

A container's folder is enc(name). A valid name has up to 256 characters, and enc turns each escaped byte into three, so past 255 characters the folder cannot be created: XGameSaveCreateContainer returns S_OK and every XGameSaveSubmitUpdate to that container fails with E_FAIL. Fixes #326.

What is in it

  • crates/xcl/src/hle/xgameruntime/gamesave.rs:
    • container_folder(name): enc(name) when it fits in 255 characters (so every folder that works today keeps its name); otherwise the start of enc(name) (never cut inside a %XX), ~ and a 64-bit FNV-1a hash of the lowercase name. enc never writes ~, so the two kinds never meet; the hash is of the lowercase name because container names match ignoring case, as the enc(name) folders do on NTFS.
    • apply() writes the exact name to the folder's name file when the folder is a hashed one; each_container reads it back through container_name(dir).
    • XGameSaveCreateContainer, XGameSaveDeleteContainer(Async) use container_folder.
    • Test long_container_names_are_saved_listed_and_deleted: the two names from the issue (256 letters; "a/" × 85 + "x", 341 characters encoded) are written, read back, found by XGameSaveGetContainerInfo in upper case, listed by XGameSaveEnumerateContainerInfo with their exact names, and deleted; a 255-character name keeps its plain folder.

Tested

  • AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, Rust stable, release.
  • cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu (llvm-mingw 20261117), test binary run under Wine with --test-threads=4:
    • this PR (820ff6a): 632 passed, 5 failed, 21 ignored;
    • main (a6f5f7a): 631 passed, 5 failed, 21 ignored – the same five fail on both (gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction, xma2_source_voice_decodes_and_manages_lifetime, and pe::tests::parses_own_test_binary_tls, which #464 fixes for this toolchain).
  • cargo test ... gamesave: 11 passed. The new test on main's gamesave.rs (without its two container_folder asserts): FAILED at the first XGameSaveSubmitUpdate, as the issue describes.

Regression run
Made with scripts/linux/smoke.sh from #257 under Wine (not smoke.ps1), MSVC builds (cargo xwin) of both commits. The main block was made with a local copy of the script with two lines changed so that a run which does not reach its end still prints its block (set -eu instead of set -euo pipefail; the data: fallback as an if).

xcl-smoke v1
commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 9 (PresentX 9)
presents per 2 s (last 3): 1 0 1
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 820ff6a2d1abd2b3869c7a9940cb6e0bda30bfff
gpu: AMD Radeon RX 9070 XT (RADV GFX1201)
title: Build
seconds: 60
exit: 0x0
frames shown: 10 (PresentX 11)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

Not tested

  • Windows and NTFS: built and run only as x86_64-pc-windows-gnu under Wine on Linux (the Linux file system has the same 255-byte limit on a name).
  • A title that uses names this long: the retail title in the regression run does not.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, the test and this description, and ran the commands above on the machine described.
**@⁠pablogonz12** on GitHub · 2026-11-24 01:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/493) `pablogonz12:gamesave-long-names` → `main` · +97 −9 · 1 files · 1 commits · closed without merging A container's folder is `enc(name)`. A valid name has up to 256 characters, and `enc` turns each escaped byte into three, so past 255 characters the folder cannot be created: `XGameSaveCreateContainer` returns `S_OK` and every `XGameSaveSubmitUpdate` to that container fails with `E_FAIL`. Fixes #326. **What is in it** - `crates/xcl/src/hle/xgameruntime/gamesave.rs`: - `container_folder(name)`: `enc(name)` when it fits in 255 characters (so every folder that works today keeps its name); otherwise the start of `enc(name)` (never cut inside a `%XX`), `~` and a 64-bit FNV-1a hash of the lowercase name. `enc` never writes `~`, so the two kinds never meet; the hash is of the lowercase name because container names match ignoring case, as the `enc(name)` folders do on NTFS. - `apply()` writes the exact name to the folder's `name` file when the folder is a hashed one; `each_container` reads it back through `container_name(dir)`. - `XGameSaveCreateContainer`, `XGameSaveDeleteContainer(Async)` use `container_folder`. - Test `long_container_names_are_saved_listed_and_deleted`: the two names from the issue (256 letters; `"a/" × 85 + "x"`, 341 characters encoded) are written, read back, found by `XGameSaveGetContainerInfo` in upper case, listed by `XGameSaveEnumerateContainerInfo` with their exact names, and deleted; a 255-character name keeps its plain folder. **Tested** - AMD Radeon RX 9070 XT (RADV GFX1201, Mesa), AMD Ryzen 9 9900X, CachyOS (Linux 7.3), Wine 11.0 (Proton CachyOS) with vkd3d-proton v3.1 + the patch from #257, Rust stable, release. - `cargo test -p xcl --lib --release --target x86_64-pc-windows-gnu` (llvm-mingw 20261117), test binary run under Wine with `--test-threads=4`: - this PR (`820ff6a`): 632 passed, 5 failed, 21 ignored; - `main` (`a6f5f7a`): 631 passed, 5 failed, 21 ignored – the same five fail on both (`gpu_f64_roots`, `gpu_f64_math_random`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `xma2_source_voice_decodes_and_manages_lifetime`, and `pe::tests::parses_own_test_binary_tls`, which #464 fixes for this toolchain). - `cargo test ... gamesave`: 11 passed. The new test on `main`'s `gamesave.rs` (without its two `container_folder` asserts): FAILED at the first `XGameSaveSubmitUpdate`, as the issue describes. **Regression run** Made with `scripts/linux/smoke.sh` from #257 under Wine (not `smoke.ps1`), MSVC builds (`cargo xwin`) of both commits. The `main` block was made with a local copy of the script with two lines changed so that a run which does not reach its end still prints its block (`set -eu` instead of `set -euo pipefail`; the `data:` fallback as an `if`). ``` xcl-smoke v1 commit: a6f5f7a74cc620c1f88a9e3669a633d10c3c8212 gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 9 (PresentX 9) presents per 2 s (last 3): 1 0 1 device removals: 0 crashes: 0 peak commit: 0 MB ``` ``` xcl-smoke v1 commit: 820ff6a2d1abd2b3869c7a9940cb6e0bda30bfff gpu: AMD Radeon RX 9070 XT (RADV GFX1201) title: Build seconds: 60 exit: 0x0 frames shown: 10 (PresentX 11) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 0 MB ``` **Not tested** - Windows and NTFS: built and run only as `x86_64-pc-windows-gnu` under Wine on Linux (the Linux file system has the same 255-byte limit on a name). - A title that uses names this long: the retail title in the regression run does not. **AI use** - Claude Code (Claude Opus 5.5): wrote the change, the test and this description, and ran the commands above on the machine described.
A container's folder is enc(name), and a valid name has up to 256 characters that enc turns into up to three each: past 255 the folder cannot be created, so XGameSaveCreateContainer said S_OK and every XGameSaveSubmitUpdate to it failed with E_FAIL (#326). Such a name now gets the start of enc(name), '~' and a 64-bit FNV-1a hash of the lowercase name as its folder (enc never writes '~'), and the exact name in the folder's 'name' file, which listing reads. Names whose folder fits keep the folder they always had.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:23:29 +00:00
github-bot closed this pull request 2026-11-26 04:23:29 +00:00
Author
Owner

@⁠pablogonz12 on GitHub · 2026-11-24 01:01 UTC · original

Closing: duplicate of #481 (and #492), which were opened before this one for the same issue. Sorry for the noise.

**@⁠pablogonz12** on GitHub · 2026-11-24 01:01 UTC · [original](https://github.com/xcl-dev/xcl/pull/493#issuecomment-7118681277) Closing: duplicate of #481 (and #492), which were opened before this one for the same issue. Sorry for the noise.

Pull request closed

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