fix(libkernel): export _readv, _writev, _fcntl, _fstat, __sys_socketex #5992

Merged
Get-fix merged 1 commit from upstream-pr/5992 into main 2026-10-18 14:45:20 +00:00
Get-fix commented 2026-10-14 18:36:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-14T18:36:58Z.


What

PS4 programs and modules built with the OpenOrbis toolchain import these libkernel names, and the samples stop at start-up without them: FAIL: unresolved ELF import YSHRBRLn2pI (_writev, all nine samples that otherwise start), +WRlkKjZvag (_readv), t0fXUzq61Z4 (_fcntl) and A0O5kF5x4LQ (_fstat, in the library sample's libExample.prx). __sys_socketex is imported by the networking sample.

  • _readv, _writev, _fcntl and _fstat forward to readv, writev, fcntl and fstat, as _ioctl already does. _fcntl passes its argument on as a full 64-bit value, so the record lock commands keep their whole pointer.
  • __sys_socketex creates a socket like socket(); its name argument is ignored, as sceNetSocket does.

Part of the PS4 homebrew work tracked in #3093.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, full build with BUILD_TESTING=ON, on main e442f4c2e:

  • guest_kernel_fcntl, guest_file_vector and guest_file_timestamps pass, as do guest_udp, guest_sendfile and guest_sce_net (6/6). They call each name and check what it did: _readv reads from an offset, _writev writes swapped segments, _fstat returns the same times as fstat, _fcntl sets descriptor flags and reads a record lock into a static flock (in the image, above 4 GiB), and __sys_socketex makes a TCP socket.
  • Each of these makes a test fail: _fcntl narrowing its argument to int, or dropping it; __sys_socketex swapping family and type; _readv reading nothing; _writev claiming success without writing; _fstat filling nothing.
  • OpenOrbis samples with the other changes listed in #3093 (left out one at a time on main 84b01f9cd, all together on e442f4c2e): with this change the nine samples start; the networking sample, a TCP server, was not run for this PR.
  • tools/check_conventions.py --base origin/main passes.

Not tested on Linux.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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 under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: OpenOrbis PS4 toolchain samples, #3093
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4862687043 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-14T18:36:58Z. --- ### What PS4 programs and modules built with the OpenOrbis toolchain import these libkernel names, and the samples stop at start-up without them: `FAIL: unresolved ELF import YSHRBRLn2pI` (`_writev`, all nine samples that otherwise start), `+WRlkKjZvag` (`_readv`), `t0fXUzq61Z4` (`_fcntl`) and `A0O5kF5x4LQ` (`_fstat`, in the library sample's `libExample.prx`). `__sys_socketex` is imported by the networking sample. - `_readv`, `_writev`, `_fcntl` and `_fstat` forward to `readv`, `writev`, `fcntl` and `fstat`, as `_ioctl` already does. `_fcntl` passes its argument on as a full 64-bit value, so the record lock commands keep their whole pointer. - `__sys_socketex` creates a socket like `socket()`; its name argument is ignored, as `sceNetSocket` does. Part of the PS4 homebrew work tracked in #3093. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, full build with `BUILD_TESTING=ON`, on `main` `e442f4c2e`: - `guest_kernel_fcntl`, `guest_file_vector` and `guest_file_timestamps` pass, as do `guest_udp`, `guest_sendfile` and `guest_sce_net` (6/6). They call each name and check what it did: `_readv` reads from an offset, `_writev` writes swapped segments, `_fstat` returns the same times as `fstat`, `_fcntl` sets descriptor flags and reads a record lock into a static `flock` (in the image, above 4 GiB), and `__sys_socketex` makes a TCP socket. - Each of these makes a test fail: `_fcntl` narrowing its argument to `int`, or dropping it; `__sys_socketex` swapping family and type; `_readv` reading nothing; `_writev` claiming success without writing; `_fstat` filling nothing. - OpenOrbis samples with the other changes listed in #3093 (left out one at a time on `main` `84b01f9cd`, all together on `e442f4c2e`): with this change the nine samples start; the networking sample, a TCP server, was not run for this PR. - `tools/check_conventions.py --base origin/main` passes. Not tested on Linux. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: OpenOrbis PS4 toolchain samples, #3093 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-14 18:37:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T18:37:50Z.


Progress report (73efd94 → f12d2de)

📈 System libraries: 88.87% (+0.01%, +5 implemented functions)

✅ 5 implemented
Library Name
libkernel __sys_socketex_nid_postfix
libkernel _fcntl_nid_postfix
libkernel _fstat_nid_postfix
libkernel _readv_nid_postfix
libkernel _writev_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175601556 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992#issuecomment-6175601556). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T18:37:50Z. --- <!-- progress-report --> ### Progress report (73efd94 → f12d2de) 📈 **System libraries**: 88.87% (+0.01%, +5 implemented functions) <details> <summary>✅ 5 implemented</summary> | Library | Name | | - | - | | libkernel | `__sys_socketex_nid_postfix` | | libkernel | `_fcntl_nid_postfix` | | libkernel | `_fstat_nid_postfix` | | libkernel | `_readv_nid_postfix` | | libkernel | `_writev_nid_postfix` | </details>
github-actions[bot] commented 2026-10-15 12:12:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:12:53Z.


Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 5021 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 6044 core/libs/tests/GuestFileTimestamps.cpp
core/libs/tests/GuestFileVector.cpp
core/libs/tests/GuestKernelFcntl.cpp
PR 6222 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 6879 core/libs/prx/libkernel/File/src/Stdio.cpp
PR 7088 core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7201 core/libs/prx/libkernel/File/src/Stdio.cpp
core/libs/prx/libkernel/Socket/src/Udp.cpp
PR 7299 core/libs/prx/libkernel/File/src/Stdio.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191762171 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992#issuecomment-6191762171). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:12:53Z. --- <!-- pr-overlap --> Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestFileTimestamps.cpp`<br>`core/libs/tests/GuestFileVector.cpp`<br>`core/libs/tests/GuestKernelFcntl.cpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libkernel/File/src/Stdio.cpp` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel/File/src/Stdio.cpp`<br>`core/libs/prx/libkernel/Socket/src/Udp.cpp` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `core/libs/prx/libkernel/File/src/Stdio.cpp` |
Get-fix commented 2026-10-15 13:35:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T13:35:07Z.


I checked the overlap the bot lists. I fetched each listed pull request and, for every file it shares with this one, merged its change with git merge-file into current main (a5e2a80c6) and into main with this pull request merged. A conflict that appears only in the second case is one this pull request adds.

The bot lists 21 pull requests, with 41 shared files between them (File/src/Stdio.cpp and Socket/src/Udp.cpp). This pull request adds no conflict to any of them. Its additions are new functions placed after the ones they forward to.

AI-assisted: yes (Claude Code). I ran these checks myself on Windows 11.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193363237 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992#issuecomment-6193363237). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-15T13:35:07Z. --- I checked the overlap the bot lists. I fetched each listed pull request and, for every file it shares with this one, merged its change with `git merge-file` into current `main` (`a5e2a80c6`) and into `main` with this pull request merged. A conflict that appears only in the second case is one this pull request adds. The bot lists 21 pull requests, with 41 shared files between them (`File/src/Stdio.cpp` and `Socket/src/Udp.cpp`). This pull request adds no conflict to any of them. Its additions are new functions placed after the ones they forward to. AI-assisted: yes (Claude Code). I ran these checks myself on Windows 11. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-16 20:12:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:12:57Z.


Checked the five forwarders against readv/writev/fcntl/fstat/socket, the 64-bit _fcntl argument, and the new assertions in guest_file_vector, guest_file_timestamps and guest_kernel_fcntl (all pass; the tests don't link without the change). Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6223833531 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992#issuecomment-6223833531). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T20:12:57Z. --- Checked the five forwarders against `readv`/`writev`/`fcntl`/`fstat`/`socket`, the 64-bit `_fcntl` argument, and the new assertions in `guest_file_vector`, `guest_file_timestamps` and `guest_kernel_fcntl` (all pass; the tests don't link without the change). Merging once the full Build is green.
adriadam10 commented 2026-10-16 23:21:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T23:21:26Z.


Re-checked against current main (4272979b3): merges cleanly, the five forwarders and the new assertions in guest_file_vector, guest_file_timestamps and guest_kernel_fcntl pass. Merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226525976 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5992#issuecomment-6226525976). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T23:21:26Z. --- Re-checked against current `main` (4272979b3): merges cleanly, the five forwarders and the new assertions in `guest_file_vector`, `guest_file_timestamps` and `guest_kernel_fcntl` pass. Merging once the full Build is green.
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!5992
No description provided.