Windows sceKernelStat returns ENOENT for an existing file under a long host path (PPSA99902) #7195

Closed
opened 2026-10-17 15:45:03 +00:00 by Amoenus · 0 comments
Amoenus commented 2026-10-17 15:45:03 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-17T15:45:03Z.


Failure

A valid short guest path can return 0x80020002 (ENOENT) from sceKernelStat on Windows when its resolved host filename exceeds MAX_PATH. The host file exists. This is separate from fopen's native open correction in #7182 / #7187.

Found while validating Sonic Unleashed Recompiled, PPSA99902 (#3036, discussion #4443): the existing WorldMap.arl has a 266-character resolved host path and is288 bytes. A control links the actual unpatched host libraries built at 3811293e76755982fda9dc0d66afd8fabe5142ae (the #7187 review follow-up). libkernel/File/src/Open.cpp and libc path resolution are byte-identical to current main f51724078f975a60c8f9985e547b6259acdcab64; git diff main..3811293 -- Open.cpp General.cpp is empty. The fopen-only changes do not alter this stat call.

Direct exported-API reproduction

Map the same short guest prefix to the parent of the same real file, first using an ordinary drive path, then the extended Unicode spelling. Call sceKernelStat on the same guest filename each time:

ordinary host root:253 characters, stat_result=0x80020002, size=0
extended host root:257 characters, stat_result=0x00000000, size=288

The leaf adds13 characters, so ordinary full path length is266. Only the host alias spelling changes; file contents and guest path remain unchanged. The control uses AddPathAlias_nid_no_patch, FileStat and the real sceKernelStat export, not a mock or symbol-presence check.

Independent same-toolchain native controls confirm the underlying lookup behavior:

ordinary full path266: std::filesystem::status exists=0/error2;
  file_size=UINT64_MAX/error2; GetFileAttributesW=INVALID/error3
extended full path270: status exists=1/error0;
  file_size=288/error0; GetFileAttributesW=32/error0

Windows11 Enterprise26200, WinLibs GCC15.2.0 r7, Release host libraries. CPU/filesystem result; no GPU attribution. The observed wrong result is unchanged-main code behavior isolated through the export; this is not a plain-main whole-title result.

Relevant implementation and overlap

core/libs/prx/libkernel/File/src/Open.cpp::sceKernelStat passes the resolved host spelling to std::filesystem::status; the failed lookup is then reported as a missing file. An extended spelling succeeds. Microsoft's Win32 namespace documentation describes long Unicode paths.

A proposed correction is to prepare a Windows native long-path spelling for the filesystem metadata operations, preserving guest/archive path identity and error behavior. MarcZX100 has implemented the ordinary-path correction in PR #7196. Our validation confirms it on the real266-character game file and with30 focused passes on each of Windows/Linux. The initial existing-namespace regression was corrected in head 28eaa5bdad25ec393110696ec94782bdcf8ea722: it now passes the same6 independent controls, and both ordinary/extended aliases return success and size288 for the actual game file. Full Windows/Linux builds and30 focused passes on each were repeated on this published head. No duplicate implementation PR is proposed. #7187 explicitly only changes fopen's native opener and does not fix this metadata path. #4618 only opted relinker.exe into long paths.

#6648 and #6942 improve ELOOP/ENAMETOOLONG translation after failed lookups. They do not make this existing266-character host file discoverable; their scope is different. They touch the same function and should be considered when preparing a fix. Searches found no existing issue/PR for this valid-file stat failure.

Game scope

An exact-runtime directory-layout control (all127 PRXs/executable/guest module/dependencies retained, fresh original assets/user data) reaches the earlier GPU stop from a short physical root: NVIDIA28.293s, resident8x DCC refusal; AMD70.664s, Vulkan device loss-4. Both last captures remain NOW LOADING. The long-root comparison reaches its120s limit. This implicates additional layout-sensitive file behavior, but does not establish this one stat call as the sole cause of the remaining loading stop. #3036 / #5336 maintain the GPU observations. No menu/gameplay/FPS claim.

AI-assisted: yes, Codex; author responsible.

Current composed title validation

Integrationc784faf893 includes #7196 head28ea and #7187cf84 on main667, with full Windows/Linux builds and51/33 focused passes. Fresh long-root game runs reach the older GPU stops: RTX5080 resident8x DCC refusal at28.656s; AMD Radeon Graphics device loss-4 at70.750s. Last captures remain NOW LOADING. All127 libraries match the build and across GPUs, standard a515 conversion retained, original inputs/configs unchanged, no timeout. The target metadata filename is274/271 characters. #3036 maintains hardware and coverage limits. The real-export controls above establish this metadata correction independently; the composed title observation does not isolate one correction or establish a common GPU cause.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5900118406 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7195). Originally posted by [Amoenus](https://github.com/Amoenus) on 2026-10-17T15:45:03Z. --- ### Failure A valid short guest path can return `0x80020002` (ENOENT) from `sceKernelStat` on Windows when its resolved host filename exceeds MAX_PATH. The host file exists. This is separate from `fopen`'s native open correction in #7182 / #7187. Found while validating Sonic Unleashed Recompiled, PPSA99902 (#3036, discussion #4443): the existing `WorldMap.arl` has a 266-character resolved host path and is288 bytes. A control links the actual unpatched host libraries built at `3811293e76755982fda9dc0d66afd8fabe5142ae` (the #7187 review follow-up). `libkernel/File/src/Open.cpp` and libc path resolution are byte-identical to current main `f51724078f975a60c8f9985e547b6259acdcab64`; `git diff main..3811293 -- Open.cpp General.cpp` is empty. The fopen-only changes do not alter this stat call. ### Direct exported-API reproduction Map the same short guest prefix to the parent of the same real file, first using an ordinary drive path, then the extended Unicode spelling. Call `sceKernelStat` on the same guest filename each time: ```text ordinary host root:253 characters, stat_result=0x80020002, size=0 extended host root:257 characters, stat_result=0x00000000, size=288 ``` The leaf adds13 characters, so ordinary full path length is266. Only the host alias spelling changes; file contents and guest path remain unchanged. The control uses `AddPathAlias_nid_no_patch`, `FileStat` and the real `sceKernelStat` export, not a mock or symbol-presence check. Independent same-toolchain native controls confirm the underlying lookup behavior: ```text ordinary full path266: std::filesystem::status exists=0/error2; file_size=UINT64_MAX/error2; GetFileAttributesW=INVALID/error3 extended full path270: status exists=1/error0; file_size=288/error0; GetFileAttributesW=32/error0 ``` Windows11 Enterprise26200, WinLibs GCC15.2.0 r7, Release host libraries. CPU/filesystem result; no GPU attribution. The observed wrong result is unchanged-main code behavior isolated through the export; this is not a plain-main whole-title result. ### Relevant implementation and overlap `core/libs/prx/libkernel/File/src/Open.cpp::sceKernelStat` passes the resolved host spelling to `std::filesystem::status`; the failed lookup is then reported as a missing file. An extended spelling succeeds. Microsoft's [Win32 namespace documentation](https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#win32-file-namespaces) describes long Unicode paths. A proposed correction is to prepare a Windows native long-path spelling for the filesystem metadata operations, preserving guest/archive path identity and error behavior. MarcZX100 has implemented the ordinary-path correction in [PR #7196](https://github.com/boykopovar/AnyPS5/pull/7196). [Our validation](https://github.com/boykopovar/AnyPS5/pull/7196#issuecomment-6236410121) confirms it on the real266-character game file and with30 focused passes on each of Windows/Linux. The initial existing-namespace regression was corrected in head `28eaa5bdad25ec393110696ec94782bdcf8ea722`: it now passes the same6 independent controls, and both ordinary/extended aliases return success and size288 for the actual game file. Full Windows/Linux builds and30 focused passes on each were repeated on this published head. No duplicate implementation PR is proposed. #7187 explicitly only changes fopen's native opener and does not fix this metadata path. #4618 only opted `relinker.exe` into long paths. #6648 and #6942 improve ELOOP/ENAMETOOLONG translation after failed lookups. They do not make this existing266-character host file discoverable; their scope is different. They touch the same function and should be considered when preparing a fix. Searches found no existing issue/PR for this valid-file stat failure. ### Game scope An exact-runtime directory-layout control (all127 PRXs/executable/guest module/dependencies retained, fresh original assets/user data) reaches the earlier GPU stop from a short physical root: NVIDIA28.293s, resident8x DCC refusal; AMD70.664s, Vulkan device loss-4. Both last captures remain NOW LOADING. The long-root comparison reaches its120s limit. This implicates additional layout-sensitive file behavior, but does not establish this one stat call as the sole cause of the remaining loading stop. #3036 / #5336 maintain the GPU observations. No menu/gameplay/FPS claim. AI-assisted: yes, Codex; author responsible. <!-- codex-stat-current-title-v1 --> ### Current composed title validation [Integrationc784faf893](https://github.com/Amoenus/AnyPS5/commit/c784faf8931422cc39c78db87eb44ffa9c35903b) includes #7196 head28ea and #7187cf84 on main667, with full Windows/Linux builds and51/33 focused passes. Fresh long-root game runs reach the older GPU stops: RTX5080 resident8x DCC refusal at28.656s; AMD Radeon Graphics device loss-4 at70.750s. Last captures remain NOW LOADING. All127 libraries match the build and across GPUs, standard a515 conversion retained, original inputs/configs unchanged, no timeout. The target metadata filename is274/271 characters. [#3036](https://github.com/boykopovar/AnyPS5/issues/3036) maintains hardware and coverage limits. The real-export controls above establish this metadata correction independently; the composed title observation does not isolate one correction or establish a common GPU cause. <!-- /codex-stat-current-title-v1 -->
Sign in to join this conversation.
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#7195
No description provided.