diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 07:02:11 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 07:05:40 -0500 |
| commit | de8cb53d5498ce914ba82bc02c6a3f39dc03f3bf (patch) | |
| tree | 48e08d747d41b9f46e18325d3fe11f45de34f0af /docs | |
| parent | 21625bca8c675c62f9dbffc318ce6a59d57faf31 (diff) | |
file_system: RemoveDirectory and a create inside the folder are ordered as on the host
Restores old upstream PR 9215 in ItsNotRexed/Leonida (closed unmerged when that repository went private), ported
onto the current main: the write-open keeps main's long-path disk_path() for its overlay path, and the new race test
sits after main's tests that recreate a removed package folder.
A GAME: write-open checked that its folder exists, mirrored it into the overlay and then opened the file, and
RemoveDirectory checked that the folder was empty and wrote its marker, neither under a lock. A remove that ran
between the open's check and its host CreateFile succeeded on an empty folder, and the open then made the folder
and the file again: both calls succeeded and the removed folder was back. CreateDirectory of a folder inside it had
the same gap. On Windows one of the two fails: the create with ERROR_PATH_NOT_FOUND or the remove with
ERROR_DIR_NOT_EMPTY.
A striped lock keyed by the folder's upper-cased name (64 namespace-scope std::mutex, no function-local static):
write_target holds the lock of the folder it opens in from the parent check until the Target is gone, after the
host CreateFile/CreateFile2; CreateDirectory holds the parent's from its check to the host call; RemoveDirectory
holds the folder's from its view to the marker. Reads take no lock.
file_system_test races the two calls on two threads, 2,000 rounds each for a creating CreateFileW (CREATE_NEW,
CREATE_ALWAYS, OPEN_ALWAYS) and for CreateDirectoryW, and checks that they never both succeed, that the loser
fails with the host's error and that a removed folder stays removed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/runtime_imports.md | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/docs/runtime_imports.md b/docs/runtime_imports.md index 7b9f62d5a..7cad0eed7 100644 --- a/docs/runtime_imports.md +++ b/docs/runtime_imports.md | |||
| @@ -232,7 +232,9 @@ and the `api-ms-win-core-file-*` sets a GDK title links against. | |||
| 232 | package has, fails with `ERROR_ALREADY_EXISTS`; a missing parent with `ERROR_PATH_NOT_FOUND`. | 232 | package has, fails with `ERROR_ALREADY_EXISTS`; a missing parent with `ERROR_PATH_NOT_FOUND`. |
| 233 | - `RemoveDirectory*` needs the folder empty in the title's view (`ERROR_DIR_NOT_EMPTY` otherwise). An overlay folder is | 233 | - `RemoveDirectory*` needs the folder empty in the title's view (`ERROR_DIR_NOT_EMPTY` otherwise). An overlay folder is |
| 234 | removed; a package folder is hidden by a `.gta6rt-dir` marker inside its marker folder, and stays on disk. A marker | 234 | removed; a package folder is hidden by a `.gta6rt-dir` marker inside its marker folder, and stays on disk. A marker |
| 235 | folder on its own (left by a file deleted below it) does not hide anything. | 235 | folder on its own (left by a file deleted below it) does not hide anything. A remove and a write-open or |
| 236 | `CreateDirectory*` inside the folder on another thread are ordered as on the host: one goes first, and the create | ||
| 237 | fails with `ERROR_PATH_NOT_FOUND` or the remove with `ERROR_DIR_NOT_EMPTY`, never both succeeding. | ||
| 236 | - `MoveFile*` writes the destination in the overlay. A package file is copied there and its old name deleted by a | 238 | - `MoveFile*` writes the destination in the overlay. A package file is copied there and its old name deleted by a |
| 237 | marker; an overlay file or an overlay-only folder is renamed. An existing destination needs | 239 | marker; an overlay file or an overlay-only folder is renamed. An existing destination needs |
| 238 | `MOVEFILE_REPLACE_EXISTING` even when only the package has it. Moving a package folder fails with | 240 | `MOVEFILE_REPLACE_EXISTING` even when only the package has it. Moving a package folder fails with |