Skip to content

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

Merged
aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
aslan2142:t-drive-overlay
Nov 25, 2026
Merged

aslan2142 merged 4 commits into
ProjectLeonida:mainfrom
aslan2142:t-drive-overlay

Conversation

@aslan2142

Copy link
Copy Markdown
Collaborator

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

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 21625bc; 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: file_system: GetTempPath and GetTempFileName resolve GAME:, G: and T: to the overlay scratch folder #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 (21625bc): 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 and others added 2 commits November 24, 2026 06:54
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 <noreply@anthropic.com>
… one

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 <noreply@anthropic.com>

@abnalstlll-byte abnalstlll-byte left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 24, 2026
…da#684)

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 <noreply@anthropic.com>
@github-actions github-actions Bot added needs rebase Conflicts with the base branch: rebase it on main and removed needs rebase Conflicts with the base branch: rebase it on main labels Nov 25, 2026
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 <noreply@anthropic.com>
@aslan2142

Copy link
Copy Markdown
Collaborator Author

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants