getlogin_r and readdir_r are absent (VLC, PS5MC); fix branch ready #3556

Closed
opened 2026-10-11 13:09:10 +00:00 by screamm · 5 comments
screamm commented 2026-10-11 13:09:10 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-11T13:09:10Z.


getlogin_r (libkernel, NID 78FiHequa9U) and readdir_r (libc, NID J0kng1yac3M) are absent. From the relink registry order they are the predicted next stops of VLC (PPSA85300; getlogin_r called from libsmb2 smb2_init_context at 0x5356B5 with a 1024-byte buffer and a "Guest" fallback; readdir_r from libbluray _dir_read_posix at 0x16A0B91 with a 264-byte stack dirent), and PS5MC (PPSA99420) imports getlogin_r; not yet observed in a run.

Fix branch ready: screamm:feat/libc-getlogin-readdir-r (two commits on main a11c8f7f: dc750864 feat(libkernel): implement getlogin_r, 01085afe feat(libc): implement readdir_r). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are.

  • getlogin_r(name, len) next to getuid in System/src/Process.cpp: a length below 1 returns ERANGE without touching the buffer (FreeBSD 11.4 getlogin.c, 8c639945); every other call throws without writing a name, because no public source (shadPS4, KytyPS5, SharpProspero, fpPS4) gives the login name a console game process gets; recorded in TechnicalDebt. VLC therefore loads past the import and only reaches the throw when opening an SMB share.
  • readdir_r(dir, entry, result) in libc/src/Directory.cpp after FreeBSD readdir.c __readdir_r: reads under the existing per-stream mutex through a helper shared with readdir (one position per stream), copies recordLength bytes (FreeBSD's _GENERIC_DIRSIZ), sets *result or NULL at end, returns 0 or the read errno; null stream EBADF; null entry/result throw.
  • guest_credentials and guest_directory gain the ERANGE/throw cases and a full walk compared with readdir, the copy length, errno kept at end, continuing after a readdir, and the error cases.

Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON, full build including libs: both tests 3/3; ctest -j8 -E "^agc_driver_|^video_out_flip" 533/536, the failures being the known windows_exceptions (#3411), guest_kernel_sys (#3510) and guest_filesystem (#3518); with main's Directory.cpp the extended directory test fails; tools/check_conventions.py --base main and git diff --check pass. Not run on Linux.

Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5801343566 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T13:09:10Z. --- `getlogin_r` (libkernel, NID `78FiHequa9U`) and `readdir_r` (libc, NID `J0kng1yac3M`) are absent. From the relink registry order they are the predicted next stops of VLC (PPSA85300; `getlogin_r` called from libsmb2 `smb2_init_context` at 0x5356B5 with a 1024-byte buffer and a `"Guest"` fallback; `readdir_r` from libbluray `_dir_read_posix` at 0x16A0B91 with a 264-byte stack `dirent`), and PS5MC (PPSA99420) imports `getlogin_r`; not yet observed in a run. **Fix branch ready:** [`screamm:feat/libc-getlogin-readdir-r`](https://github.com/screamm/AnyPS5/tree/feat/libc-getlogin-readdir-r) (two commits on `main` `a11c8f7f`: `dc750864` `feat(libkernel): implement getlogin_r`, `01085afe` `feat(libc): implement readdir_r`). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. - `getlogin_r(name, len)` next to `getuid` in `System/src/Process.cpp`: a length below 1 returns `ERANGE` without touching the buffer (FreeBSD 11.4 `getlogin.c`, `8c639945`); every other call throws without writing a name, because no public source (shadPS4, KytyPS5, SharpProspero, fpPS4) gives the login name a console game process gets; recorded in TechnicalDebt. VLC therefore loads past the import and only reaches the throw when opening an SMB share. - `readdir_r(dir, entry, result)` in `libc/src/Directory.cpp` after FreeBSD `readdir.c` `__readdir_r`: reads under the existing per-stream mutex through a helper shared with `readdir` (one position per stream), copies `recordLength` bytes (FreeBSD's `_GENERIC_DIRSIZ`), sets `*result` or NULL at end, returns 0 or the read errno; null stream `EBADF`; null entry/result throw. - `guest_credentials` and `guest_directory` gain the `ERANGE`/throw cases and a full walk compared with `readdir`, the copy length, errno kept at end, continuing after a `readdir`, and the error cases. **Tested** on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, `BUILD_TESTING=ON`, full build including `libs`: both tests 3/3; `ctest -j8 -E "^agc_driver_|^video_out_flip"` 533/536, the failures being the known `windows_exceptions` (#3411), `guest_kernel_sys` (#3510) and `guest_filesystem` (#3518); with `main`'s `Directory.cpp` the extended directory test fails; `tools/check_conventions.py --base main` and `git diff --check` pass. Not run on Linux. Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
blawesom commented 2026-10-11 14:01:58 +00:00 (Migrated from github.com)
Author
Contributor

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


Independent verification on Linux (the gap noted in the report): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • The branch is already based on current main — no rebase needed, the commit (01085afe1) is unchanged.
  • tools/check_conventions.py --base origin/main and git diff --check pass.
  • The libc login and directory tests pass, including the new getlogin_r/readdir_r cases.
  • Full suite: 832/832 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).

The branch is also mirrored at blawesom:verify/3556 for anyone carrying.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109818999 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556#issuecomment-6109818999). Originally posted by [blawesom](https://github.com/blawesom) on 2026-10-11T14:01:58Z. --- Independent verification on **Linux** (the gap noted in the report): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, `BUILD_TESTING=ON`. - The branch is already based on current `main` — no rebase needed, the commit (`01085afe1`) is unchanged. - `tools/check_conventions.py --base origin/main` and `git diff --check` pass. - The libc login and directory tests pass, including the new getlogin_r/readdir_r cases. - Full suite: **832/832 passed** (all tests including the Vulkan suites on AMD RX 9070 XT / RADV). The branch is also mirrored at [`blawesom:verify/3556`](https://github.com/blawesom/AnyPS5/tree/verify/3556) for anyone carrying.
reyani-dev commented 2026-10-11 14:22:03 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by reyani-dev on 2026-10-11T14:22:03Z.


Run evidence for both predictions (Windows 11, WinLibs GCC 15.2.0, catalog build with eboot.bin and sce_module/libc.prx unwrapped):

  • On main a11c8f7f, VLC (PPSA85300) stops on the first one:
    FAIL: unresolved ELF import 78FiHequa9U from libkernel.prx
    
  • With only a getlogin_r export added, the next stop is the second:
    FAIL: unresolved ELF import J0kng1yac3M from libSceLibcInternal.prx
    

So both are observed stops now, in that order. I'm not carrying the branch.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109996443 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556#issuecomment-6109996443). Originally posted by [reyani-dev](https://github.com/reyani-dev) on 2026-10-11T14:22:03Z. --- Run evidence for both predictions (Windows 11, WinLibs GCC 15.2.0, catalog build with `eboot.bin` and `sce_module/libc.prx` unwrapped): - On `main` a11c8f7f, VLC (PPSA85300) stops on the first one: ``` FAIL: unresolved ELF import 78FiHequa9U from libkernel.prx ``` - With only a `getlogin_r` export added, the next stop is the second: ``` FAIL: unresolved ELF import J0kng1yac3M from libSceLibcInternal.prx ``` So both are observed stops now, in that order. I'm not carrying the branch.
screamm commented 2026-10-11 14:29:41 +00:00 (Migrated from github.com)
Author
Contributor

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


Thanks, that settles both: the issue now has observed stops in the predicted order (VLC on 78FiHequa9U, then J0kng1yac3M once getlogin_r exists), so the branch covers exactly VLC's next two stops on main a11c8f7f.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110064967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556#issuecomment-6110064967). Originally posted by [screamm](https://github.com/screamm) on 2026-10-11T14:29:41Z. --- Thanks, that settles both: the issue now has observed stops in the predicted order (VLC on `78FiHequa9U`, then `J0kng1yac3M` once `getlogin_r` exists), so the branch covers exactly VLC's next two stops on `main` a11c8f7f.
MarcZX10 commented 2026-10-11 14:29:47 +00:00 (Migrated from github.com)
Author
Contributor

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


I split the two missing exports across focused PRs so each has one implementation to review:

Export Pull request Scope
getlogin_r #3606 Reads the host account name using the buffer and error contract described there.
readdir_r #3635 Shares the locked directory-stream reader with readdir, copies the guest record, and returns the entry or EOF result.

For #3635, the focused Linux guest_directory test passed, including the new null-result-pointer case; conventions and git diff --check passed. I did not run VLC or a Windows build. The issue remains open while these PRs are reviewed.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6110065820 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556#issuecomment-6110065820). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-11T14:29:47Z. --- I split the two missing exports across focused PRs so each has one implementation to review: | Export | Pull request | Scope | |---|---|---| | `getlogin_r` | [#3606](https://github.com/boykopovar/AnyPS5/pull/3606) | Reads the host account name using the buffer and error contract described there. | | `readdir_r` | [#3635](https://github.com/boykopovar/AnyPS5/pull/3635) | Shares the locked directory-stream reader with `readdir`, copies the guest record, and returns the entry or EOF result. | For #3635, the focused Linux `guest_directory` test passed, including the new null-result-pointer case; conventions and `git diff --check` passed. I did not run VLC or a Windows build. The issue remains open while these PRs are reviewed.
oneandonlydean commented 2026-10-13 02:08:13 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T02:08:13Z.


Closing: both are on main, getlogin_r with #3606 and readdir_r with #3635.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6136622335 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/3556#issuecomment-6136622335). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-13T02:08:13Z. --- Closing: both are on main, `getlogin_r` with #3606 and `readdir_r` with #3635.
Sign in to join this conversation.
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#3556
No description provided.