fix(kernel): open game files through the extended-length path on Windows when the path is MAX_PATH or longer #9947

Merged
klosixgaming-arch merged 1 commit from upstream-pr/9947 into main 2026-11-08 10:29:24 +00:00
klosixgaming-arch commented 2026-10-22 23:10:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-22T23:10:27Z.


What

On Windows, CreateFileW and the streams built on it refuse an ordinary path of 260 characters (MAX_PATH) or more. #12560 added the shared NativeVerbatimPath_nid_no_patch and already uses it in open and the directory open. This PR builds on that helper for the places that still used the plain path:

  • the APR reader: the file stream, the size lookup (the FindFirstFileExW listing of the parent and the is_regular_file fallback) and the end-of-file check
  • directory descriptors: Load lists a directory through FindFirstFileExW with a verbatim search pattern on Windows and stats the directory, its parent and each entry through the verbatim path. InsideApp0 opens the /app0 root that way, and OpenDirectoryDescriptor checks for a directory that way.
  • sceKernelOpen: the O_NOFOLLOW symlink check and the directory fallback after a failed open

Samurai Maiden (PPSA04132, 01.060.000) has asset bundles with long names under Media/StreamingAssets/aa/PS5/. Under a 116-character runtime folder, every open whose resolved path reached 260 characters failed, and the title stayed dimmed on its logo screen.

Tested

Windows 11 (10.0.26200), WinLibs GCC 15.2.0, this head on main 4f41f4c375:

  • pass: the nine guest_apr_read_* cases including the new guest_apr_read_longeof; guest_filesystem; guest_windows_directory_link_types (with LongNoFollow); guest_directory_entries, _buffer, _rewind and _close; agc_shader_disk_cache_long_paths
  • not conclusive: long_paths failed while removing its temporary folder (WinError 32, file in use). Antivirus on this machine was blocking ctest.exe at the time, so I couldn't rerun it, guest_directory, guest_filesystem_error or agc_pipeline_journal_long_paths.
  • Open.cpp, Apr.cpp and DirectoryDescriptor.cpp compile on Linux (g++ -fsyntax-only). No full Linux build.
  • Samurai Maiden was tested on the earlier head of this PR, which reached the Load Game menu and a story scene. Not retested on this head.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA04132
  • GPUs tested: n/a
  • AI-assisted: yes. Written with AI assistance and reviewed by me.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4975365563 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-22T23:10:27Z. --- ### What On Windows, `CreateFileW` and the streams built on it refuse an ordinary path of 260 characters (`MAX_PATH`) or more. #12560 added the shared `NativeVerbatimPath_nid_no_patch` and already uses it in `open` and the directory open. This PR builds on that helper for the places that still used the plain path: - the APR reader: the file stream, the size lookup (the `FindFirstFileExW` listing of the parent and the `is_regular_file` fallback) and the end-of-file check - directory descriptors: `Load` lists a directory through `FindFirstFileExW` with a verbatim search pattern on Windows and stats the directory, its parent and each entry through the verbatim path. `InsideApp0` opens the `/app0` root that way, and `OpenDirectoryDescriptor` checks for a directory that way. - `sceKernelOpen`: the `O_NOFOLLOW` symlink check and the directory fallback after a failed open Samurai Maiden (PPSA04132, 01.060.000) has asset bundles with long names under `Media/StreamingAssets/aa/PS5/`. Under a 116-character runtime folder, every open whose resolved path reached 260 characters failed, and the title stayed dimmed on its logo screen. ### Tested Windows 11 (10.0.26200), WinLibs GCC 15.2.0, this head on main `4f41f4c375`: - pass: the nine `guest_apr_read_*` cases including the new `guest_apr_read_longeof`; `guest_filesystem`; `guest_windows_directory_link_types` (with `LongNoFollow`); `guest_directory_entries`, `_buffer`, `_rewind` and `_close`; `agc_shader_disk_cache_long_paths` - not conclusive: `long_paths` failed while removing its temporary folder (`WinError 32`, file in use). Antivirus on this machine was blocking `ctest.exe` at the time, so I couldn't rerun it, `guest_directory`, `guest_filesystem_error` or `agc_pipeline_journal_long_paths`. - `Open.cpp`, `Apr.cpp` and `DirectoryDescriptor.cpp` compile on Linux (`g++ -fsyntax-only`). No full Linux build. - Samurai Maiden was tested on the earlier head of this PR, which reached the Load Game menu and a story scene. Not retested on this head. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA04132 - [x] GPUs tested: n/a - [x] AI-assisted: yes. Written with AI assistance and reviewed by me.
MarcZX10 commented 2026-10-23 00:15:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:15:12Z.

Review: CHANGES_REQUESTED


The exact-head implementation still returns short relative paths before resolving them. A short relative input can resolve past MAX_PATH under a long current directory, while the added test only uses a relative string already longer than the limit. Please resolve/check the relative path before this early return and add the short-relative-under-long-current-directory regression case. Exact-head diff-check and conventions pass; hosted eligibility, conventions, labels and report pass, while product/relinker jobs are skipped. I have not run the Windows-only CTest locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5622463657 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5622463657). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T00:15:12Z. **Review:** CHANGES_REQUESTED --- The exact-head implementation still returns short relative paths before resolving them. A short relative input can resolve past `MAX_PATH` under a long current directory, while the added test only uses a relative string already longer than the limit. Please resolve/check the relative path before this early return and add the short-relative-under-long-current-directory regression case. Exact-head diff-check and conventions pass; hosted eligibility, conventions, labels and report pass, while product/relinker jobs are skipped. I have not run the Windows-only CTest locally.
MarcZX10 commented 2026-10-23 00:17:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:17:46Z.

Review: APPROVED


Reviewed exact head b1ab76973a82cfe88193fae36a62f23e4e4289f4. The third commit resolves relative paths before checking the normalized absolute length, preserves the fast path for short absolute paths, and adds the requested short-relative-name under long-current-directory case with cleanup. The reported Windows 11 run passes the updated helper test and repeats the title reproduction. I independently compiled and linked the exact Windows test and helper with MinGW-w64 GCC 12.2 (-std=c++20 -Wall -Wextra -Werror); this host has no Windows runtime, so I did not execute the binary. Exact-head diff-check and conventions pass. Product/relinker CI remains skipped by repository path policy.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5622479596 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5622479596). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T00:17:46Z. **Review:** APPROVED --- Reviewed exact head `b1ab76973a82cfe88193fae36a62f23e4e4289f4`. The third commit resolves relative paths before checking the normalized absolute length, preserves the fast path for short absolute paths, and adds the requested short-relative-name under long-current-directory case with cleanup. The reported Windows 11 run passes the updated helper test and repeats the title reproduction. I independently compiled and linked the exact Windows test and helper with MinGW-w64 GCC 12.2 (`-std=c++20 -Wall -Wextra -Werror`); this host has no Windows runtime, so I did not execute the binary. Exact-head diff-check and conventions pass. Product/relinker CI remains skipped by repository path policy.
MarcZX10 commented 2026-10-23 00:18:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:18:01Z.

Review: DISMISSED


One issue remains in the new regression test: it creates and recursively removes a fixed directory under the system temp path (aps5_extended_path_test). That can delete a pre-existing directory belonging to the user or interfere with a concurrent test run. Please use an exclusively created unique temp directory and clean up only that directory. The short-relative-path fix itself is present; exact-head diff-check/conventions pass, and the Windows test/helper cross-compile and link cleanly (runtime assertions were not run here).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5622481157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5622481157). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T00:18:01Z. **Review:** DISMISSED --- One issue remains in the new regression test: it creates and recursively removes a fixed directory under the system temp path (`aps5_extended_path_test`). That can delete a pre-existing directory belonging to the user or interfere with a concurrent test run. Please use an exclusively created unique temp directory and clean up only that directory. The short-relative-path fix itself is present; exact-head diff-check/conventions pass, and the Windows test/helper cross-compile and link cleanly (runtime assertions were not run here).
XairRrR commented 2026-10-29 03:17:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T03:17:44Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The long-path handling for the main open, directory and APR read paths looks right, but two checks in functions the debt entry now lists as long-path capable (sceKernelOpen with O_NOFOLLOW / O_CREAT|O_EXCL, and the APR read at end of file) still use the plain path, so a long path takes a different result there than a short one.

What I ran

Head fa00e458e659d19fd825e61d7e9ee5095d738235, main 3a2b91981651569163768854a1fcdc7193b6667b, merged with --no-ff in a clean worktree (Linux, GCC 16.2.1, Release, Ninja).

git fetch origin main pull/9947/head:refs/review/9947
git checkout --detach origin/main
git merge --no-ff --no-edit refs/review/9947
git diff --check origin/main...refs/review/9947
python3 tools/check_conventions.py --base origin/main
cmake --build build -j10 --target libs guest_filesystem_tests guest_apr_read_tests
cmake --build build -j10
ctest --test-dir build -j4 --output-on-failure \
  -R '^(guest_filesystem|guest_apr_read_.*|guest_directory|guest_directory_link_types|guest_directory_entries)$'
# negative control
git checkout origin/main -- core/libs/prx/libkernel/Apr/src/Apr.cpp core/libs/prx/libkernel/File/src/DirectoryDescriptor.cpp \
  core/libs/prx/libkernel/File/src/Open.cpp core/libs/prx/libkernel/CMakeLists.txt
cmake --build build -j10 --target libkernel guest_filesystem_tests
ctest --test-dir build --output-on-failure -R '^guest_filesystem$'

Results

Check Result
Merge onto main clean
git diff --check clean
check_conventions.py All conventions checks passed.
Build (libs + full build) OK
guest_filesystem, guest_apr_read_* (6), guest_directory, guest_directory_link_types, guest_directory_entries on Linux 10/10 passed
windows_extended_path, guest_windows_directory_link_types not built here (Windows-only targets, no MinGW toolchain on this host)
ctest (merged tree)
 7/10 Test #2583: guest_directory_link_types .......   Passed    0.00 sec
 8/10 Test #2584: guest_directory_entries ..........   Passed    0.00 sec
 9/10 Test #2392: guest_filesystem .................   Passed    0.05 sec
10/10 Test #2363: guest_apr_read_streams ...........   Passed    0.09 sec

100% tests passed out of 10

Negative control

I restored Apr.cpp, DirectoryDescriptor.cpp, Open.cpp and the libkernel CMakeLists.txt from main and kept the new GuestFilesystem.cpp. On Linux guest_filesystem still passes, which is expected: WindowsExtendedPath returns its input unchanged off Windows, and Linux has no 260-character limit. So the Linux run does not exercise the change. The Windows negative controls reported in the thread (guest_filesystem failing at the new sceKernelOpen check, and guest_windows_directory_link_types failing with either fa00e458e6 fix reverted) are from other people's runs. I did not reproduce them.

Findings

Blocking

  1. sceKernelOpen link checks still use the plain path — core/libs/prx/libkernel/File/src/Open.cpp:231, :238, :240, :243 (head line numbers).
    NativeOpen and the directory fallback now go through WindowsExtendedPath, but the O_CREAT|O_EXCL reparse-point check (GetFileAttributesW(native.c_str())) and the O_NOFOLLOW check (is_symlink(native), GetFileAttributesW(native.c_str()), ReadJunction(native, ...)) do not. In a process without long-path opt-in, GetFileAttributesW on a path of 260 characters or more returns INVALID_FILE_ATTRIBUTES, so both checks are skipped silently. With this PR the open that follows then succeeds:

    • O_NOFOLLOW on a junction or symbolic link at a long path opens through the link. The same call on a short path returns EMLINK.
    • For O_CREAT|O_EXCL on a long path, the EEXIST check for a reparse point is skipped, and the outcome is left to CreateFileW(CREATE_NEW).

    Before this PR, the open failed with ENOENT. Now it returns a wrong success, and the debt entry says sceKernelOpen uses the \\?\ form. Suggested fix: compute const auto openPath = File::WindowsExtendedPath(native); once in OpenNative and use it for these four calls, with a guest_windows_directory_link_types case that opens a junction under a long directory with O_NOFOLLOW and expects EMLINK. This is a source-level finding. I could not run it on Windows.

  2. APR read at end of file still stats the plain path — core/libs/prx/libkernel/Apr/src/Apr.cpp:186.
    _readFile now opens WindowsExtendedPath(file.path) (line 164). But a short read at EOF evaluates std::filesystem::file_size(file.path) on the plain path. For a file at a path of 260 characters or more, that call fails and file_size throws filesystem_error. The read then aborts where a short path zero-fills the tail, which is the case guest_apr_read_eof covers. The debt entry lists "the APR file read" as handled. Suggested fix: use the extended path there too, for example by hoisting const auto hostPath = File::WindowsExtendedPath(file.path); and using it for both the stream and file_size. This is also source-level and not run on Windows.

Non-blocking

  1. Other APR entry points still use the plain path: _fileSize's FindFirstFileExW((path.parent_path() / L"*").c_str(), ...) (Apr.cpp:78), its is_regular_file(path) fallback (Apr.cpp:105), and sceKernelAprGetFileStat's FillFileStat(_file(id).path, ...) (Apr.cpp:890, which throws on failure). So when the parent directory is 258 characters or more, resolution fails with ENOENT, and a stat of a long-path APR file throws. The debt line's catch-all ("the other functions that take a native path") covers this. Naming APR resolve and stat explicitly, or routing them through the helper, would make the entry accurate.
  2. Dead code in Load: DirectoryDescriptor.cpp:226-230. The original loop moved into the new #else branch, but it still contains an inner #ifdef _WIN32 ... EntryType(it->path(), followLinks) ... #else that can no longer be compiled. The two adjacent #ifdef _WIN32 blocks at lines 206-210 and 211 could also be merged. Suggested fix: keep only the DirectoryEntryType(it->symlink_status(error)) line in the non-Windows loop.
  3. UNC normalization: WindowsExtendedPath.hpp:21 normalizes \server\share\... as a rooted path. A .. directly under the share therefore removes the share: \\server\share\..\x becomes \\server\x, while Win32 keeps \\server\share as the root and gives \\server\share\x. This is a rare input. Normalizing only the part after \\server\share would match Win32.

The reviews and comments in the thread already covered short relative paths, the fixed temporary directory, directory EACCES, directory_iterator on WinLibs, InsideApp0 and the MAX_PATH search pattern. The current head addresses all of them in source, and I am not repeating them.

Not verified

  • No Windows build or run: windows_extended_path, guest_windows_directory_link_types and the Windows branches of guest_filesystem were not compiled or executed here. Both blocking findings come from reading the source.
  • The PPSA04132 reproduction (Windows-only, and titles are not run by this review).
  • Behaviour with the process-level long-path opt-in enabled (LongPathsEnabled together with a longPathAware manifest).

To get this to a good state

  • Pass the extended path to the O_CREAT|O_EXCL and O_NOFOLLOW checks in OpenNative, and add a Windows test for O_NOFOLLOW on a junction under a long directory.
  • Use the extended path for the file_size call in _readFile. A Windows APR test that reads past EOF of a long-path file would cover it.
  • Optionally route APR resolve and stat through the helper (or name them in the debt entry), and remove the dead #ifdef in Load.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5692442048 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5692442048). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-10-29T03:17:44Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The long-path handling for the main open, directory and APR read paths looks right, but two checks in functions the debt entry now lists as long-path capable (`sceKernelOpen` with `O_NOFOLLOW` / `O_CREAT|O_EXCL`, and the APR read at end of file) still use the plain path, so a long path takes a different result there than a short one. ## What I ran Head `fa00e458e659d19fd825e61d7e9ee5095d738235`, `main` `3a2b91981651569163768854a1fcdc7193b6667b`, merged with `--no-ff` in a clean worktree (Linux, GCC 16.2.1, Release, Ninja). ```sh git fetch origin main pull/9947/head:refs/review/9947 git checkout --detach origin/main git merge --no-ff --no-edit refs/review/9947 git diff --check origin/main...refs/review/9947 python3 tools/check_conventions.py --base origin/main cmake --build build -j10 --target libs guest_filesystem_tests guest_apr_read_tests cmake --build build -j10 ctest --test-dir build -j4 --output-on-failure \ -R '^(guest_filesystem|guest_apr_read_.*|guest_directory|guest_directory_link_types|guest_directory_entries)$' # negative control git checkout origin/main -- core/libs/prx/libkernel/Apr/src/Apr.cpp core/libs/prx/libkernel/File/src/DirectoryDescriptor.cpp \ core/libs/prx/libkernel/File/src/Open.cpp core/libs/prx/libkernel/CMakeLists.txt cmake --build build -j10 --target libkernel guest_filesystem_tests ctest --test-dir build --output-on-failure -R '^guest_filesystem$' ``` ## Results | Check | Result | |---|---| | Merge onto `main` | clean | | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Build (`libs` + full build) | OK | | `guest_filesystem`, `guest_apr_read_*` (6), `guest_directory`, `guest_directory_link_types`, `guest_directory_entries` on Linux | 10/10 passed | | `windows_extended_path`, `guest_windows_directory_link_types` | not built here (Windows-only targets, no MinGW toolchain on this host) | <details><summary>ctest (merged tree)</summary> ``` 7/10 Test #2583: guest_directory_link_types ....... Passed 0.00 sec 8/10 Test #2584: guest_directory_entries .......... Passed 0.00 sec 9/10 Test #2392: guest_filesystem ................. Passed 0.05 sec 10/10 Test #2363: guest_apr_read_streams ........... Passed 0.09 sec 100% tests passed out of 10 ``` </details> ## Negative control I restored `Apr.cpp`, `DirectoryDescriptor.cpp`, `Open.cpp` and the libkernel `CMakeLists.txt` from `main` and kept the new `GuestFilesystem.cpp`. On Linux `guest_filesystem` still passes, which is expected: `WindowsExtendedPath` returns its input unchanged off Windows, and Linux has no 260-character limit. So the Linux run does not exercise the change. The Windows negative controls reported in the thread (`guest_filesystem` failing at the new `sceKernelOpen` check, and `guest_windows_directory_link_types` failing with either `fa00e458e6` fix reverted) are from other people's runs. I did not reproduce them. ## Findings ### Blocking 1. **`sceKernelOpen` link checks still use the plain path** — `core/libs/prx/libkernel/File/src/Open.cpp:231`, `:238`, `:240`, `:243` (head line numbers). `NativeOpen` and the directory fallback now go through `WindowsExtendedPath`, but the `O_CREAT|O_EXCL` reparse-point check (`GetFileAttributesW(native.c_str())`) and the `O_NOFOLLOW` check (`is_symlink(native)`, `GetFileAttributesW(native.c_str())`, `ReadJunction(native, ...)`) do not. In a process without long-path opt-in, `GetFileAttributesW` on a path of 260 characters or more returns `INVALID_FILE_ATTRIBUTES`, so both checks are skipped silently. With this PR the open that follows then succeeds: - `O_NOFOLLOW` on a junction or symbolic link at a long path opens through the link. The same call on a short path returns `EMLINK`. - For `O_CREAT|O_EXCL` on a long path, the `EEXIST` check for a reparse point is skipped, and the outcome is left to `CreateFileW(CREATE_NEW)`. Before this PR, the open failed with `ENOENT`. Now it returns a wrong success, and the debt entry says `sceKernelOpen` uses the `\\?\` form. Suggested fix: compute `const auto openPath = File::WindowsExtendedPath(native);` once in `OpenNative` and use it for these four calls, with a `guest_windows_directory_link_types` case that opens a junction under a long directory with `O_NOFOLLOW` and expects `EMLINK`. This is a source-level finding. I could not run it on Windows. 2. **APR read at end of file still stats the plain path** — `core/libs/prx/libkernel/Apr/src/Apr.cpp:186`. `_readFile` now opens `WindowsExtendedPath(file.path)` (line 164). But a short read at EOF evaluates `std::filesystem::file_size(file.path)` on the plain path. For a file at a path of 260 characters or more, that call fails and `file_size` throws `filesystem_error`. The read then aborts where a short path zero-fills the tail, which is the case `guest_apr_read_eof` covers. The debt entry lists "the APR file read" as handled. Suggested fix: use the extended path there too, for example by hoisting `const auto hostPath = File::WindowsExtendedPath(file.path);` and using it for both the stream and `file_size`. This is also source-level and not run on Windows. ### Non-blocking 1. Other APR entry points still use the plain path: `_fileSize`'s `FindFirstFileExW((path.parent_path() / L"*").c_str(), ...)` (`Apr.cpp:78`), its `is_regular_file(path)` fallback (`Apr.cpp:105`), and `sceKernelAprGetFileStat`'s `FillFileStat(_file(id).path, ...)` (`Apr.cpp:890`, which throws on failure). So when the parent directory is 258 characters or more, resolution fails with `ENOENT`, and a stat of a long-path APR file throws. The debt line's catch-all ("the other functions that take a native path") covers this. Naming APR resolve and stat explicitly, or routing them through the helper, would make the entry accurate. 2. Dead code in `Load`: `DirectoryDescriptor.cpp:226-230`. The original loop moved into the new `#else` branch, but it still contains an inner `#ifdef _WIN32 ... EntryType(it->path(), followLinks) ... #else` that can no longer be compiled. The two adjacent `#ifdef _WIN32` blocks at lines 206-210 and 211 could also be merged. Suggested fix: keep only the `DirectoryEntryType(it->symlink_status(error))` line in the non-Windows loop. 3. UNC normalization: `WindowsExtendedPath.hpp:21` normalizes `\server\share\...` as a rooted path. A `..` directly under the share therefore removes the share: `\\server\share\..\x` becomes `\\server\x`, while Win32 keeps `\\server\share` as the root and gives `\\server\share\x`. This is a rare input. Normalizing only the part after `\\server\share` would match Win32. The reviews and comments in the thread already covered short relative paths, the fixed temporary directory, directory `EACCES`, `directory_iterator` on WinLibs, `InsideApp0` and the `MAX_PATH` search pattern. The current head addresses all of them in source, and I am not repeating them. ## Not verified - No Windows build or run: `windows_extended_path`, `guest_windows_directory_link_types` and the Windows branches of `guest_filesystem` were not compiled or executed here. Both blocking findings come from reading the source. - The PPSA04132 reproduction (Windows-only, and titles are not run by this review). - Behaviour with the process-level long-path opt-in enabled (`LongPathsEnabled` together with a `longPathAware` manifest). ## To get this to a good state - Pass the extended path to the `O_CREAT|O_EXCL` and `O_NOFOLLOW` checks in `OpenNative`, and add a Windows test for `O_NOFOLLOW` on a junction under a long directory. - Use the extended path for the `file_size` call in `_readFile`. A Windows APR test that reads past EOF of a long-path file would cover it. - Optionally route APR resolve and stat through the helper (or name them in the debt entry), and remove the dead `#ifdef` in `Load`.
BunnyFl commented 2026-11-02 23:27:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T23:27:03Z.

Review: APPROVED


XairRrR's two points look addressed in 67c3f5e7b9, and here's the Windows run the Linux reviews can't give. The O_NOFOLLOW and O_CREAT|O_EXCL link checks in Open.cpp (is_symlink, GetFileAttributesW, ReadJunction) now use the extended openPath. The APR end-of-file size check in Apr.cpp uses the extended hostPath, with the new longeof case. The UNC branch of WindowsExtendedPath keeps the \server\share root and gives \?\UNC\server\share\... for a long path.

Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current main: 15 of 15 pass, nothing skipped. They are guest_filesystem, guest_directory, guest_directory_entries, the nine guest_apr_read_* cases including guest_apr_read_longeof, long_paths, agc_pipeline_journal_long_paths and agc_shader_disk_cache_long_paths. With main's Apr.cpp, DirectoryDescriptor.cpp, Open.cpp and libkernel CMakeLists.txt (XairRrR's negative-control set), guest_filesystem aborts (0xc0000409).

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5744883235 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5744883235). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T23:27:03Z. **Review:** APPROVED --- XairRrR's two points look addressed in 67c3f5e7b9, and here's the Windows run the Linux reviews can't give. The `O_NOFOLLOW` and `O_CREAT|O_EXCL` link checks in `Open.cpp` (`is_symlink`, `GetFileAttributesW`, `ReadJunction`) now use the extended `openPath`. The APR end-of-file size check in `Apr.cpp` uses the extended `hostPath`, with the new `longeof` case. The UNC branch of `WindowsExtendedPath` keeps the `\server\share` root and gives `\?\UNC\server\share\...` for a long path. Tested on Windows 11, WinLibs GCC 15.2.0, with this head merged onto current `main`: 15 of 15 pass, nothing skipped. They are `guest_filesystem`, `guest_directory`, `guest_directory_entries`, the nine `guest_apr_read_*` cases including `guest_apr_read_longeof`, `long_paths`, `agc_pipeline_journal_long_paths` and `agc_shader_disk_cache_long_paths`. With `main`'s `Apr.cpp`, `DirectoryDescriptor.cpp`, `Open.cpp` and libkernel `CMakeLists.txt` (XairRrR's negative-control set), `guest_filesystem` aborts (`0xc0000409`).
XairRrR commented 2026-11-02 23:37:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T23:37:57Z.

Review: APPROVED


Re-checked — approved

Both blocking findings from my last review are fixed. Commit 67c3f5e7b9 puts the sceKernelOpen link checks and the APR end-of-file file_size call on the extended path and adds LongNoFollow and guest_apr_read_longeof. Commit a5be6b2720 moves the helper include out of the #ifdef _WIN32 block, so the Linux build works again. The two failures the bot reported come from main, not from this PR.

What changed since my last review

I last reviewed fa00e458e6. Since then:

  • 67c3f5e7b9: OpenNative now computes openPath once and uses it for the O_DIRECTORY status check, the O_CREAT|O_EXCL reparse-point check and the O_NOFOLLOW checks. _readFile uses one hostPath for the stream and for file_size. _fileSize extends the parent directory before listing it and extends the path in its is_regular_file fallback. The unreachable #ifdef in Load is gone. UNC normalization now keeps \\server\share as the root.
  • New tests: LongNoFollow in GuestWindowsDirectoryLinkTypes.cpp, guest_apr_read_longeof, and a \\server\share\..\file.bin case in windows_extended_path.
  • a5be6b2720: the WindowsExtendedPath.hpp include in Open.cpp sits above the #ifdef _WIN32 block. This fixes the Linux build error reported by oneandonlydean.
  • Rebases: the branch was rebased onto newer main. The range-diff shows only context changes in the earlier commits.
  • Other reviews: BunnyFl approved and reported a Windows run: 15/15 pass, and with main's production files guest_filesystem aborts.

What I ran

Head a5be6b2720c0af77b3324523f07af18b8c870793, main 5cb015caaaaf83f8ee431414ee6a457b5b307d49, merged tree 766baa0fe992b51a75c8c6b93fc766ee0297cf94 (Linux, GCC 14.2.0, Release, Ninja).

git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...a5be6b2720c0af77b3324523f07af18b8c870793
python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49
ctest --test-dir build --output-on-failure --repeat until-fail:3 \
  -R '^(agc_driver_image_sample_lod_clamp_shader_lane|unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group|guest_filesystem|guest_apr_read_.*)$'
# attempted negative control: Apr.cpp, DirectoryDescriptor.cpp, Open.cpp, libkernel CMakeLists.txt from main
git show 5cb015caaa:<path> > <path>
ninja -C build -j32 -l32 libkernel agc_driver_image_sample_lod_clamp_tests guest_filesystem_tests guest_apr_read_tests
git show 766baa0fe9:<path> > <path>
git status --porcelain
git log --oneline 096c45570f..5cb015caaa -- core/libs/prx/libSceAgcDriver core/shader tools/unwrap_self.py tools/tests/test_unwrap_self.py
Check Result
git diff --check clean
check_conventions.py All conventions checks passed.
Build (script) configure, build and libs OK
guest_filesystem, the 7 Linux guest_apr_read_* cases pass, 3 repeats each
agc_driver_image_sample_lod_clamp_shader_lane fails every time; comes from main (see below)
unwrap_self_..._destination_directory_group fails (os.chown → EINVAL in the sandbox); comes from main (see below)
windows_extended_path, guest_windows_directory_link_types, guest_apr_read_longeof not built here (Windows-only)

The two new failures come from main:

  • The failure baseline is from 096c45570f, which is older than main. Since then main merged 4e2a028e43 fix(agc): bind a T# minimum LOD through an S# that holds the LOD at 0 (#12980) and new unwrap test cases (#14558). Those are the two failing tests.
  • On Linux the PR changes nothing at run time: WindowsExtendedPath returns its input unchanged when _WIN32 is not defined. Every other changed line in Apr.cpp, Open.cpp and DirectoryDescriptor.cpp is inside _WIN32 code or goes through that helper.
  • The unwrap test is a Python test of tools/, which this PR does not touch.
  • I tried to confirm the AGC failure by rebuilding with main's production files, but could not (see Not verified).
AGC failure (same as build.json)
AGC graphics: image_sample_lz through the S# that holds the LOD at 0 with T# MIN_LOD 768 ... thread 0 component 1 is 0.000000, expected 0.062500

Previous findings

  • Blocking 1, sceKernelOpen link checks on the plain path: Resolved. core/libs/prx/libkernel/File/src/Open.cpp:235-255 uses openPath for status, both GetFileAttributesW calls, is_symlink and ReadJunction. The LongNoFollow case expects 0x8002001F for a junction past MAX_PATH. I checked this in source. The Windows run and negative control are BunnyFl's and the author's reports.
  • Blocking 2, APR end-of-file file_size on the plain path: Resolved. core/libs/prx/libkernel/Apr/src/Apr.cpp:165-188 uses hostPath for both the stream and file_size. guest_apr_read_longeof reads 200 bytes from a 100-byte long-path file and checks the zero fill and the guard bytes. Its Windows result is author-reported.
  • Non-blocking 1, APR size lookup and stat: Resolved. Apr.cpp:79 and Apr.cpp:106 extend the path. FillFileStat goes through NativeMetadataPath → WindowsNormalizedPath (Open.cpp:120-121), and the debt entry names the size lookup and the end-of-file check.
  • Non-blocking 2, dead #ifdef in Load: Resolved. The non-Windows loop now has only the DirectoryEntryType line.
  • Non-blocking 3, UNC .. under the share: Resolved. WindowsExtendedPath.hpp:20-28 normalizes only the part after \\server\share, and windows_extended_path has the \\server\share\..\file.bin case.

New findings

Blocking

None.

Non-blocking

  1. APR directory listing at the MAX_PATH boundary (core/libs/prx/libkernel/Apr/src/Apr.cpp:79).
    • The listing extends path.parent_path() first and appends \* afterwards. This is the boundary case mashingaan found in ListDirectoryEntries, which the PR already fixed there.
    • For a parent of 258 or 259 characters, WindowsExtendedPath leaves the parent unchanged and the search pattern reaches 260. FindFirstFileExW then fails, and an empty size map is cached for that directory.
    • Results stay correct, because each file then falls back to is_regular_file + FillFileStat on the extended path. But every file in such a directory pays a separate stat.
    • Suggested fix: File::WindowsExtendedPath(path.parent_path() / L"*"), as DirectoryDescriptor.cpp:145 does.

Not verified

  • Linux negative control: I did not repeat it. On Linux the helper returns the path unchanged, so a Linux run cannot fail. My previous review showed this.
  • AGC failure check: I tried to confirm it with main's production files, but the sandbox stopped the build: CMake's regeneration fails with Operation not permitted in SDL2's configure_file. That attribution rests on the main history and on the Linux no-op argument above. The worktree is back at the merged tree (git status --porcelain is empty), but the build tree's build.ninja is now marked for regeneration.
  • Windows: nothing was compiled or run on Windows here. The Windows tests and the Windows negative controls are from BunnyFl's and the author's runs.
  • Title run: the PPSA04132 reproduction was not run (Windows-only, and this review does not launch titles).
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5744975710 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5744975710). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-02T23:37:57Z. **Review:** APPROVED --- # Re-checked — approved Both blocking findings from my last review are fixed. Commit `67c3f5e7b9` puts the `sceKernelOpen` link checks and the APR end-of-file `file_size` call on the extended path and adds `LongNoFollow` and `guest_apr_read_longeof`. Commit `a5be6b2720` moves the helper include out of the `#ifdef _WIN32` block, so the Linux build works again. The two failures the bot reported come from `main`, not from this PR. ## What changed since my last review I last reviewed `fa00e458e6`. Since then: - **`67c3f5e7b9`:** `OpenNative` now computes `openPath` once and uses it for the `O_DIRECTORY` status check, the `O_CREAT|O_EXCL` reparse-point check and the `O_NOFOLLOW` checks. `_readFile` uses one `hostPath` for the stream and for `file_size`. `_fileSize` extends the parent directory before listing it and extends the path in its `is_regular_file` fallback. The unreachable `#ifdef` in `Load` is gone. UNC normalization now keeps `\\server\share` as the root. - **New tests:** `LongNoFollow` in `GuestWindowsDirectoryLinkTypes.cpp`, `guest_apr_read_longeof`, and a `\\server\share\..\file.bin` case in `windows_extended_path`. - **`a5be6b2720`:** the `WindowsExtendedPath.hpp` include in `Open.cpp` sits above the `#ifdef _WIN32` block. This fixes the Linux build error reported by oneandonlydean. - **Rebases:** the branch was rebased onto newer `main`. The range-diff shows only context changes in the earlier commits. - **Other reviews:** BunnyFl approved and reported a Windows run: 15/15 pass, and with `main`'s production files `guest_filesystem` aborts. ## What I ran Head `a5be6b2720c0af77b3324523f07af18b8c870793`, `main` `5cb015caaaaf83f8ee431414ee6a457b5b307d49`, merged tree `766baa0fe992b51a75c8c6b93fc766ee0297cf94` (Linux, GCC 14.2.0, Release, Ninja). ```sh git diff --check 5cb015caaaaf83f8ee431414ee6a457b5b307d49...a5be6b2720c0af77b3324523f07af18b8c870793 python3 tools/check_conventions.py --base 5cb015caaaaf83f8ee431414ee6a457b5b307d49 ctest --test-dir build --output-on-failure --repeat until-fail:3 \ -R '^(agc_driver_image_sample_lod_clamp_shader_lane|unwrap_self_UnwrapTest_test_new_output_inherits_the_destination_directory_group|guest_filesystem|guest_apr_read_.*)$' # attempted negative control: Apr.cpp, DirectoryDescriptor.cpp, Open.cpp, libkernel CMakeLists.txt from main git show 5cb015caaa:<path> > <path> ninja -C build -j32 -l32 libkernel agc_driver_image_sample_lod_clamp_tests guest_filesystem_tests guest_apr_read_tests git show 766baa0fe9:<path> > <path> git status --porcelain git log --oneline 096c45570f..5cb015caaa -- core/libs/prx/libSceAgcDriver core/shader tools/unwrap_self.py tools/tests/test_unwrap_self.py ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Build (script) | configure, build and `libs` OK | | `guest_filesystem`, the 7 Linux `guest_apr_read_*` cases | pass, 3 repeats each | | `agc_driver_image_sample_lod_clamp_shader_lane` | fails every time; comes from `main` (see below) | | `unwrap_self_..._destination_directory_group` | fails (`os.chown` → `EINVAL` in the sandbox); comes from `main` (see below) | | `windows_extended_path`, `guest_windows_directory_link_types`, `guest_apr_read_longeof` | not built here (Windows-only) | **The two new failures come from `main`:** - The failure baseline is from `096c45570f`, which is older than `main`. Since then `main` merged `4e2a028e43 fix(agc): bind a T# minimum LOD through an S# that holds the LOD at 0` (#12980) and new unwrap test cases (#14558). Those are the two failing tests. - On Linux the PR changes nothing at run time: `WindowsExtendedPath` returns its input unchanged when `_WIN32` is not defined. Every other changed line in `Apr.cpp`, `Open.cpp` and `DirectoryDescriptor.cpp` is inside `_WIN32` code or goes through that helper. - The unwrap test is a Python test of `tools/`, which this PR does not touch. - I tried to confirm the AGC failure by rebuilding with `main`'s production files, but could not (see Not verified). <details><summary>AGC failure (same as build.json)</summary> ``` AGC graphics: image_sample_lz through the S# that holds the LOD at 0 with T# MIN_LOD 768 ... thread 0 component 1 is 0.000000, expected 0.062500 ``` </details> ## Previous findings - **Blocking 1, `sceKernelOpen` link checks on the plain path: Resolved.** `core/libs/prx/libkernel/File/src/Open.cpp:235-255` uses `openPath` for `status`, both `GetFileAttributesW` calls, `is_symlink` and `ReadJunction`. The `LongNoFollow` case expects `0x8002001F` for a junction past `MAX_PATH`. I checked this in source. The Windows run and negative control are BunnyFl's and the author's reports. - **Blocking 2, APR end-of-file `file_size` on the plain path: Resolved.** `core/libs/prx/libkernel/Apr/src/Apr.cpp:165-188` uses `hostPath` for both the stream and `file_size`. `guest_apr_read_longeof` reads 200 bytes from a 100-byte long-path file and checks the zero fill and the guard bytes. Its Windows result is author-reported. - **Non-blocking 1, APR size lookup and stat: Resolved.** `Apr.cpp:79` and `Apr.cpp:106` extend the path. `FillFileStat` goes through `NativeMetadataPath` → `WindowsNormalizedPath` (`Open.cpp:120-121`), and the debt entry names the size lookup and the end-of-file check. - **Non-blocking 2, dead `#ifdef` in `Load`: Resolved.** The non-Windows loop now has only the `DirectoryEntryType` line. - **Non-blocking 3, UNC `..` under the share: Resolved.** `WindowsExtendedPath.hpp:20-28` normalizes only the part after `\\server\share`, and `windows_extended_path` has the `\\server\share\..\file.bin` case. ## New findings ### Blocking None. ### Non-blocking 1. **APR directory listing at the `MAX_PATH` boundary** (`core/libs/prx/libkernel/Apr/src/Apr.cpp:79`). - The listing extends `path.parent_path()` first and appends `\*` afterwards. This is the boundary case mashingaan found in `ListDirectoryEntries`, which the PR already fixed there. - For a parent of 258 or 259 characters, `WindowsExtendedPath` leaves the parent unchanged and the search pattern reaches 260. `FindFirstFileExW` then fails, and an empty size map is cached for that directory. - Results stay correct, because each file then falls back to `is_regular_file` + `FillFileStat` on the extended path. But every file in such a directory pays a separate stat. - Suggested fix: `File::WindowsExtendedPath(path.parent_path() / L"*")`, as `DirectoryDescriptor.cpp:145` does. ## Not verified - **Linux negative control:** I did not repeat it. On Linux the helper returns the path unchanged, so a Linux run cannot fail. My previous review showed this. - **AGC failure check:** I tried to confirm it with `main`'s production files, but the sandbox stopped the build: CMake's regeneration fails with `Operation not permitted` in SDL2's `configure_file`. That attribution rests on the `main` history and on the Linux no-op argument above. The worktree is back at the merged tree (`git status --porcelain` is empty), but the build tree's `build.ninja` is now marked for regeneration. - **Windows:** nothing was compiled or run on Windows here. The Windows tests and the Windows negative controls are from BunnyFl's and the author's runs. - **Title run:** the PPSA04132 reproduction was not run (Windows-only, and this review does not launch titles). <!-- anyps5-bots job=2871 head=a5be6b2720c0af77b3324523f07af18b8c870793 -->
XairRrR commented 2026-11-03 14:28:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T14:28:56Z.

Review: APPROVED


Re-checked — approved

The branch was rewritten as one commit, 61546e6932, on top of main 4f41f4c375. It removes WindowsExtendedPath.hpp and its test and calls #12560's NativeVerbatimPath_nid_no_patch instead. It keeps the APR, directory-listing, /app0-root and O_NOFOLLOW fixes and their tests. The diff check, the conventions check and the affected Linux tests pass, and I found nothing blocking.

What changed since my last review

I last reviewed a5be6b2720. Since then:

  • Rewrite onto the shared helper. oneandonlydean asked for this after #12560 was merged. File::WindowsExtendedPath / WindowsNormalizedPath and the windows_extended_path test are gone. The debt entry the earlier head added is gone too. main has no long-path entry in docs/dev/debt/libkernel.md, so nothing is left stale.
  • Apr.cpp: a new _hostPath (verbatim path, or the plain path if the helper returns an error) is used for the parent listing, the is_regular_file fallback, the stream and the end-of-file file_size.
  • DirectoryDescriptor.cpp:
    • HostPath does the same job.
    • InsideApp0 opens the root through it.
    • ListDirectoryEntries (FindFirstFileExW) builds the verbatim pattern from the complete directory / L"*".
    • Load stats the directory, its parent and each entry through verbatim paths.
    • OpenDirectoryDescriptor checks is_directory on the verbatim path.
  • Open.cpp: the O_NOFOLLOW is_symlink check uses openNative on Windows. The directory fallback after a failed open goes through NativeMetadataPath.
  • Tests: these are the same as before: guest_apr_read_longeof, the LongApp0Root, LongNoFollow and SearchPatternAtMaxPath cases in GuestWindowsDirectoryLinkTypes.cpp, and the long-path open and getdents checks in GuestFilesystem.cpp. All of them are Windows-only.
  • Windows results in the description are author-reported. On this head:
    • The APR, link-type, filesystem and directory-entry tests pass.
    • long_paths, guest_directory, guest_filesystem_error and agc_pipeline_journal_long_paths were not conclusive or not run. The author says antivirus blocked them.
    • The title was not retested.

What I ran

Head 61546e69320d5ecca1851f3c5a9f4298c590e4d1, main 4f41f4c375f5abb487dbd184fbc150f31994d762, merged tree a25d61afe035f9a511cfb1512ab077e7b3bc37ad (Linux, GCC 14.2.0, Release, Ninja).

git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...61546e69320d5ecca1851f3c5a9f4298c590e4d1
python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R '^(guest_filesystem|guest_apr_read_.*|guest_directory.*)$'
git status --porcelain
Check Result
git diff --check clean
check_conventions.py All conventions checks passed.
Build (script) configure, build and libs OK
Script test run 0 new failures, 0 timeouts; the 9 known failures also fail on main (baseline is main_sha)
guest_filesystem, 7 Linux guest_apr_read_*, guest_directory, guest_directory_entries, guest_directory_link_types 10/10 pass
Windows-only tests (guest_apr_read_longeof, guest_windows_directory_link_types, the long-path part of guest_filesystem) not built here

Negative control

None on this machine. All new and changed test code is inside #ifdef _WIN32 (TestLongHostPathStat sits in the _WIN32 block of GuestFilesystem.cpp, longeof is only registered on WIN32, and GuestWindowsDirectoryLinkTypes.cpp is Windows-only). On Linux the production change does nothing at run time: NativeVerbatimPath_nid_no_patch returns its input when _WIN32 is not defined (core/libs/prx/libc/include/WindowsVerbatimPath.hpp:257-262), and the rest of the changed code is in _WIN32 branches. So no Linux run can fail with main's production files. The Windows negative controls come from earlier heads: the author's and BunnyFl's runs, against code that was functionally the same. Nobody has repeated them on this head.

Previous findings

  • Non-blocking 1, APR directory listing at the MAX_PATH boundary: Resolved. core/libs/prx/libkernel/Apr/src/Apr.cpp:86 still extends the parent before it appends \*. But the shared helper switches to the verbatim form from 248 characters (WindowsMaxDirectoryPathLength, WindowsVerbatimPath.hpp:12,252). So a parent left unprefixed is at most 247 characters, and its \* pattern stays at or below 249, under 260. The boundary case can no longer happen.

The two blocking findings from my earlier review (the link checks in sceKernelOpen, and the APR end-of-file file_size) were resolved at a5be6b2720. The rewrite keeps both fixes:

  • Open.cpp:243-257 uses openNative for the GetFileAttributesW, is_symlink and ReadJunction checks.
  • Apr.cpp:172 uses one hostPath for the stream and for file_size.

New findings

Blocking

None.

Non-blocking

  1. Two copies of the same wrapper. _hostPath (core/libs/prx/libkernel/Apr/src/Apr.cpp:70-74) and HostPath (core/libs/prx/libkernel/File/src/DirectoryDescriptor.cpp:42-50) both do "verbatim path, or the input on error". Open.cpp:235-237 and OpenPlaceholder (DirectoryDescriptor.cpp:271-273) write the same thing inline. This could become one helper next to NativeVerbatimPath_nid_no_patch, in this PR or a follow-up. The #ifdef in HostPath is also unneeded, because the helper already has a non-Windows overload.
  2. The new test cases leak on failure. LongApp0Root, LongNoFollow and SearchPatternAtMaxPath (core/libs/tests/GuestWindowsDirectoryLinkTypes.cpp) and TestLongEof remove their directories only on the success path. LongApp0Root also leaves the /app0 alias in place if Types throws. Each run uses a fresh steady_clock name, so a failed run only leaves directories behind in the build tree. A small RAII guard, like the one the earlier windows_extended_path test had, would clean them up.
  3. Checklist format. Unblocks: PPSA04132 has no Game bring-up discussion number. CONTRIBUTING asks for the form Unblocks: PPSA01325 #3232. Please add the discussion, if one exists.

Not verified

  • Windows: nothing was compiled or run on Windows here. The Windows results on this head are the author's report and are partial, as the description says.
  • Windows negative control: not repeated on this head (see above).
  • Title run: the PPSA04132 reproduction was not run. It is Windows-only, and this review does not launch titles.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5753913040 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5753913040). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T14:28:56Z. **Review:** APPROVED --- # Re-checked — approved The branch was rewritten as one commit, `61546e6932`, on top of `main` `4f41f4c375`. It removes `WindowsExtendedPath.hpp` and its test and calls #12560's `NativeVerbatimPath_nid_no_patch` instead. It keeps the APR, directory-listing, `/app0`-root and `O_NOFOLLOW` fixes and their tests. The diff check, the conventions check and the affected Linux tests pass, and I found nothing blocking. ## What changed since my last review I last reviewed `a5be6b2720`. Since then: - **Rewrite onto the shared helper.** oneandonlydean asked for this after #12560 was merged. `File::WindowsExtendedPath` / `WindowsNormalizedPath` and the `windows_extended_path` test are gone. The debt entry the earlier head added is gone too. `main` has no long-path entry in `docs/dev/debt/libkernel.md`, so nothing is left stale. - **`Apr.cpp`:** a new `_hostPath` (verbatim path, or the plain path if the helper returns an error) is used for the parent listing, the `is_regular_file` fallback, the stream and the end-of-file `file_size`. - **`DirectoryDescriptor.cpp`:** - `HostPath` does the same job. - `InsideApp0` opens the root through it. - `ListDirectoryEntries` (`FindFirstFileExW`) builds the verbatim pattern from the complete `directory / L"*"`. - `Load` stats the directory, its parent and each entry through verbatim paths. - `OpenDirectoryDescriptor` checks `is_directory` on the verbatim path. - **`Open.cpp`:** the `O_NOFOLLOW` `is_symlink` check uses `openNative` on Windows. The directory fallback after a failed open goes through `NativeMetadataPath`. - **Tests:** these are the same as before: `guest_apr_read_longeof`, the `LongApp0Root`, `LongNoFollow` and `SearchPatternAtMaxPath` cases in `GuestWindowsDirectoryLinkTypes.cpp`, and the long-path open and `getdents` checks in `GuestFilesystem.cpp`. All of them are Windows-only. - **Windows results in the description are author-reported.** On this head: - The APR, link-type, filesystem and directory-entry tests pass. - `long_paths`, `guest_directory`, `guest_filesystem_error` and `agc_pipeline_journal_long_paths` were not conclusive or not run. The author says antivirus blocked them. - The title was not retested. ## What I ran Head `61546e69320d5ecca1851f3c5a9f4298c590e4d1`, `main` `4f41f4c375f5abb487dbd184fbc150f31994d762`, merged tree `a25d61afe035f9a511cfb1512ab077e7b3bc37ad` (Linux, GCC 14.2.0, Release, Ninja). ```sh git diff --check 4f41f4c375f5abb487dbd184fbc150f31994d762...61546e69320d5ecca1851f3c5a9f4298c590e4d1 python3 tools/check_conventions.py --base 4f41f4c375f5abb487dbd184fbc150f31994d762 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R '^(guest_filesystem|guest_apr_read_.*|guest_directory.*)$' git status --porcelain ``` | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Build (script) | configure, build and `libs` OK | | Script test run | 0 new failures, 0 timeouts; the 9 known failures also fail on `main` (baseline is `main_sha`) | | `guest_filesystem`, 7 Linux `guest_apr_read_*`, `guest_directory`, `guest_directory_entries`, `guest_directory_link_types` | 10/10 pass | | Windows-only tests (`guest_apr_read_longeof`, `guest_windows_directory_link_types`, the long-path part of `guest_filesystem`) | not built here | ## Negative control None on this machine. All new and changed test code is inside `#ifdef _WIN32` (`TestLongHostPathStat` sits in the `_WIN32` block of `GuestFilesystem.cpp`, `longeof` is only registered on `WIN32`, and `GuestWindowsDirectoryLinkTypes.cpp` is Windows-only). On Linux the production change does nothing at run time: `NativeVerbatimPath_nid_no_patch` returns its input when `_WIN32` is not defined (`core/libs/prx/libc/include/WindowsVerbatimPath.hpp:257-262`), and the rest of the changed code is in `_WIN32` branches. So no Linux run can fail with `main`'s production files. The Windows negative controls come from earlier heads: the author's and BunnyFl's runs, against code that was functionally the same. Nobody has repeated them on this head. ## Previous findings - **Non-blocking 1, APR directory listing at the `MAX_PATH` boundary: Resolved.** `core/libs/prx/libkernel/Apr/src/Apr.cpp:86` still extends the parent before it appends `\*`. But the shared helper switches to the verbatim form from 248 characters (`WindowsMaxDirectoryPathLength`, `WindowsVerbatimPath.hpp:12,252`). So a parent left unprefixed is at most 247 characters, and its `\*` pattern stays at or below 249, under 260. The boundary case can no longer happen. The two blocking findings from my earlier review (the link checks in `sceKernelOpen`, and the APR end-of-file `file_size`) were resolved at `a5be6b2720`. The rewrite keeps both fixes: - `Open.cpp:243-257` uses `openNative` for the `GetFileAttributesW`, `is_symlink` and `ReadJunction` checks. - `Apr.cpp:172` uses one `hostPath` for the stream and for `file_size`. ## New findings ### Blocking None. ### Non-blocking 1. **Two copies of the same wrapper.** `_hostPath` (`core/libs/prx/libkernel/Apr/src/Apr.cpp:70-74`) and `HostPath` (`core/libs/prx/libkernel/File/src/DirectoryDescriptor.cpp:42-50`) both do "verbatim path, or the input on error". `Open.cpp:235-237` and `OpenPlaceholder` (`DirectoryDescriptor.cpp:271-273`) write the same thing inline. This could become one helper next to `NativeVerbatimPath_nid_no_patch`, in this PR or a follow-up. The `#ifdef` in `HostPath` is also unneeded, because the helper already has a non-Windows overload. 2. **The new test cases leak on failure.** `LongApp0Root`, `LongNoFollow` and `SearchPatternAtMaxPath` (`core/libs/tests/GuestWindowsDirectoryLinkTypes.cpp`) and `TestLongEof` remove their directories only on the success path. `LongApp0Root` also leaves the `/app0` alias in place if `Types` throws. Each run uses a fresh `steady_clock` name, so a failed run only leaves directories behind in the build tree. A small RAII guard, like the one the earlier `windows_extended_path` test had, would clean them up. 3. **Checklist format.** `Unblocks: PPSA04132` has no Game bring-up discussion number. CONTRIBUTING asks for the form `Unblocks: PPSA01325 #3232`. Please add the discussion, if one exists. ## Not verified - **Windows:** nothing was compiled or run on Windows here. The Windows results on this head are the author's report and are partial, as the description says. - **Windows negative control:** not repeated on this head (see above). - **Title run:** the PPSA04132 reproduction was not run. It is Windows-only, and this review does not launch titles. <!-- anyps5-bots job=3378 head=61546e69320d5ecca1851f3c5a9f4298c590e4d1 -->
BunnyFl commented 2026-11-03 14:44:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T14:44:57Z.

Review: APPROVED


Re-approving at 61546e6932, the one-commit rewrite onto main 4f41f4c375. My earlier approval was for a5be6b2720. This head is a new implementation, and I read the whole diff again rather than a delta.

What I read

  • The new _hostPath / HostPath helpers in Apr.cpp and DirectoryDescriptor.cpp call NativeVerbatimPath_nid_no_patch (core/libs/prx/libc/include/WindowsVerbatimPath.hpp:241) and keeps the plain path when it returns an error. The helper returns \\?\ and \\.\ paths unchanged (core/libs/prx/libc/include/WindowsVerbatimPath.hpp:247), so ListDirectoryEntries can pass an already verbatim directory back through HostPath without doubling the prefix. Outside Windows it returns the path as given (core/libs/prx/libc/include/WindowsVerbatimPath.hpp:257-262), so the unguarded _hostPath in Apr.cpp is a no-op on Linux and macOS.
  • The verbatim entry paths that Load passes to FillLinkStat / TryFillFileStat are safe: NativeStatPath in NativeStat.cpp leaves \\?\ paths as they are.
  • InsideApp0 only changes how the /app0 root is opened. The component comparison against the guest directory is unchanged.
  • In Open.cpp, the Windows O_NOFOLLOW check now tests openNative, the path the open itself uses. The directory fallback stats through NativeMetadataPath, falling back to the plain path on error, like the metadata paths above it. Non-Windows code is unchanged.
  • The Windows listing in Load throws on any FindFirstFileExW / FindNextFileW error except ERROR_FILE_NOT_FOUND and ERROR_NO_MORE_FILES, like the directory_iterator loop it replaces.

What I ran (Windows 11, WinLibs GCC 15.2.0, Release, this head merged onto 4f41f4c375): 16 tests (guest_apr_read_* including longeof, guest_filesystem, guest_directory, guest_directory_entries, guest_windows_directory_link_types, long_paths, agc_pipeline_journal_long_paths, agc_shader_disk_cache_long_paths): 16/16 pass.

Negative control: the same tests with Apr.cpp, DirectoryDescriptor.cpp and Open.cpp taken from main: 3 of 16 fail, all in the new cases.

  • guest_apr_read_longeof
  • guest_filesystem: "Filesystem check failed at line 392 (guest errno 13, Win32 error 3)", the long /long-stat-host/ directory open.
  • guest_windows_directory_link_types: line 120, the directory open in Types().

One limit of this run: the link-type test printed "Symbolic-link cases require Windows developer mode or symbolic-link privilege; junction cases still run". Its symbolic-link cases did not run here; the junction cases did.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5754202699 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5754202699). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-03T14:44:57Z. **Review:** APPROVED --- Re-approving at `61546e6932`, the one-commit rewrite onto `main` `4f41f4c375`. My earlier approval was for `a5be6b2720`. This head is a new implementation, and I read the whole diff again rather than a delta. **What I read** - The new `_hostPath` / `HostPath` helpers in `Apr.cpp` and `DirectoryDescriptor.cpp` call `NativeVerbatimPath_nid_no_patch` (`core/libs/prx/libc/include/WindowsVerbatimPath.hpp:241`) and keeps the plain path when it returns an error. The helper returns `\\?\` and `\\.\` paths unchanged (`core/libs/prx/libc/include/WindowsVerbatimPath.hpp:247`), so `ListDirectoryEntries` can pass an already verbatim directory back through `HostPath` without doubling the prefix. Outside Windows it returns the path as given (`core/libs/prx/libc/include/WindowsVerbatimPath.hpp:257-262`), so the unguarded `_hostPath` in `Apr.cpp` is a no-op on Linux and macOS. - The verbatim entry paths that `Load` passes to `FillLinkStat` / `TryFillFileStat` are safe: `NativeStatPath` in `NativeStat.cpp` leaves `\\?\` paths as they are. - `InsideApp0` only changes how the `/app0` root is opened. The component comparison against the guest directory is unchanged. - In `Open.cpp`, the Windows `O_NOFOLLOW` check now tests `openNative`, the path the open itself uses. The directory fallback stats through `NativeMetadataPath`, falling back to the plain path on error, like the metadata paths above it. Non-Windows code is unchanged. - The Windows listing in `Load` throws on any `FindFirstFileExW` / `FindNextFileW` error except `ERROR_FILE_NOT_FOUND` and `ERROR_NO_MORE_FILES`, like the `directory_iterator` loop it replaces. **What I ran** (Windows 11, WinLibs GCC 15.2.0, Release, this head merged onto `4f41f4c375`): 16 tests (`guest_apr_read_*` including `longeof`, `guest_filesystem`, `guest_directory`, `guest_directory_entries`, `guest_windows_directory_link_types`, `long_paths`, `agc_pipeline_journal_long_paths`, `agc_shader_disk_cache_long_paths`): 16/16 pass. **Negative control:** the same tests with `Apr.cpp`, `DirectoryDescriptor.cpp` and `Open.cpp` taken from `main`: 3 of 16 fail, all in the new cases. - `guest_apr_read_longeof` - `guest_filesystem`: "Filesystem check failed at line 392 (guest errno 13, Win32 error 3)", the long `/long-stat-host/` directory open. - `guest_windows_directory_link_types`: line 120, the directory open in `Types()`. One limit of this run: the link-type test printed "Symbolic-link cases require Windows developer mode or symbolic-link privilege; junction cases still run". Its symbolic-link cases did not run here; the junction cases did.
Superseabas commented 2026-11-07 16:40:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-07T16:40:16Z.

Review: APPROVED


Windows check of the rebased head 2a234fd995, merged onto main 090f57166a (clean merge). The two approvals are on 61546e6932, so this covers the rebase, including the DirectoryDescriptor.cpp resolution against #12139, and the tests the description couldn't run.

Setup: Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (x86_64-ucrt-posix-seh, r3), Release, BUILD_TESTING=ON. Run from PowerShell. This machine has LongPathsEnabled = 1, which matters for one test (below).

Non-GPU suite (ctest -E '^agc|gpu|vulkan|video_out' -j 8):

result
main 3005 / 3007
this PR 3005 / 3008
  • select_tests_MissingCommandTests (symlink privilege) and configure_seed_stdout (cmake without -G picks NMake) fail on main too.
  • The PR run's third failure, loadexec_arguments, is Windows Defender. It quarantined the test's relinked executables in %TEMP%\anyps5-loadexec-* (WinError 225 … contains a virus or potentially unwanted software). After that, main failed it 5 of 5 with the same error, so it isn't this change.

File-path tests, 28 of them (-R 'apr_read|guest_.*filesystem|guest_directory|long_path|link_types|working_directory'), 5 runs: 28 / 28 each time. That includes the ones the description lists as not run or not conclusive: long_paths, guest_directory, guest_filesystem_error and agc_pipeline_journal_long_paths, as well as guest_apr_read_longeof, guest_windows_directory_link_types and agc_shader_disk_cache_long_paths. guest_directory_removed_entries (#12139's test) passes in all 5 runs, so the rebase kept its rule. The new Windows listing still skips an entry whose FillLinkStat gives ENOENT.

Red check, with main's Apr.cpp, DirectoryDescriptor.cpp and Open.cpp and the PR's tests kept, 3 runs:

  • guest_filesystem fails at the long-directory sceKernelGetdents listing (Require(longNames == {".", "..", "payload.bin"})), 3 of 3.
  • guest_windows_directory_link_types fails at Require(app0.at("packed") == 4), the junction under a long /app0 root, 3 of 3.
  • guest_apr_read_longeof passes with main's Apr.cpp. The test executables embed <longPathAware>true</longPathAware>, and with LongPathsEnabled = 1 Windows accepts the plain long path, so on this machine the old APR reader succeeds and the test can't fail. On a default install (LongPathsEnabled = 0) it should fail as described. I didn't change the setting, so the APR part of the fix is unchecked here.

tools/check_conventions.py --base main passes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5813702150 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5813702150). Originally posted by [Superseabas](https://github.com/Superseabas) on 2026-11-07T16:40:16Z. **Review:** APPROVED --- Windows check of the rebased head `2a234fd995`, merged onto `main` `090f57166a` (clean merge). The two approvals are on `61546e6932`, so this covers the rebase, including the `DirectoryDescriptor.cpp` resolution against #12139, and the tests the description couldn't run. **Setup:** Windows 11 Home 10.0.26200, Ryzen 7 7700X, WinLibs GCC 16.2.0 (`x86_64-ucrt-posix-seh`, r3), Release, `BUILD_TESTING=ON`. Run from PowerShell. This machine has `LongPathsEnabled = 1`, which matters for one test (below). **Non-GPU suite** (`ctest -E '^agc|gpu|vulkan|video_out' -j 8`): | | result | |---|---| | `main` | 3005 / 3007 | | this PR | 3005 / 3008 | - `select_tests_MissingCommandTests` (symlink privilege) and `configure_seed_stdout` (`cmake` without `-G` picks NMake) fail on `main` too. - The PR run's third failure, `loadexec_arguments`, is Windows Defender. It quarantined the test's relinked executables in `%TEMP%\anyps5-loadexec-*` (`WinError 225 … contains a virus or potentially unwanted software`). After that, `main` failed it 5 of 5 with the same error, so it isn't this change. **File-path tests**, 28 of them (`-R 'apr_read|guest_.*filesystem|guest_directory|long_path|link_types|working_directory'`), 5 runs: 28 / 28 each time. That includes the ones the description lists as not run or not conclusive: `long_paths`, `guest_directory`, `guest_filesystem_error` and `agc_pipeline_journal_long_paths`, as well as `guest_apr_read_longeof`, `guest_windows_directory_link_types` and `agc_shader_disk_cache_long_paths`. `guest_directory_removed_entries` (#12139's test) passes in all 5 runs, so the rebase kept its rule. The new Windows listing still skips an entry whose `FillLinkStat` gives `ENOENT`. **Red check**, with `main`'s `Apr.cpp`, `DirectoryDescriptor.cpp` and `Open.cpp` and the PR's tests kept, 3 runs: - `guest_filesystem` fails at the long-directory `sceKernelGetdents` listing (`Require(longNames == {".", "..", "payload.bin"})`), 3 of 3. - `guest_windows_directory_link_types` fails at `Require(app0.at("packed") == 4)`, the junction under a long `/app0` root, 3 of 3. - `guest_apr_read_longeof` **passes** with `main`'s `Apr.cpp`. The test executables embed `<longPathAware>true</longPathAware>`, and with `LongPathsEnabled = 1` Windows accepts the plain long path, so on this machine the old APR reader succeeds and the test can't fail. On a default install (`LongPathsEnabled = 0`) it should fail as described. I didn't change the setting, so the APR part of the fix is unchecked here. `tools/check_conventions.py --base main` passes.
gabichuuuuu commented 2026-11-08 02:03:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T02:03:36Z.

Review: COMMENTED


Windows check of head 2a234fd995, merged onto main 676fb61acc (clean merge). It covers the APR part that the last review couldn't check.

Setup: Windows 11, WinLibs GCC 15.2 (x86_64-ucrt-posix-seh), Release, full build with BUILD_TESTING=ON. LongPathsEnabled = 1, but this toolchain doesn't embed longPathAware in the test executables (guest_apr_read_tests.exe and guest_windows_directory_link_types_tests.exe don't contain the string), so a plain long path fails here as it would on a default install.

File-path tests (-R 'guest_apr_read_|^guest_filesystem|guest_windows_directory_link_types|^guest_directory', 19 tests): 18 / 19. guest_filesystem gets through the new long-directory read and listing in TestLongHostPathStat and then aborts later, in a check this PR doesn't touch (below).

Red check, with main's Apr.cpp, DirectoryDescriptor.cpp and Open.cpp and the PR's tests kept: 16 / 19.

  • guest_apr_read_longeof fails: cannot resolve the long path APR file. So the Apr.cpp change is what makes the long-path APR read work without the manifest.
  • guest_windows_directory_link_types fails opening /app0 under the long root (0x8002000D).
  • guest_filesystem fails at line 411, opening the long directory for sceKernelGetdents (guest errno 13, Win32 error 3).

Unrelated failure: guest_filesystem aborts in the third-party reparse tag check (tagged.bin, tag 0xABC) with std::system_error: lstat: CreateFileW: The file cannot be accessed by the system. main's sources and tests do the same, 2 of 2 runs. This user can set the reparse point, so the check runs instead of being skipped, and lstat throws instead of returning an error. That is a main issue, not this change.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5816041370 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9947#pullrequestreview-5816041370). Originally posted by [gabichuuuuu](https://github.com/gabichuuuuu) on 2026-11-08T02:03:36Z. **Review:** COMMENTED --- Windows check of head `2a234fd995`, merged onto `main` `676fb61acc` (clean merge). It covers the APR part that the last review couldn't check. **Setup:** Windows 11, WinLibs GCC 15.2 (`x86_64-ucrt-posix-seh`), Release, full build with `BUILD_TESTING=ON`. `LongPathsEnabled = 1`, but this toolchain doesn't embed `longPathAware` in the test executables (`guest_apr_read_tests.exe` and `guest_windows_directory_link_types_tests.exe` don't contain the string), so a plain long path fails here as it would on a default install. **File-path tests** (`-R 'guest_apr_read_|^guest_filesystem|guest_windows_directory_link_types|^guest_directory'`, 19 tests): 18 / 19. `guest_filesystem` gets through the new long-directory read and listing in `TestLongHostPathStat` and then aborts later, in a check this PR doesn't touch (below). **Red check**, with `main`'s `Apr.cpp`, `DirectoryDescriptor.cpp` and `Open.cpp` and the PR's tests kept: 16 / 19. - `guest_apr_read_longeof` fails: `cannot resolve the long path APR file`. So the `Apr.cpp` change is what makes the long-path APR read work without the manifest. - `guest_windows_directory_link_types` fails opening `/app0` under the long root (`0x8002000D`). - `guest_filesystem` fails at line 411, opening the long directory for `sceKernelGetdents` (guest errno 13, Win32 error 3). **Unrelated failure:** `guest_filesystem` aborts in the third-party reparse tag check (`tagged.bin`, tag `0xABC`) with `std::system_error`: `lstat: CreateFileW: The file cannot be accessed by the system`. `main`'s sources and tests do the same, 2 of 2 runs. This user can set the reparse point, so the check runs instead of being skipped, and `lstat` throws instead of returning an error. That is a `main` issue, not this change.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!9947
No description provided.