OLD-8161: restore old upstream PR 8161 - file_system: T: is a folder of each process's own in the overlay #684

Manually merged
github merged 4 commits from gh-pr/684/head into gh-pr/684/base 2026-11-26 09:16:12 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 11:56 UTC · original
aslan2142:t-drive-overlay → main · +391 −30 · 9 files · 4 commits · merged 2026-11-25 22:56 UTC

Claimed in the coordination issue as: OLD-8161 #14

Restoration of my original pull request, old upstream PR 8161 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Ported onto main at 21625bca8c; the port makes T:'s folder and reserve_unique_dir's creates go through main's win32_io_path, keeps the scratch-folder exception in the write-open path, and points main's long-overlay T: check at the process's own folder.

Depends on: #317 (textual conflict in parse_console), #379 (conflict in docs/boot.md)

What and why

  • Problem: T:\ mapped to <overlay>\.gta6rt-temp, one folder shared by every run and kept between runs.
    • The title makes its crash dump and crash log there with CREATE_NEW.
    • If an earlier run or a second process had left the same name, the create failed with ERROR_FILE_EXISTS (80) and no report landed. This was old upstream issue 7913, measured by Spacecer2 under Wine 11.22.
  • Fix: T:\ now names <overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>, using the process's start time in UTC and its id. On the console, T: is the title's own temporary drive, empty at launch and shared with no other run.
  • Reservation: rt::fs::reserve_unique_dir takes the folder with a create-only CreateDirectoryW.
    • If that name already exists (a reused process id in the same millisecond, which Wine makes likely), it tries -2, -3, ... up to 1000 names, so no run writes into an older folder.
    • The reservation happens once per overlay, under a mutex.
    • If it fails, the reason is printed once and T: paths fail with ERROR_INVALID_NAME.
  • Unchanged behaviour:
    • T:\.. cannot climb into the shared folder.
    • T:\ still cannot be removed or moved.
    • Earlier runs' folders are kept, so their crash files can be read.
    • GAME: and G: are unchanged.
  • Startup line: it names the folder: console paths: GAME: -> ..., writes -> ..., T: -> .... rt::fs::scratch_dir() returns the folder. check_console_paths.cmake, check_game_dir.cmake and tests/test_console_paths.py expect the new part.
  • Docs: docs/boot.md and docs/runtime_imports.md describe the mapping.
  • Related: #287 (GetTempPath/GetTempFileName resolve to the overlay scratch folder) is complementary, not a conflict. It drops the first part parse_console returns, so it lands in this process's folder too.

Tested

Linux, Wine 11.22 (Staging), clang 23 targeting x86_64-w64-mingw32 (lld, static libstdc++). This is a local check only; the MSVC /W4 /permissive- build is left to CI.

  • file_system_test on main (21625bca8): 494 checks, 11 failures.
  • This PR's tests built against main's file_system.cpp (the new functions stubbed to main's behaviour): 519 checks, 27 failures, so the PR's checks add 16.
    • CreateFileW(T:\crash.dmp, CREATE_NEW) fails with 80 in this process and in the second process.
    • Every reserve_unique_dir check fails.
  • This branch: 519 checks, 11 failures, the same 11 as on main. The first commit alone gives 508 checks and the same 11 failures.
  • The 11 failures are Wine-only and fail on main too:
    • a host ReadFile into uncommitted pages does not fail with ERROR_NOACCESS (1);
    • MAXIMUM_ALLOWED write-opens of a package file through CreateFileW, CreateFileA and CreateFile2 (6);
    • long-path deletion markers and listings (3);
    • removing the synthetic long paths afterwards (1).
  • Other checks:
    • python -I tests/test_console_paths.py: OK.
    • run_tiny_game_console_paths and run_tiny_game_dir need the Windows gta6rt build and are left to CI.
    • git diff --check is clean.
    • python -I scripts/check_no_game_data.py on the 9 changed files is clean.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-24 11:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/684) `aslan2142:t-drive-overlay` → `main` · +391 −30 · 9 files · 4 commits · merged 2026-11-25 22:56 UTC Claimed in the coordination issue as: OLD-8161 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 Restoration of my original pull request, old upstream PR 8161 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Ported onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31; the port makes `T:`'s folder and `reserve_unique_dir`'s creates go through main's `win32_io_path`, keeps the scratch-folder exception in the write-open path, and points main's long-overlay `T:` check at the process's own folder. Depends on: #317 (textual conflict in `parse_console`), #379 (conflict in `docs/boot.md`) ### What and why - **Problem:** `T:\` mapped to `<overlay>\.gta6rt-temp`, one folder shared by every run and kept between runs. - The title makes its crash dump and crash log there with `CREATE_NEW`. - If an earlier run or a second process had left the same name, the create failed with `ERROR_FILE_EXISTS` (80) and no report landed. This was old upstream issue 7913, measured by Spacecer2 under Wine 11.22. - **Fix:** `T:\` now names `<overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>`, using the process's start time in UTC and its id. On the console, `T:` is the title's own temporary drive, empty at launch and shared with no other run. - **Reservation:** `rt::fs::reserve_unique_dir` takes the folder with a create-only `CreateDirectoryW`. - If that name already exists (a reused process id in the same millisecond, which Wine makes likely), it tries `-2`, `-3`, ... up to 1000 names, so no run writes into an older folder. - The reservation happens once per overlay, under a mutex. - If it fails, the reason is printed once and `T:` paths fail with `ERROR_INVALID_NAME`. - **Unchanged behaviour:** - `T:\..` cannot climb into the shared folder. - `T:\` still cannot be removed or moved. - Earlier runs' folders are kept, so their crash files can be read. - `GAME:` and `G:` are unchanged. - **Startup line:** it names the folder: `console paths: GAME: -> ..., writes -> ..., T: -> ...`. `rt::fs::scratch_dir()` returns the folder. `check_console_paths.cmake`, `check_game_dir.cmake` and `tests/test_console_paths.py` expect the new part. - **Docs:** `docs/boot.md` and `docs/runtime_imports.md` describe the mapping. - **Related:** #287 (`GetTempPath`/`GetTempFileName` resolve to the overlay scratch folder) is complementary, not a conflict. It drops the first part `parse_console` returns, so it lands in this process's folder too. ### Tested Linux, Wine 11.22 (Staging), clang 23 targeting `x86_64-w64-mingw32` (lld, static libstdc++). This is a local check only; the MSVC `/W4 /permissive-` build is left to CI. - **`file_system_test` on main (21625bca8):** 494 checks, 11 failures. - **This PR's tests built against main's `file_system.cpp`** (the new functions stubbed to main's behaviour): 519 checks, 27 failures, so the PR's checks add 16. - `CreateFileW(T:\crash.dmp, CREATE_NEW)` fails with 80 in this process and in the second process. - Every `reserve_unique_dir` check fails. - **This branch:** 519 checks, 11 failures, the same 11 as on main. The first commit alone gives 508 checks and the same 11 failures. - **The 11 failures are Wine-only and fail on main too:** - a host `ReadFile` into uncommitted pages does not fail with `ERROR_NOACCESS` (1); - `MAXIMUM_ALLOWED` write-opens of a package file through `CreateFileW`, `CreateFileA` and `CreateFile2` (6); - long-path deletion markers and listings (3); - removing the synthetic long paths afterwards (1). - **Other checks:** - `python -I tests/test_console_paths.py`: OK. - `run_tiny_game_console_paths` and `run_tiny_game_dir` need the Windows `gta6rt` build and are left to CI. - `git diff --check` is clean. - `python -I scripts/check_no_game_data.py` on the 9 changed files is clean. GPUs tested: n/a AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
T:\ mapped to <overlay>\.gta6rt-temp, one folder shared by every run and
kept between runs. The title makes its crash dump and crash log there
with CREATE_NEW, and a name an earlier run (or a second process) had
left failed with ERROR_FILE_EXISTS (80), so no report landed (old
upstream issue 7913, measured by Spacecer2 under Wine 11.22).

T:\ now names <overlay>\.gta6rt-temp\<YYYYMMDD-HHMMSS-mmm>-pid<id>, the
process's start time in UTC and its id, made on the first T: call. The
start time keeps a reused process id (Wine hands each fresh prefix the
same small ids) out of an old run's folder. T:\.. cannot climb into the
shared folder, T:\ itself still cannot be removed or moved, and earlier
runs' folders are kept so their crash files can be read. GAME: and G:
are unchanged.

rt::fs::scratch_dir() returns the folder, and the startup line names it:
"console paths: GAME: -> ..., writes -> ..., T: -> ...". The two CMake
checks of that line (run_tiny_game_console_paths, run_tiny_game_dir)
and the synthetic test of the first now expect the T: part.

file_system_test: a CREATE_NEW of a name earlier runs left in
.gta6rt-temp succeeds and lands in the process's own folder; the folder
is stable for the process; a second process (the test started again)
creating the same name on the same overlay succeeds in a folder of its
own; GAME: reads and writes are unchanged. On main these fail with
ERROR_FILE_EXISTS (80), in this process and in the second one.

Restored from old upstream PR 8161 and ported onto the new main: the
folder is made through main's win32_io_path, so long overlay roots keep
working, and the scratch-folder check of the write-open path is kept.
Main's long-overlay T: check now finds scratch.bin in the process's own
folder below .gta6rt-temp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Xiiano's review of old upstream PR 8161: the folder name (start time to
the millisecond plus process id) is not guaranteed unique, and earlier
runs' folders are kept, so a reused id in the same millisecond would
land in a stale folder and bring ERROR_FILE_EXISTS back. Under Wine
every fresh run gets the same small ids (both run_tiny_game_dir runs
here were pid 32).

rt::fs::reserve_unique_dir(base, stem) makes base\stem with
CreateDirectoryW and takes success as ownership; on ERROR_ALREADY_EXISTS
it tries stem-2, stem-3, ... up to 1000 names, and fails with the Win32
error otherwise. T:'s folder is reserved once per overlay under a mutex
(the first T: call or rt::fs::scratch_dir(), which the startup line
calls), so concurrent first calls share it. A failed reservation is
printed once and T: paths fail with ERROR_INVALID_NAME.
rt::fs::scratch_stem() gives the first name tried.

file_system_test: with stem and stem-2 taken, reserve_unique_dir makes
stem-3, new and empty, then stem-4; a file with the next name counts as
taken; max_tries names taken fail with ERROR_ALREADY_EXISTS; a missing
base is made. T: with folders of this process's own stem and stem-2
already kept takes stem-3 and CREATE_NEW succeeds; eight threads making
their first T: call at once reserve one folder. The second-process test
stays.

Restored from old upstream PR 8161 and ported onto the new main: the
base folder and every candidate go through main's win32_io_path, like
the other creates in file_system.cpp, so a long overlay root keeps
working.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in docs/boot.md, the --overlay switch: main now says the overlay defaults to
<game-dir>\overlay and the package is never written; this branch adds the per-process T: folder
inside the overlay. Kept main's sentence and appended the T: text after it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
docs/boot.md: main added LEONIDA_WRITE_DIR / LEONIDA_SAVE_DIR to the
--overlay bullet and a new "Under Wine on Linux" section; keep both and
the T: paragraph of this branch after main's sentences.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:16:10 +00:00
github manually merged commit c116c3fa28 into gh-pr/684/base 2026-11-26 09:16:12 +00:00
Author
Owner

@⁠abnalstlll-byte on GitHub · 2026-11-24 12:20 UTC · original · approved these changes

Reviewed and verified OLD-8161 restoration. Isolating guest process T: scratch directories under .gta6rt-temp<timestamp>-pid via atomic
eserve_unique_dir with CreateDirectoryW prevents cross-run file collision errors (ERROR_FILE_EXISTS) during crash dump creation. CTest coverage in
untime/tests/file_system_test.cpp and standard-library test ests/test_console_paths.py fully validate path resolution and isolation. Excellent work, approved.

**@⁠abnalstlll-byte** on GitHub · 2026-11-24 12:20 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/684#pullrequestreview-6039084149) · **approved these changes** Reviewed and verified OLD-8161 restoration. Isolating guest process T: scratch directories under <overlay>\.gta6rt-temp\<timestamp>-pid<id> via atomic eserve_unique_dir with CreateDirectoryW prevents cross-run file collision errors (ERROR_FILE_EXISTS) during crash dump creation. CTest coverage in untime/tests/file_system_test.cpp and standard-library test ests/test_console_paths.py fully validate path resolution and isolation. Excellent work, approved.
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:56 UTC · original

Merged: file_system: T: is a folder of each process's own in the overlay.

  • Changed since review: main merged in. The one conflict was in docs/boot.md, where main added LEONIDA_WRITE_DIR / LEONIDA_SAVE_DIR to the --overlay bullet and a new "Under Wine on Linux" section. Both are kept, with the T: paragraph after main's sentences (c116c3fa2).
  • Tested: the full Windows suite under Wine on main 5fab93967 with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. file_system fails only on the BCryptOpenAlgorithmProvider check, as on the baseline. test_console_paths.py passes.
  • Checked on main 6ef26a648 + c116c3fa2: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 9 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 22:56 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/684#issuecomment-7176966795) Merged: `file_system`: `T:` is a folder of each process's own in the overlay. - **Changed since review:** `main` merged in. The one conflict was in `docs/boot.md`, where `main` added `LEONIDA_WRITE_DIR` / `LEONIDA_SAVE_DIR` to the `--overlay` bullet and a new "Under Wine on Linux" section. Both are kept, with the `T:` paragraph after `main`'s sentences (`c116c3fa2`). - **Tested:** the full Windows suite under Wine on `main` `5fab93967` with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. `file_system` fails only on the `BCryptOpenAlgorithmProvider` check, as on the baseline. `test_console_paths.py` passes. - **Checked on `main` `6ef26a648` + `c116c3fa2`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 9 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.