feat(libc): implement readdir_r #3635

Merged
MarcZX10 merged 2 commits from upstream-pr/3635 into main 2026-10-13 01:15:32 +00:00
MarcZX10 commented 2026-10-11 14:29:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-11T14:29:32Z.


What

Related to #3556. Implements the missing readdir_r export in libc (J0kng1yac3M). It reads through the same locked directory-stream helper as readdir, copies the guest record's recordLength bytes, returns the caller's entry through result, and preserves errno on success and at end of directory. Read errors are returned as error numbers; a null stream returns EBADF, while null output pointers throw.

The behavior follows FreeBSD 11.4's readdir.c; the PS5 payload SDK lists the export in libSceLibcInternal. VLC's import registry predicts this as its next missing import after getlogin_r. This PR covers only readdir_r: open PR #3606 independently implements getlogin_r.

This carries David's implementation commit 01085afe with its author metadata preserved. I added a regression for a null result pointer.

Sources: FreeBSD 11.4 readdir.c, PS5 payload SDK libc stubs.

Tested

  • Linux, GCC 12.2.0, Release: built guest_directory_tests; guest_directory passed 1/1.
  • python3 tools/check_conventions.py --base upstream/main and git diff --check passed.
  • CTest lists guest_directory. The repository's check_test_registration.py could not run because it invokes Ninja and Ninja is unavailable in this environment.
  • Windows and title-level runs were not performed here.

Checklist

  • Based on current main; no other open PR implements readdir_r (open PR #3606 implements getlogin_r)
  • 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 in TechnicalDebt
  • No notes, investigation files or images added to the repository
  • New third-party code is a submodule built from source
  • Generic behavior, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819783495 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3635). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T14:29:32Z. --- ### What Related to #3556. Implements the missing `readdir_r` export in `libc` (`J0kng1yac3M`). It reads through the same locked directory-stream helper as `readdir`, copies the guest record's `recordLength` bytes, returns the caller's entry through `result`, and preserves `errno` on success and at end of directory. Read errors are returned as error numbers; a null stream returns `EBADF`, while null output pointers throw. The behavior follows FreeBSD 11.4's `readdir.c`; the PS5 payload SDK lists the export in `libSceLibcInternal`. VLC's import registry predicts this as its next missing import after `getlogin_r`. This PR covers only `readdir_r`: open PR #3606 independently implements `getlogin_r`. This carries David's implementation commit [`01085afe`](https://github.com/screamm/AnyPS5/commit/01085afe122d6d2c6af9e54c745e2a7c448f7b24) with its author metadata preserved. I added a regression for a null `result` pointer. Sources: [FreeBSD 11.4 `readdir.c`](https://github.com/freebsd/freebsd-src/blob/releng/11.4/lib/libc/gen/readdir.c), [PS5 payload SDK libc stubs](https://github.com/ps5-payload-dev/sdk/blob/f5d40f02/sce_stubs/libSceLibcInternal.c). ### Tested - Linux, GCC 12.2.0, Release: built `guest_directory_tests`; `guest_directory` passed 1/1. - `python3 tools/check_conventions.py --base upstream/main` and `git diff --check` passed. - CTest lists `guest_directory`. The repository's `check_test_registration.py` could not run because it invokes Ninja and Ninja is unavailable in this environment. - Windows and title-level runs were not performed here. ### Checklist - [x] Based on current `main`; no other open PR implements `readdir_r` (open PR #3606 implements `getlogin_r`) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [x] No notes, investigation files or images added to the repository - [x] New third-party code is a submodule built from source - [x] Generic behavior, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-11 14:29:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T14:29:53Z.


Progress report (1acfa7f → 32b0c8d)

📈 System libraries: 86.37% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libc readdir_r_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110066646 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3635#issuecomment-6110066646). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T14:29:53Z. --- <!-- progress-report --> ### Progress report (1acfa7f → 32b0c8d) 📈 **System libraries**: 86.37% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libc | `readdir_r_nid_postfix` | </details>
blawesom commented 2026-10-11 15:00:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-11T15:00:01Z.


Cross-linking for the review: this implements half of the fix tracked in #3556 (readdir_r; the getlogin_r half is in #3606), which has an independent Linux verification on that issue — full suite 832/832 (CachyOS, GCC 16.2.1, including the Vulkan suites on AMD RX 9070 XT / RADV), conventions check clean.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110337340 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3635#issuecomment-6110337340). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T15:00:01Z. --- Cross-linking for the review: this implements half of the fix tracked in #3556 (`readdir_r`; the `getlogin_r` half is in #3606), which has an independent Linux verification on that issue — full suite **832/832** (CachyOS, GCC 16.2.1, including the Vulkan suites on AMD RX 9070 XT / RADV), conventions check clean.
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!3635
No description provided.