feat(libkernel): implement getdents and getdirentries #1634
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1634"
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:22:39Z.
What
Implements
getdents(2G6i6hMIUUY) andgetdirentries(f09KvIPy-QY) in libkernel. Part of #1578: PPSA99039 (EVO-PLAYER-PS5) imports both.They return the same FreeBSD 11
direntrecords assceKernelGetdentsandsceKernelGetdirentries, with the FreeBSD 11 signatures (int nbytes, 64-bit*basep), and report failures as -1 witherrnothroughPosixResultinstead of an SCE error code.Not changed here: on a descriptor that is not a directory, FreeBSD
kern_getdirentriesreturnsEINVAL, whilesceKernelGetdirentriescurrently returnsENOTDIR(fromgetdents64on Linux andReadDirectoryDescriptoron Windows). The wrappers pass on whatever it returns.Tested
Linux (Ubuntu 24.04, GCC 13, Release):
guest_directory_entriespasses with--repeat until-fail:3. It now reads the test directory with both calls (same records and byte count assceKernelGetdents,*basep0 after rewinding, 0 at the end) and checksEINVALfor a buffer too small or zero bytes andEFAULTfor a null buffer. The test fails whengetdentsreturns the SCE code. That test is registered on Linux only; the wrappers are shared and Windows keeps its existingsceKernelGetdirentries. Windows:Stdio.cppcompiles with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows.check_conventions.pypasses. 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:32:50Z.
Review: APPROVED
LGTM. Clean implementation of getdents and getdirentries as POSIX-style wrappers around the existing sceKernel functions, using PosixResult for proper error code conversion. The test coverage is thorough - verifying both new functions return identical results to their sceKernel counterparts while also testing edge cases (buffer too small, null buffer, zero bytes) with correct errno values. Good addition to support EVO-PLAYER-PS5's import requirements.
Imported from boykopovar/AnyPS5. Originally posted by SleglJan on 2026-10-08T15:59:29Z.
Confirmed on Linux on top of current
main.main4b005b22+ 9104f396 (clean merge), CachyOS (kernel 7.2.9, GCC 16.2.1, btrfs), full build withBUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ON: fullctest467/467;guest_directory_entries3/3 under--repeat until-fail:3;tools/check_conventions.py --base main --head 9104f396passes; the patchedlibkernel.prxexports2G6i6hMIUUYandf09KvIPy-QY.I had the same two wrappers written independently before seeing this PR (same shape over
sceKernelGetdirentrieswithPosixResult), so I ran my test against this branch too; it passes 3/3. It checks two thingsguest_directory_entriesdoes not, in case you want them:getdentson a descriptor aftersceKernelClosereturns -1 with errno 9, andgetdirentriesthe same;getdirentriescall on a 48-byte buffer returns more than 0 with*basepdifferent from the first call's 0.tools/import_audit.pyon catalog titles, absent imports before → after with this branch: PPSA59322 ccleste 50 → 49, PPSA68091 Ruffle Flash 71 → 70, PPSA99010 vkQuake 51 → 50, PPSA99039 EVO Player 24 → 22, PPSA99505 Jelly5 30 → 28.AI-assisted: yes (Claude Code); the runs and counts above were checked by hand.
Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T16:07:28Z.
Thanks for running it end to end. Added both checks in 620947b4: EBADF from both calls after close, and errno left alone on success with
*basepmoving forward on the secondgetdirentriescall.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T17:37:09Z.
Fork CI while the upstream run waits for approval: Build run, all jobs green on 620947b4 (Linux 467/467, Windows 457/457, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with
main.Imported from boykopovar/AnyPS5. Originally posted by LeandroLP23 on 2026-10-08T20:16:21Z.
Run with the title on Windows. EVO Player (PPSA99039 v0.10.0) on
mainstops atFAIL: unresolved ELF import 2G6i6hMIUUY from libkernel.prx(getdents). With this PR it stops at the next one,6kPnj51T62YfromlibSceVideoOut.prx(sceVideoOutGetResolutionStatus, #1714). With this PR and #1714 together it reaches+F7C-hdk7+Efromlibkernel.prx(sigemptyset).Windows 11, Radeon 860M, MinGW-w64 GCC 15.2.0, Release,
main4b6ab6bb; title relinked withrelinker --windowsand run with the patchedbuild/core/libs/libs/*.prx.Tested with AI assistance (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-08T21:22:07Z.
Progress report (
f8c2f07→7d130d1)📈 System libraries: 84.7% (+0.01%, +2 implemented functions)
✅ 2 implemented
getdents_nid_postfixgetdirentries_nid_postfixImported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-08T22:57:43Z.
One more title that stops on
getdentson currentmain, alongside @LeandroLP23's EVO Player run on Windows above. 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: 2G6i6hMIUUY(getdents)3QIPIh-GDjw(rewind)The "with this branch" build also had my other open PRs merged; only this branch exports
2G6i6hMIUUY.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-09T01:26:40Z.
Capy Mobile on Windows as well. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release,
mainf1451396(relinkerandlibs); titles relinked with--windows.mainFAIL: unresolved ELF import 2G6i6hMIUUY from libkernel.prx(getdents)FAIL: unresolved ELF import 3QIPIh-GDjw from libSceLibcInternal.prx(rewind)As on Linux, the second build also had my other open PRs merged; only this branch exports
2G6i6hMIUUY.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-09T21:18:42Z.
Checked on a build of the PR merged onto current
main: full ctest 520/520,guest_directory_entriespasses, and without the wrappers the test doesn't link, so it does exercise the change. Errno values (EINVAL/EFAULT/EBADF) and the success-leaves-errno-alone behaviour match the otherPosixResultwrappers. Also confirmed by @SleglJan (Linux) and @LeandroLP23 (EVO Player on Windows); merging.