feat(libkernel): export _ioctl #3487

Merged
DariusHQ merged 1 commit from upstream-pr/3487 into main 2026-10-11 11:54:42 +00:00
DariusHQ commented 2026-10-11 11:26:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DariusHQ on 2026-10-11T11:26:07Z.


What

_ioctl (wW+k21cmbwQ) in libkernel. FreeBSD's _ioctl is the same system call as ioctl, so it forwards to the existing ioctl export

Stremio Plus (PPSA74126 0.5.6, LoZazaMastro/Stremio-Plus) stops at it at start-up on main 9a9bd3fb3, Windows, catalog build with eboot.bin and sce_module/libc.prx unwrapped as #2605 requires (tracked in #1578):

FAIL: unresolved ELF import wW+k21cmbwQ from libkernel.prx

With this branch it goes on to getsid (gokWod7GAH4), its last absent import:

FAIL: unresolved ELF import gokWod7GAH4 from libkernel.prx

The title calls _ioctl only from its statically linked copy of FreeBSD's lib/libc/gen/termios.c: tcgetattr, tcsetattr, tcsetpgrp, tcgetpgrp, tcgetsid, tcsetsid, tcsendbreak, tcdrain, tcflush and tcflow. They send TIOCGETA, TIOCSETA, TIOCSETAW, TIOCSETAF, TIOCSPGRP, TIOCGPGRP, TIOCGSID, TIOCSCTTY, TIOCSBRK, TIOCCBRK, TIOCDRAIN, TIOCFLUSH, TIOCSTOP and TIOCSTART

ioctl handles FIONBIO and FIONREAD on sockets only. Another request on a socket fails with ENOTTY. Any request on a file or pipe descriptor fails with EBADF, where FreeBSD answers FIONBIO and FIONREAD there too and fails the termios requests with ENOTTY. That limit is not new, but it was not recorded, so TechnicalDebt now lists it for both names.

Tested

Windows 11 (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with BUILD_TESTING=ON on 9a9bd3fb3: ctest 830/832 passed. The two failures are known:

  • windows_exceptions fails the same way on main (#3411)
  • agc_driver_prepared_shaders_debug exited with a heap corruption (0xc0000374, as in #3171) and passed 5/5 when rerun alone

guest_udp now also calls _ioctl: FIONREAD on a socket returns 0 and writes the queued byte count, an unknown request fails with ENOTTY, and a closed descriptor fails with EBADF. A mutant that forwards a fixed request instead of the caller's fails the test.

tools/import_audit.py on Stremio Plus relinked with --windows --registry: absent imports go from 2 to 1 (getsid).

Not run on Linux (no Linux host here); the change is the same on both.

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 in TechnicalDebt
  • 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
  • AI-assisted: no
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4818705752 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3487). Originally posted by [DariusHQ](https://github.com/DariusHQ) on 2026-10-11T11:26:07Z. --- ### What `_ioctl` (`wW+k21cmbwQ`) in libkernel. FreeBSD's `_ioctl` is the same system call as `ioctl`, so it forwards to the existing `ioctl` export Stremio Plus (PPSA74126 0.5.6, [LoZazaMastro/Stremio-Plus](https://github.com/LoZazaMastro/Stremio-Plus)) stops at it at start-up on `main` 9a9bd3fb3, Windows, catalog build with `eboot.bin` and `sce_module/libc.prx` unwrapped as #2605 requires (tracked in #1578): ``` FAIL: unresolved ELF import wW+k21cmbwQ from libkernel.prx ``` With this branch it goes on to `getsid` (`gokWod7GAH4`), its last absent import: ``` FAIL: unresolved ELF import gokWod7GAH4 from libkernel.prx ``` The title calls `_ioctl` only from its statically linked copy of FreeBSD's `lib/libc/gen/termios.c`: `tcgetattr`, `tcsetattr`, `tcsetpgrp`, `tcgetpgrp`, `tcgetsid`, `tcsetsid`, `tcsendbreak`, `tcdrain`, `tcflush` and `tcflow`. They send `TIOCGETA`, `TIOCSETA`, `TIOCSETAW`, `TIOCSETAF`, `TIOCSPGRP`, `TIOCGPGRP`, `TIOCGSID`, `TIOCSCTTY`, `TIOCSBRK`, `TIOCCBRK`, `TIOCDRAIN`, `TIOCFLUSH`, `TIOCSTOP` and `TIOCSTART` `ioctl` handles `FIONBIO` and `FIONREAD` on sockets only. Another request on a socket fails with `ENOTTY`. Any request on a file or pipe descriptor fails with `EBADF`, where FreeBSD answers `FIONBIO` and `FIONREAD` there too and fails the termios requests with `ENOTTY`. That limit is not new, but it was not recorded, so TechnicalDebt now lists it for both names. ### Tested Windows 11 (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build with `BUILD_TESTING=ON` on `9a9bd3fb3`: `ctest` 830/832 passed. The two failures are known: - `windows_exceptions` fails the same way on `main` (#3411) - `agc_driver_prepared_shaders_debug` exited with a heap corruption (`0xc0000374`, as in #3171) and passed 5/5 when rerun alone `guest_udp` now also calls `_ioctl`: `FIONREAD` on a socket returns 0 and writes the queued byte count, an unknown request fails with `ENOTTY`, and a closed descriptor fails with `EBADF`. A mutant that forwards a fixed request instead of the caller's fails the test. `tools/import_audit.py` on Stremio Plus relinked with `--windows --registry`: absent imports go from 2 to 1 (`getsid`). Not run on Linux (no Linux host here); the change is the same on both. ### Checklist - [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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: no
github-actions[bot] commented 2026-10-11 11:26:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T11:26:38Z.


Progress report (0f863c1 → b4a59e3)

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

✅ 1 implemented
Library Name
libkernel _ioctl_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108527057 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3487#issuecomment-6108527057). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T11:26:38Z. --- <!-- progress-report --> ### Progress report (0f863c1 → b4a59e3) 📈 **System libraries**: 85.75% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel | `_ioctl_nid_postfix` | </details>
github-actions[bot] commented 2026-10-11 11:44:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T11:44:25Z.


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.

Pull request Conflicting files (lines on main) Same exports Same new files
#3493 _ioctl_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108668377 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3487#issuecomment-6108668377). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T11:44:25Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #3493 | | `_ioctl_nid_postfix` | |
adriadam10 commented 2026-10-11 11:54:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T11:54:39Z.


Checked the build and guest_udp on Linux (libkernel scope): it passes, and without the change it fails to link (_ioctl missing). _ioctl forwards to the existing ioctl, matching FreeBSD where both are the same syscall, and the TechnicalDebt entry is in the right section. Merging once CI is green.

Note: #3493 also exports _ioctl; it will need to drop that part after this lands.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6108748770 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3487#issuecomment-6108748770). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T11:54:39Z. --- Checked the build and `guest_udp` on Linux (libkernel scope): it passes, and without the change it fails to link (`_ioctl` missing). `_ioctl` forwards to the existing `ioctl`, matching FreeBSD where both are the same syscall, and the TechnicalDebt entry is in the right section. Merging once CI is green. Note: #3493 also exports `_ioctl`; it will need to drop that part after this lands.
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!3487
No description provided.