fix(libkernel): report socket status from fstat on a guest socket #4351
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4351"
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 milescoviello on 2026-10-12T07:25:29Z.
What
Fixes #4051.
fstaton a guest socket descriptor passed the guest number (from0x10000000up) to the host, which has no such descriptor, so it threwFillFileStat: fstat failed for fd 268435460.sceKernelFstatreturnedEBADFfor the same descriptor. FreeBSD fills the stat buffer for a socket throughsoo_stat(sys/kern/sys_socket.c):pru_sense_null(sys/kern/uipc_socket.c) then setsst_blksize = so->so_snd.sb_hiwat.fstatandsceKernelFstatanswer a guest socket from the socket table:S_IFSOCK, the read bits until the receive side is shut down and drained, the write bits until the send side is shut down,st_sizefrom the queued bytes (FIONREAD),st_blksizefromSO_SNDBUF. Every other field is zero, as after FreeBSD'sbzero.shutdownrecords which side it closed.EBADFinstead of the throw.FIONREADper datagram and doublesSO_SNDBUF, andsocketpairends reportst_dev/st_ino0.Tested
Ubuntu 24.04, GCC 13.3 (CI's compiler), Release with CI's configure flags.
guest_socket_pairgained checks on a stream pair: a fresh end reports mode0140666and size 0, 5 queued bytes show asst_size5 throughsceKernelFstat,SHUT_WRleaves0140444,SHUT_RDkeeps the read bits while data is queued and drops them once it is read (0140222), and a closed descriptor returnsEBADFand the SCEEBADFcode. With main's library sources it aborts withFillFileStat: fstat failed for fd 268435460. It passes with this change.ctest -R '^guest_' -E '^guest_video_out_': 289/289 pass.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T13:33:51Z.
Windows test of head
a84aa9ademerged onto currentmain(a1a9c3db5, clean merge): Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, full build 0 errors. The 27 tests matchingguest_(socket|poll|select|dup|sce_net|fstat|posix_filesystem|tcp|udp|fcntl|equeue|filesystem|net)pass, includingguest_socket_pair(the new fstat cases),guest_tcp,guest_udpandguest_poll.Not checked: that the new
guest_socket_paircases fail without the change, Linux, and a title run. Note for ordering: this PR conflicts with #4391 (Stdio.cpp,SocketRuntime.hpp,TechnicalDebt.md), which makesfstaton a guest socket throw as unimplemented; see https://github.com/boykopovar/AnyPS5/pull/4391#issuecomment-6125218729.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-12T13:35:36Z.
Thanks for the Windows run and for mapping the overlap with #4391. This PR finds guest sockets with the
FirstDescriptorrange, which #4391 removes; if #4391 lands first I'll rebase this ontoGuestSockets::IsOpenand rerun the tests, and if this lands first the same change applies to #4391's merge.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T14:42:08Z.
Windows test: head
a84aa9ademerged onto currentmain8fa5cc486(clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release,-j2: full build 0 errors; ctest with the filterguest_socket_pair: guest_socket_pair passed (1 test(s), 0 failed);python tools/check_conventions.py --base upstream/mainpassed. I did not run the new tests againstmainwithout the change.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T21:10:32Z.
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)docs/dev/debt/libkernel.mdL142-143core/libs/prx/libkernel/Socket/src/Udp.cppL79Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:21:23Z.
Closing: no title is shown to call
fstaton a socket, where main stops atFillFileStat: fstat failed for fd ..., and the result here differs from the console in the ways its TechnicalDebt entry lists. Reopen with the title ID and that log line.Pull request closed