fix(libkernel): answer fcntl status flags on libSceNet sockets #4924
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4924"
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 nicolasfalesy on 2026-10-13T04:29:37Z.
What
Follow-up to #4391. With libSceNet sockets on ordinary descriptor numbers, a title that makes a libSceNet socket non-blocking the POSIX way,
fcntl(fd, F_GETFL)thenfcntl(fd, F_SETFL, flags | O_NONBLOCK), reachesFile::Fcntl, whose classification throws for a socket:libSceNet now registers a status control with libkernel, the same way it registers its option setter (
KernelSetSocketStatusControl_nid_no_patch).fcntlasks it before falling back toFile::Fcntl, and for a libSceNet socket it behaves asfcntlalready does for libkernel sockets:F_GETFLreturnsO_RDWRplusO_NONBLOCKwhen set,F_SETFLappliesO_NONBLOCKthroughSO_NBIO(sosceNetGetsockoptsees the same state), flags outside the status mask fail withEOPNOTSUPPand other commands withEINVAL.This branch contains #4391's commits; the change here is the last commit (1836f8e93). It only makes sense on top of #4391: on
main, libSceNet numbers can collide with host descriptors.Tested
Linux (Arch, GCC 16.2.1, Release), on #4391's head
e0ec0c809plus this commit:CheckKernelStatusFlagsinguest_sce_net: get, set and clearO_NONBLOCKwithfcntlon a libSceNet socket, checked againstSO_NBIO, plus theEOPNOTSUPPandEINVALcases. Passes 5/5. Without the libSceNet change it aborts with thefcntl: descriptor 7 is neither a file ...error above.guest_sce_net,guest_socket_descriptors,guest_poll,guest_select,guest_dup,guest_socket_pair: all pass.--to-intel), 3 runs of 60 s: no longer stops onfcntl; its next stop ispoll: descriptor 47 is neither a socket nor a pipe, i.e.pollnot yet knowing libSceNet sockets. That is a separate change and not part of this PR.tools/check_conventions.py --base upstream/mainpasses.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)pollnext)Imported from boykopovar/AnyPS5. Originally posted by VitzS7 on 2026-10-13T06:29:31Z.
Heads-up from #4910, which also touches
Equeue.cppL596-605: once your lookup lands, a libSceNet socket reachesGuestSockets::Kindthere as a descriptor that is not in the libkernel socket table, so akeventread or write event on it would answerEINVALinstead of registering a knote. I noted on that PR that the native lookup you register is the natural source for the kind, and that I will rebase on whichever of the two lands first and ask it there rather than deriving the kind from the host descriptor alone. Nothing for you to change here.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T08:20:49Z.
Windows test of this PR.
Environment: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release,
BUILD_TESTING=ON,-j2,libusb-cmakefrom a local checkout. Built frommainc2565f014with this PR and ten other open PRs (#4972, #4967, #4966, #4945, #4938, #4936, #4933, #4898, #4896, #4888) merged together; the merges had no conflict.Result: guest_dup and guest_fstatfs (2 of 2; the branch is contained in #4933) pass.
Not checked: whether the test fails without the change in the library code; the PR was not tested alone, only in the combined merge; no title run; Linux not tested.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by YossiYad on 2026-10-14T07:16:22Z.
Linux title run with ProsperoLight (PPSA99002, catalog release): Bazzite 44, GCC 16.2, Release, RX 7700 XT (RADV), head
1836f8e93merged intomain315260903.mainalone: ProsperoLight aborts during start-up withfcntl: descriptor 48 is neither a file, a directory, a pipe nor a character device, the stop this PR describes.fcntlstop is gone. The title gets through its UI start-up (EGL surface, GL programs, pad and audio) and then stops on the same socket inpoll:poll: descriptor 48 is neither a socket nor a pipe. That is the stop #4933 handles. With #4933, which carries this commit, onmainf74ec639c, ProsperoLight ran the full 60 s without a stop.guest_sce_netpasses 3 of 3 (--repeat until-fail:3) on the merged tree.Merging into current
mainconflicts only incore/libs/tests/GuestSceNet.cpp:mainaddedCheckSocketError();on the line where this PR addsCheckKernelStatusFlags();. Keeping both calls builds, and that's the tree the runs above used.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T17:23:43Z.
Rebased onto current
main(#4391 is merged, so only thefcntlcommit remains; one adjacency conflict inGuestSceNet.cpp'smain()kept both calls). Checked: build and ctest for libSceNet/libkernel green,guest_sce_netfails without the change, flag values match FreeBSD (O_NONBLOCK4,EOPNOTSUPP45,EINVAL22). Merging once the full build is green; thanks also to @YossiYad and @xXPBSXx for the runs.