feat(libkernel): export the POSIX rename #1192
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1192"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-07T17:04:07Z.
What
PPSA12544 (Hollow Knight: Silksong, v1.0.30021) imports
rename(NIDNN01qLRhiqU) from libkernel, not from libc. The title ships its ownlibc.prxinsce_module, so the host libc'srename(added in91bf8e3a) is not in the lookup. libkernel did not export it, and with--windows-diagnosticsstartup stopped with:renamenext tounlink. Like the other POSIX wrappers inStdio.cpp, it checks both paths withPathError(null ?EFAULT, empty ?ENOENT) and maps thesceKernelRenameresult toerrnothroughPosixResult.guest_filesystem_testslinks bothlibkernelandlibc, which each definerename_nid_postfix, so which one it binds to depends on the loader (reviewer on Linux showed it passes with or without this change). The newguest_kernel_rename_testsresolves the symbol fromlibkernel.prxexplicitly and checks rename, rename onto itself, missing source (ENOENT) and null/empty arguments (EFAULT/ENOENT). It fails without the export. Windows only so far; thedlopenpath for Linux is untested.renameto libkernel.Tested
-DBUILD_TESTING=ON, full build,--target libs,ctest -R guest_: 131/131 pass.--windows --to-intel --module-dir Media/Plugins: with this change theNN01qLRhiqUimport resolves. On a local integration branch that also carries @merwie's Silksong PRs (#716/#846, #760, #842, #844, #904) and #788/#903, the title gets past the Team Cherry logos to its main menu (Start game / Options / Extras) and holds a steady 60 FPS (vsync-locked) for 5+ minutes. Screenshot attached.0x00, key 0 is0xff, as in merwie's report on #648), and two exports that open PRs already add (#518 VRR peg/unpeg, #407sceNpEntitlementAccessGetEntitlementKey/sceNpUnregisterNpReachabilityStateCallback).renamefrom libkernel; I don't know whether merwie's version imports it.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T02:40:44Z.
Review: COMMENTED
Built and ran it — and then found that the existing test for this symbol cannot tell whether your change is there, which is worth knowing before this is relied on as covered.
Linux (CachyOS, GCC, Release):
The suite passes with and without the change.
guest_filesystem_testslinks bothlibkernelandlibc, andlibc.prxalready exports this symbol on your base —libc/src/Filesystem.cpp:93:nmon the test binary shows the symbol asU rename_nid_postfix— undefined in the executable and bound at load time from one of the two libraries (lddlists bothlibkernel.prxandlibc.prx). Reverting only yourStdio.cpphunk and rebuilding:So the test binds to whichever library the loader picks and passes either way; it exercises a
rename, not the one you added. The existing assertions (rename to a new name, to itself, to a missing source, back again) are real coverage of the function — just not of this implementation.The thing I would ask about is the second implementation. There are now two definitions of one POSIX function, and they do not follow the same path:
EFAULT(14) and an empty one asENOENT(2), thenResolvePath+std::filesystem::renamewithFilesystemErrormapping.PathErroron both arguments, thensceKernelRenamethroughPosixResult.Both are defensible, and each is internal-consistent — but a guest that imports
renamefromlibkerneland one that imports it fromlibcnow run different validation and different errno mapping, and two implementations of one function drift as soon as either is edited. If a title or a NID needsrenameexported from libkernel specifically, putting that in the body makes the duplication obviously intentional; if not, one of the two delegating to the other would keep a single behaviour.Nothing blocking — the build and the suite are clean, and adding the export is not harmful. It is the claim of coverage I wanted to correct, because the passing test looks like it covers this and does not.
This is a comment, not an approval — I have no merge rights here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-08T08:48:17Z.
Thanks for the careful check, and you're right:
guest_filesystem_testslinks both libs, so it binds to whichever the loader picks. My claim that it ran against libkernel only held on Windows. I've corrected the description and pushed 72dca197, which addsguest_kernel_rename_tests. It resolvesrename_nid_postfixfromlibkernel.prxexplicitly. It fails without the export and passes with it (Windows; I couldn't test the Linuxdlopenpath).On the duplicate: the export has to exist in libkernel because Silksong ships its own
libc.prx, so host libc is never in its lookup. I agree two implementations will drift. I'd rather make libc delegate to the libkernel one in a separate PR than widen this one, unless you'd prefer it here.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T08:51:17Z.
Review: CHANGES_REQUESTED
Thanks. Built and ran this merged onto current
mainon Linux: everything passes except the new test.core/libs/tests/GuestKernelRename.cpp:36:guest_kernel_renameaborts on Linux at the first rename (Kernel rename check failed at line 42 (guest errno 2)).rootis built fromstd::filesystem::temp_directory_path(), an absolute host path, and the guest VFS on Linux doesn't map those.GuestFilesystem.cpp:89uses a relative directory (std::filesystem::path("anyps5-filesystem-test-" + ...)) for this reason; ctest runs in the build dir. Withrootbuilt the same way the test passes here. Please change it, so the Linux CI job doesn't go red.The export itself looks fine: it matches the other POSIX wrappers in
Stdio.cpp, and since the title importsrenamefrom libkernel rather than libc, having it there is intentional, not a duplicate to remove.Not verified on our side: Windows (the
LoadLibraryApath and the Silksong import).Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-08T09:37:21Z.
Thanks @adriadam10, good catch. Fixed in 5b849126: the test now builds its directory relative to the working directory, the same way
GuestFilesystem.cppdoes, instead of usingtemp_directory_path(). It passes on Windows; I can't run Linux, so the Linux CI job is the check there.I also merged current
main(e4868c34) to clear the conflict inlibkernel/CMakeLists.txt, whereguest_kernel_syncwas added next to our block. Both are kept.On Windows, the
LoadLibraryApath is whatguest_kernel_renameexercises and it passes there. Thanks for confirming the export itself is fine as is, so I'll drop the idea of making libc delegate to it.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T09:58:25Z.
Review: CHANGES_REQUESTED
Checked on Linux, merged onto current
main: build,libsand full ctest green (434/434), and the relative-directory fix in 5b849126 works. Two things before merging:[duplicate-export] rename_nid_postfix is also in libc(Stdio.cpp:648). The project rule (#228, #241) is one implementation per export. Since the title ships its ownlibc.prxand only loads libkernel'srename, this is the case the shared-source pattern is for (FontLibrary.cmake): keep a singlerenamedefinition in one source compiled into both libraries, instead of a second copy inStdio.cpp.dlsymon the libkernel handle also searches its dependencies, andlibcexports the symbol. Check withdladdrthat the symbol comes fromlibkernel(we have a version of this ready: it fails without the export and passes with it), so the test pins the export.Not verified on our side: Windows (
LoadLibraryApath, the Silksong import).Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-08T14:21:32Z.
Thanks @adriadam10, both items are done in 76db9fa0, rebased onto current
main.renamenow lives inlibc/src/Rename.cpp, compiled into both libc and libkernel. The copy in libkernel'sStdio.cppis gone.FilesystemErrormoved tolibc/include/FilesystemError.hppso the shared source can use it.tools/check_conventions.pypasses locally.guest_kernel_renamenow checks the symbol it resolves belongs to libkernel, usingdladdragainstsceKernelRenamefrom the same handle on Linux and the owning module handle on Windows. On Windows it fails withRename.cppremoved from libkernel and passes with it.On Windows,
guest_kernel_renameandguest_filesystempass. In the full ctest run, 3 of 457 failed:jmprel_table_bounds,windows_icon_resourceandstrict_nid_filter. They need the full build, which fails here on afreetyperesource-compile error (ftver.rc), so I don't think they are related to this change, but I didn't run them onmain. Linux is untested on my side, so your run is the check for thedladdrpath.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T14:55:53Z.
Verified the current head on Linux, and both points @adriadam10 left hold here.
Linux (CachyOS, GCC, Release), head
76db9fa0:The test now pins the libkernel export, which is the thing I could not get out of the old one. With the single line that compiles
Rename.cppinto libkernel removed (libkernel/CMakeLists.txt), whilelibc.prxstill exports the symbol:Restored, it passes again and
nm -D libkernel.prxshowsT rename_nid_postfix. So thedladdrcomparison rejects thelibccopy on Linux too, not only on Windows — that is the half you noted as untested, and it does the job here.One implementation:
nm -Dstill showsrename_nid_postfixin bothlibkernel.prxandlibc.prx, but both come from the singlelibc/src/Rename.cpp, and the conventions check that failed on the previous head ([duplicate-export] rename_nid_postfix is also in libc) now passes. That is the shared-source shape @adriadam10 pointed at.Nothing else from me on the test: the coverage claim I raised is now backed by a control rather than by a passing run. Not verified here: Windows (the
LoadLibraryA/Silksong path) — your re-check on Linux is the CI-side one.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T15:05:36Z.
Status on the current head, since both of your points are now done and the remaining blocker is not in the code.
Linux, head
76db9fa0(posted above in full):guest_kernel_renamerc=0 across three runs,ctest -j16466/466, conventions check passes, and thedladdrpin is backed by a control — with the one line that compilesRename.cppinto libkernel removed, the test fails withrename_nid_postfix is not defined by libkernelandnm -D libkernel.prxno longer lists the symbol. So the half you flagged as untested on Linux works there; the single-implementation shape resolves the[duplicate-export]failure.The thing actually holding the merge: no CI has run on this head. The workflow run for
76db9fa0is inaction_required— GitHub is waiting for a maintainer with write access to approve it before it starts:So
no checks reported on the 'feat/libkernel-posix-rename' branchmeans waiting for approval, not ran and reported nothing. It is not specific to this PR either: 18 of the last 100 runs in this repository are sitting in the same state, and two others I looked at this morning are identical — #1446 (headfb2ecdd4) and #1512 (head8a857904) both show no checks for the same reason.@adriadam10 — if you approve the run for this head (and the other two), CI becomes the check rather than a missing signal, and the Windows
LoadLibraryA/Silksong path is the only thing left that no one here has exercised.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-08T15:19:36Z.
The full list is now in one place: #1631 — 38 open PR heads queued at
action_required, oldest first, with a command to refresh it. Addressed to the approval side rather than per-PR.Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-08T21:20:56Z.
Rebased onto current
main(head1bd0ef8c) to pick up59fd2022. The Linux failure on the previous head wasguest_formatting_tests is run by ctest now; remove it from KNOWN_UNRUN, a stale entry intools/check_test_registration.pythat was already fixed onmain, so it was not caused by this PR.check_conventions.pypasses locally. The new head will need a workflow approval before CI runs.Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-09T11:22:15Z.
Rebase noted. The question from my review is still the one that decides this, and it is the same one the maintainer puts to other system-library changes: which title imports
renamefromlibkernel?On
maintoday the symbol exists in exactly one place —libc/src/Filesystem.cpp— and this adds a second implementation in a second library. They do not follow the same path: libc rejects a null argument asEFAULTand an empty one asENOENT, while libkernel routes both throughPathError. With a title ID and the log line the duplication is justified and this can land; without one, two implementations of one POSIX function will drift, and which a title gets is decided by the loader's search order rather than by intent.The rebase itself looks clean from here.
Written with AI assistance.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T22:34:29Z.
Review: APPROVED
Checked on Linux merged onto current
main: build,libsand ctest green apart frompatched_libraries, which depends on directory iteration order (libs without RUNPATH needinglibkernel.prx) and also fails on unrelated branches.guest_kernel_renamepasses, and fails with "rename_nid_postfix is not defined by libkernel" whenRename.cppis dropped from libkernel's sources. libc and libkernel now share onerename(libc/src/Rename.cpp), so the earlier concern about two implementations drifting no longer applies, and the PR body names the title (PPSA12544) and the unresolved-import log line. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-10T09:14:24Z.
To close the loop on the question: PPSA12544 (Hollow Knight: Silksong) imports
renamefromlibkernel. It ships its ownlibc.prx, so the host libc export is never in its lookup. The merged version keeps one implementation (libc/src/Rename.cpp, built into both libraries), so the two cannot drift.Written with AI assistance.