feat(libkernel_sys): implement readlink #1627
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1627"
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 babyhuey on 2026-10-08T15:15:30Z.
What
Implements
readlink(pd02UI9TbOA) in libkernel_sys. Part of #1578: PPSA99001 (ProsperoRadio) imports it fromlibkernel_sys, which only had the placeholder export. On Windows an import is looked up in its own module and then libc, so it has to live in libkernel_sys.kern_readlinkat/kern_readlink_vp: a path that is not a symbolic link fails withEINVAL, a zerobufsizreturns 0, a longer target is truncated tobufsizwithout a terminator, andbufsizaboveSSIZE_MAXfails withEINVAL. A null path fails withEFAULT, an empty one withENOENT.ResolvePath_nid_no_patch. The target is read withstd::filesystem::read_symlinkand returned with/separators, then copied into the guest buffer, so no host call writes guest memory directly.EIOotherwise, asSceErrorFromErrnodoes in libkernel.Tested
Linux (Ubuntu 24.04, GCC 13, Release): new
guest_kernel_syspasses with--repeat until-fail:3. It covers a file, a directory, a missing path, empty and null paths, and a link: full target, truncation, zero size, null buffer, and a case-insensitive guest path. Where symbolic links can't be created (Windows without the privilege) it prints that the link cases were not tested. The test fails when truncation is removed.check_test_registration.pyandcheck_conventions.pypass. Windows:Export.cppcompiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows. No title run.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 klosixgaming-arch on 2026-10-08T15:34:41Z.
Review: APPROVED
LGTM. Thorough implementation of readlink following FreeBSD semantics with proper argument validation, path resolution, symlink status checking, and error mapping via GuestError. The test coverage is excellent - testing non-symlink paths, missing/empty/null paths, full reading, truncation, zero-size buffer, null buffer cases, and case-insensitive path handling on Windows. Good graceful degradation when symlinks aren't available (Windows without privilege). Clean addition to libkernel_sys for ProsperoRadio's import requirements.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T15:39:14Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)__error_nid_postfix__error_nid_postfixcore/libs/CMakeLists.txtL133__error_nid_postfix__error_nid_postfix__error_nid_postfix__error_nid_postfixcore/libs/CMakeLists.txtL133core/libs/CMakeLists.txtL133__error_nid_postfix__error_nid_postfixImported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T17:37:04Z.
Fork CI while the upstream run waits for approval: Build run, all jobs green on a2de24b9 (Linux 467/467, Windows 458/458, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with
main.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T21:26:30Z.
Progress report (
54f28f2→d024717)📈 System libraries: 85.31% (+0.01%, +1 implemented functions)
✅ 1 implemented
readlink_nid_postfixImported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T22:57:41Z.
A title that stops on
readlinkon currentmain. Linux, Ubuntu 24.04 container, GCC 13, Release,maind64134f0(relinkerandlibs); titles from the homebrew catalog, relinked for Linux and run from the title folder.mainapp.elf: symbol lookup error: app.elf: undefined symbol: pd02UI9TbOA(readlink)QuJYZ2KVGGQ(shm_open)The "with this branch" build also had my other open PRs merged; only this branch exports
pd02UI9TbOA.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T01:26:39Z.
Same title on Windows. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release,
mainf1451396(relinkerandlibs); titles relinked with--windows.mainFAIL: unresolved ELF import pd02UI9TbOA from libkernel_sys.prx(readlink)FAIL: unresolved ELF import QuJYZ2KVGGQ from libkernel.prx(shm_open)As on Linux, the second build also had my other open PRs merged; only this branch exports
pd02UI9TbOA.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:52:35Z.
Checked on Linux (merged onto current
main): build and ctest green (524/524,guest_kernel_sysincluded); the test no longer links without thereadlinkexport. Error codes and truncation match FreeBSDkern_readlinkat, and the vkQuake runs on Linux and Windows back it up. Merging.