feat(libkernel): poll files, directories, the random device and stdio as FreeBSD does #7139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7139"
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 AlexOfTheForest on 2026-10-17T13:24:10Z.
What
pollthrew for every descriptor that is neither a socket nor a pipe: regular files, directories,/dev/randomand descriptors 0–2.selectalready handled the random device and stdio, but gave the wrong answer for the random device when more than one set named it, and on Windows threw for files. Four commits, each following FreeBSD 11.4's source:feat(libkernel): poll regular files and directories as vop_stdpoll does: a vnode goes toVOP_POLL.vop_stdpoll(UFS) andvop_nopollboth returnPOLLIN,POLLRDNORMandPOLLOUTof the request for every eventpollaccepts, and neverPOLLPRI,POLLRDBANDorPOLLWRBAND. Files, directories and app0.zar files now get that answer without a host call.File::IsVnodeclassifies the descriptor without throwing, so host sockets lent by libSceNet still reach their own path.feat(libkernel): poll the random device as randomdev_poll does: once seeded,randomdev_pollnarrows a request containingPOLLIN/POLLRDNORMto those bits and returns any other request whole. Two tests that relied on the random device throwing now check the real answer (the "still throws" case uses a kqueue descriptor).fix(libkernel): answer select on files and the random device as FreeBSD's poll routines do:selscanpolls each descriptor once with the flags of every set it is in, then marks the sets whose flags the answer shares. So the random device is only readable when it is in the read set; otherwise it is reported in the write and exception sets it was asked in. Before, it was reported readable and writable together and never exceptional. Files and directories are answered in process (readable, writable, never exceptional) instead of by the host poll, which threw on Windows.feat(libkernel): poll descriptors 0 to 2 with the console model select uses: descriptor 0 reports nothing; 1 and 2 reportPOLLOUT, the bitttydev_pollgives a writable terminal. This matchesselect's existing model.The poll and select debt entries are updated. Still throwing in
poll: other character devices, kqueue descriptors, and anything that is neither a socket, pipe, file, directory, random device nor 0–2.Tested
Linux x86_64:
guest_poll,guest_select,guest_select_waitandguest_socket_descriptorspassed 5 of 5 runs. New cases cover files and directories (requests with and without band bits, a timed wait with no ready event, mixed with a socket), both random devices for each request shape, theselectset combinations for the random device, and stdio.guest_tcpandguest_named_shm_concurrencyfail identically on unmodifiedmainin this container.guest_sce_netis skipped here (no IPv6 loopback), as onmain.tools/check_conventions.py --base upstream/mainpasses; the progress report is unchanged.GetFileType/ directory-descriptor checksfcntlalready relies on.Merges cleanly with
main. It touches lines indocs/dev/debt/libkernel.mdnext to my open kevent-ev-clear and kevent-pipe-write PRs; whichever merges later needs a small rebase.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T13:37:16Z.
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.
main)core/libs/tests/GuestSelect.cppL5docs/dev/debt/libkernel.mdL68-69Some 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.
docs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/tests/GuestPoll.cppcore/libs/tests/GuestSelect.cppcore/libs/tests/GuestSocketDescriptors.cppcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Socket.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/tests/GuestPoll.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/include/DescriptorControl.hppcore/libs/prx/libkernel/File/src/DescriptorControl.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/tests/GuestPoll.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by UmillD on 2026-10-17T14:07:30Z.
Independent Windows validation of this PR.
BUILD_TESTING=ON, bundled dependencies. CPU/library tests; no GPU or game execution.acad67d946a1d024fe32bd09c0e77772c0247f95merged cleanly into pinnedmain47a266cf975f00f7fba94013467d03bfa5e355e9. Integrated tree:1a33b4df145ad04c183c9e25f266ed6c47a65911. No other open PRs or local game patches added.libc.prxhas the same SHA-256 in both phases.guest_pollguest_selectguest_select_waitguest_socket_descriptorsOn the control,
guest_pollaborts withpoll: descriptor 4 is neither a socket nor a pipe;guest_selectwithselect on descriptor 5 (neither a socket nor a pipe) not implemented;guest_socket_descriptorswithpoll: descriptor 3 is neither a socket nor a pipe. All three exit0xc0000409. These are fixture failures exercising the unsupported paths, not title crashes.With the PR, the four focused cases pass 20/20 executions, using serial CTest
--repeat until-fail:5. They exercise the new file/directory and random-device readiness, stdio handling, mixed descriptors and timed waits.The neighboring cases
guest_dup,guest_kernel_fcntl,guest_udp,guest_socket_read_writeandguest_socket_pairalso pass once on each phase (5/5 control, 5/5 candidate). No skipped cases, timeouts or memory-guard terminations. CTest ran with-j1 --timeout 30, retaining the tests' existing individual timeout properties.Scope: focused Windows regression coverage, not a full-suite run, game test or console-semantic measurement. This report does not separately exercise
app0.zarreadiness. No production or fixture changes were needed locally.AI-assisted testing and report: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by HQasper on 2026-10-17T19:30:56Z.
Thanks for this, it makes files, directories and the console descriptors behave in
selectas FreeBSD does.I stacked a small follow-up on top of it in #7248. It answers kqueues as
kqueue_polldoes, which also fixes the Linux/dev/nullplaceholder being reported readable and writable. It also handles a descriptor that is closed or reused during the wait, soselectno longer reachesNotImplemented. Your four commits are included unchanged, and I'll rebase once this one is merged. If you would rather take the kqueue part into this PR, just say so and I'll close mine.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T21:41:03Z.
This now conflicts with main after today's merges. Could you rebase onto current main? We'll re-run full CI on the new head (and #7248, stacked on this, after it).