fix(libkernel): resolve original .prx names to relinked .guest.prx in lstat #9478

Merged
EagleBearerYS merged 4 commits from upstream-pr/9478 into main 2026-10-25 17:06:43 +00:00
EagleBearerYS commented 2026-10-21 23:01:05 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:01:05Z.


What

#4688 made stat, sceKernelStat, read-only sceKernelOpen and sceKernelCheckReachability find X.guest.prx when a title asks for X, the name the relinker replaced, and listed lstat as not covered. lstat still answers ENOENT for the same path, so code that checks for a plugin with lstat sees it missing while stat and dlopen find it.

lstat now resolves the path with the module lookup of ResolvePathError_nid_no_patch, which sceKernelStat also uses. An existing X, including a dangling symbolic link, is still reported as it is; only a missing X falls back to X.guest.prx. Since #5401 was opened, main moved that lookup from File::PathOrRelinkedModule into the resolver's module flag, so the change is now that flag.

No title is claimed.

Overlap: #7447 changes the same ResolvePathError_nid_no_patch call in lstat: it sets the resolver's archived flag and answers from File::FillArchivedStat first, where this PR sets its module flag. The two should compose as ResolvePathError_nid_no_patch(path, native, true, true), the call sceKernelCheckReachability makes on main. This PR proposed going first in #7447's thread (comment), with #7447 taking that call when it rebases. qpavyros agreed (comment): this PR first, and #7447 keeps both flags in lstat's call when it takes this PR in.

#9618 (xXPBSXx) reworks the same function: lstat fills a local FileStat and copies it out with GuestCopyOut_nid_no_patch, so it answers EFAULT when the output struct isn't writable guest memory. The two conflict only there, and compose as #9618's version of the function with this PR's module flag in its ResolvePathError_nid_no_patch call. xXPBSXx checked both orders and either works for #9618 (comment). #9618 goes first, merge order only, and this PR re-applies its one-line flag when it merges main after it.

The other PRs the overlap check lists don't touch lstat or its test, so the merge order doesn't matter for them:

  • #5021, #6879, #6936 and #7201 change other parts of Stdio.cpp, and none of them changes lstat. Merged with this PR on top of main, none of their conflicts is on the lstat line; the ones they have are with main itself.
  • #6044 moves core/libs/tests/GuestFilesystem.cpp to core/libs/tests/files/GuestFilesystem.cpp without changing it. Whichever of the two merges second carries this PR's two lstat checks in TestRelinkedModuleNames to the moved file.

Related: #4225

Tested

On GitHub's runners from my fork, merged with main at a6dcea9279 (run), on both Linux and Windows:

  • TestRelinkedModuleNames in guest_filesystem gains two lstat checks: ENOENT while neither name exists, and the relinked file's size once X.guest.prx exists. With main's Stdio.cpp the test aborts on both. With the change it passes 10 runs in a row.
  • Every test registered under core/libs/prx/libc and core/libs/prx/libkernel passes: 115 and 197 on Linux, 142 and 207 on Windows.
  • After the merge with main at da54c652e3 (82bd36d74b, no conflicts, the PR's own diff unchanged; run): guest_filesystem fails with main's Stdio.cpp on both runners and passes 10 runs in a row with the change. The libc and libkernel suites pass on Windows (143, 207) and libkernel on Linux (197); in libc on Linux, the timing test precise_wait failed once.
  • After the merge with main at b91a6a60c5 (20ae347f6a; run): #9618 now has lstat fill a local FileStat and copy it out to the guest, in the lines this PR changes. The merge keeps that and this PR's module lookup in the same ResolvePathError_nid_no_patch call, so the PR's own lines are unchanged. guest_filesystem fails with main's Stdio.cpp on both runners and passes 10 runs in a row with the change. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with APS5_SKIP_TIMING_TESTS=1, which relaxes precise_wait's median bounds on GitHub's hosted runners.
  • tools/check_conventions.py --base origin/main passes.
  • Not tested: macOS, a console, any title.

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 (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none now that #9618 has merged (the order agreed in its thread (comment)); this PR merges before #7447, agreed in its thread (comment), see Overlap; no order with the others listed there)
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959504724 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T23:01:05Z. --- ### What #4688 made `stat`, `sceKernelStat`, read-only `sceKernelOpen` and `sceKernelCheckReachability` find `X.guest.prx` when a title asks for `X`, the name the relinker replaced, and listed `lstat` as not covered. `lstat` still answers `ENOENT` for the same path, so code that checks for a plugin with `lstat` sees it missing while `stat` and `dlopen` find it. `lstat` now resolves the path with the module lookup of `ResolvePathError_nid_no_patch`, which `sceKernelStat` also uses. An existing `X`, including a dangling symbolic link, is still reported as it is; only a missing `X` falls back to `X.guest.prx`. Since #5401 was opened, `main` moved that lookup from `File::PathOrRelinkedModule` into the resolver's `module` flag, so the change is now that flag. No title is claimed. **Overlap:** #7447 changes the same `ResolvePathError_nid_no_patch` call in `lstat`: it sets the resolver's `archived` flag and answers from `File::FillArchivedStat` first, where this PR sets its `module` flag. The two should compose as `ResolvePathError_nid_no_patch(path, native, true, true)`, the call `sceKernelCheckReachability` makes on `main`. This PR proposed going first in #7447's thread ([comment](https://github.com/boykopovar/AnyPS5/pull/7447#issuecomment-6329954319)), with #7447 taking that call when it rebases. qpavyros agreed ([comment](https://github.com/boykopovar/AnyPS5/pull/7447#issuecomment-6351612110)): this PR first, and #7447 keeps both flags in `lstat`'s call when it takes this PR in. #9618 (xXPBSXx) reworks the same function: `lstat` fills a local `FileStat` and copies it out with `GuestCopyOut_nid_no_patch`, so it answers `EFAULT` when the output struct isn't writable guest memory. The two conflict only there, and compose as #9618's version of the function with this PR's `module` flag in its `ResolvePathError_nid_no_patch` call. xXPBSXx checked both orders and either works for #9618 ([comment](https://github.com/boykopovar/AnyPS5/pull/9618#issuecomment-6357535017)). #9618 goes first, merge order only, and this PR re-applies its one-line flag when it merges `main` after it. The other PRs the overlap check lists don't touch `lstat` or its test, so the merge order doesn't matter for them: - #5021, #6879, #6936 and #7201 change other parts of `Stdio.cpp`, and none of them changes `lstat`. Merged with this PR on top of `main`, none of their conflicts is on the `lstat` line; the ones they have are with `main` itself. - #6044 moves `core/libs/tests/GuestFilesystem.cpp` to `core/libs/tests/files/GuestFilesystem.cpp` without changing it. Whichever of the two merges second carries this PR's two `lstat` checks in `TestRelinkedModuleNames` to the moved file. Related: #4225 ### Tested On GitHub's runners from my fork, merged with `main` at a6dcea9279 ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39686123418)), on both Linux and Windows: - `TestRelinkedModuleNames` in `guest_filesystem` gains two `lstat` checks: `ENOENT` while neither name exists, and the relinked file's size once `X.guest.prx` exists. With `main`'s `Stdio.cpp` the test aborts on both. With the change it passes 10 runs in a row. - Every test registered under `core/libs/prx/libc` and `core/libs/prx/libkernel` passes: 115 and 197 on Linux, 142 and 207 on Windows. - **After the merge with `main` at da54c652e3** (82bd36d74b, no conflicts, the PR's own diff unchanged; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728772910)): `guest_filesystem` fails with `main`'s `Stdio.cpp` on both runners and passes 10 runs in a row with the change. The libc and libkernel suites pass on Windows (143, 207) and libkernel on Linux (197); in libc on Linux, the timing test `precise_wait` failed once. - **After the merge with `main` at b91a6a60c5** (20ae347f6a; [run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/40186895254)): #9618 now has `lstat` fill a local `FileStat` and copy it out to the guest, in the lines this PR changes. The merge keeps that and this PR's module lookup in the same `ResolvePathError_nid_no_patch` call, so the PR's own lines are unchanged. `guest_filesystem` fails with `main`'s `Stdio.cpp` on both runners and passes 10 runs in a row with the change. Linux: 1 run, 1 pass, 0 skip, 0 fail. Windows: 1 run, 1 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran with `APS5_SKIP_TIMING_TESTS=1`, which relaxes `precise_wait`'s median bounds on GitHub's hosted runners. - `tools/check_conventions.py --base origin/main` passes. - Not tested: macOS, a console, any title. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none now that #9618 has merged (the order agreed in its thread ([comment](https://github.com/boykopovar/AnyPS5/pull/9618#issuecomment-6357535017))); this PR merges before #7447, agreed in its thread ([comment](https://github.com/boykopovar/AnyPS5/pull/7447#issuecomment-6351612110)), see Overlap; no order with the others listed there) - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
MarcZX10 commented 2026-10-21 23:04:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T23:04:09Z.


This change overlaps lstat_nid_postfix in #9423: that PR updates its PathError call to copy and validate the guest path, while this PR changes the same function’s ResolvePathError_nid_no_patch call. Please coordinate the order with #9423’s author and set Depends on if one needs to land first; after composition, keep both the checked path copy and relinked-module lookup.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328512095 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#issuecomment-6328512095). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-21T23:04:09Z. --- This change overlaps `lstat_nid_postfix` in #9423: that PR updates its `PathError` call to copy and validate the guest path, while this PR changes the same function’s `ResolvePathError_nid_no_patch` call. Please coordinate the order with #9423’s author and set `Depends on` if one needs to land first; after composition, keep both the checked path copy and relinked-module lookup.
EagleBearerYS commented 2026-10-21 23:27:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-21T23:27:01Z.


Thanks, @MarcZX10. git merge-tree of this PR's head (6e9768f618) with #9423's (4d7b47abe7) is clean. The merged lstat_nid_postfix keeps both: #9423 replaces path with its checked copy right after PathError, and ResolvePathError_nid_no_patch(path, native, true) then runs on that copy. Neither needs the other first, so this stays at Depends on: none, and whichever merges second needs no change. @AliZedan1A, for your awareness.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6328838978 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#issuecomment-6328838978). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-21T23:27:01Z. --- Thanks, @MarcZX10. `git merge-tree` of this PR's head (6e9768f618) with #9423's (4d7b47abe7) is clean. The merged `lstat_nid_postfix` keeps both: #9423 replaces `path` with its checked copy right after `PathError`, and `ResolvePathError_nid_no_patch(path, native, true)` then runs on that copy. Neither needs the other first, so this stays at Depends on: none, and whichever merges second needs no change. @AliZedan1A, for your awareness.
MarcZX10 commented 2026-10-22 03:41:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T03:41:30Z.

Review: CHANGES_REQUESTED


The module=true change is technically consistent with the existing resolver: ResolvePathOrRelinkedModule_nid_no_patch handles the module fallback, while ordinary lstat still uses the non-module resolution path. The added missing-name and relinked-file size assertions cover the intended behavior, and the existing sceKernelCheckReachability call demonstrates how the module and archived flags compose.

The remaining blocker is merge coordination with #7447. Both PRs change this exact lstat_nid_postfix resolver call. Your description proposes this PR first, followed by #7447 updating the call to (path, native, true, true), but #7447's author has not confirmed that order, and this PR still says Depends on: none. Please agree the order with @qpavyros and record the dependency/order on the checklist. The overlap scan also reports shared paths with #5021, #6044, #6879, #6936 and #7201; please account for the relevant file/test changes before approval.

The current eligibility, conventions, intake, labels and report checks pass. The Linux and Windows product jobs are skipped. The focused Linux and Windows runs in the description are author-reported; I did not run them locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608994157 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#pullrequestreview-5608994157). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T03:41:30Z. **Review:** CHANGES_REQUESTED --- The `module=true` change is technically consistent with the existing resolver: `ResolvePathOrRelinkedModule_nid_no_patch` handles the module fallback, while ordinary `lstat` still uses the non-module resolution path. The added missing-name and relinked-file size assertions cover the intended behavior, and the existing `sceKernelCheckReachability` call demonstrates how the module and archived flags compose. The remaining blocker is merge coordination with #7447. Both PRs change this exact `lstat_nid_postfix` resolver call. Your description proposes this PR first, followed by #7447 updating the call to `(path, native, true, true)`, but #7447's author has not confirmed that order, and this PR still says `Depends on: none`. Please agree the order with @qpavyros and record the dependency/order on the checklist. The overlap scan also reports shared paths with #5021, #6044, #6879, #6936 and #7201; please account for the relevant file/test changes before approval. The current eligibility, conventions, intake, labels and report checks pass. The Linux and Windows product jobs are skipped. The focused Linux and Windows runs in the description are author-reported; I did not run them locally.
EagleBearerYS commented 2026-10-22 03:51:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T03:51:15Z.


Thanks, @MarcZX10. The Overlap section now covers each PR the check lists. #5021, #6879, #6936 and #7201 change other parts of Stdio.cpp, not lstat, and none of their conflicts is on the lstat line. #6044 moves GuestFilesystem.cpp unchanged, so whichever merges second carries the two lstat checks to the moved file. For #7447 the order is proposed in its thread, and I'll record it under Depends on once qpavyros answers.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6332240231 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#issuecomment-6332240231). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T03:51:15Z. --- Thanks, @MarcZX10. The Overlap section now covers each PR the check lists. #5021, #6879, #6936 and #7201 change other parts of `Stdio.cpp`, not `lstat`, and none of their conflicts is on the `lstat` line. #6044 moves `GuestFilesystem.cpp` unchanged, so whichever merges second carries the two `lstat` checks to the moved file. For #7447 the order is proposed in its thread, and I'll record it under Depends on once qpavyros answers.
MarcZX10 commented 2026-10-22 04:30:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:30:35Z.

Review: DISMISSED


The module fallback is correctly limited to a missing original .prx path, while an existing file or dangling symlink remains handled by lstat itself; the regression covers missing and relinked names. The earlier #9423 checked-path overlap was manually confirmed to compose. The remaining functional coordination is #7447: it changes the same resolver call to set archived, while this PR sets module; the combined call needs both flags, but #7447’s author has not confirmed the proposed order and this checklist still says Depends on: none. Please agree the order with @qpavyros and record it, then preserve both flags when rebasing. This branch and reported tests are based on a6dcea9279, while current upstream main is ab347d144d; rebase and rerun guest_filesystem, conventions and overlap on current main. Hosted product jobs are skipped; I did not run local tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609280127 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#pullrequestreview-5609280127). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:30:35Z. **Review:** DISMISSED --- The module fallback is correctly limited to a missing original `.prx` path, while an existing file or dangling symlink remains handled by `lstat` itself; the regression covers missing and relinked names. The earlier #9423 checked-path overlap was manually confirmed to compose. The remaining functional coordination is #7447: it changes the same resolver call to set `archived`, while this PR sets `module`; the combined call needs both flags, but #7447’s author has not confirmed the proposed order and this checklist still says `Depends on: none`. Please agree the order with @qpavyros and record it, then preserve both flags when rebasing. This branch and reported tests are based on a6dcea9279, while current upstream main is ab347d144d88fae054d9770cf0db8d3565735c02; rebase and rerun `guest_filesystem`, conventions and overlap on current main. Hosted product jobs are skipped; I did not run local tests.
EagleBearerYS commented 2026-10-22 06:00:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T06:00:36Z.


Thanks, @MarcZX10. The branch now has main at da54c652e3 merged in (82bd36d74b), with the PR's own diff unchanged. On GitHub's runners (run) guest_filesystem passes 10 runs in a row on both and fails with main's Stdio.cpp; the libc and libkernel suites pass apart from libc's precise_wait timing test once on Linux, and conventions pass. Tested now says so. The order with #7447 still waits on qpavyros; it goes under Depends on once they answer, and both resolver flags stay in the combined call.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6333918104 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9478#issuecomment-6333918104). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-22T06:00:36Z. --- Thanks, @MarcZX10. The branch now has `main` at da54c652e3 merged in (82bd36d74b), with the PR's own diff unchanged. On GitHub's runners ([run](https://github.com/EagleBearerYS/AnyPS5/actions/runs/39728772910)) `guest_filesystem` passes 10 runs in a row on both and fails with `main`'s `Stdio.cpp`; the libc and libkernel suites pass apart from libc's `precise_wait` timing test once on Linux, and conventions pass. Tested now says so. The order with #7447 still waits on qpavyros; it goes under Depends on once they answer, and both resolver flags stay in the combined call.
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!9478
No description provided.