libkernel: fcntl and ioctl reject every non-socket descriptor (Yamagi Quake II, XPSemu, VLC, RetroArch); branch ready #3757
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 screamm on 2026-10-11T16:30:49Z.
fcntl,sceKernelFcntl,ioctland_ioctlwork only on libSceNet sockets; every other descriptor getsEBADF. That is observed in Yamagi Quake II's run log (Sys_Error: change stdin to blocking Bad file descriptor) and, by call-site count in the eboots, XPSemu (PPSA97358, 97fcntlsites, including QEMU's event notifier which exits on failure), VLC (PPSA85300, 43,F_RDAHEADon every opened file), RetroArch (17), Porpoise (13) and Ruffle (9) all reach it.Branch ready:
screamm:feat/libkernel-fcntl-files(two commits onmaina11c8f7f, head88c9ee8d:feat(libkernel): support fcntl on non-socket descriptors,feat(libkernel): support ioctl on non-socket descriptors). I cannot open it as a PR because of the intake check; anyone eligible is welcome to carry it, keeping the commits as they are. It touches the sameclose/dup/pipecode inStdio.cppandOpen.cppas the open #3649, #3644 and #3681, so expect textual conflicts.File/src/DescriptorControl.cppkeeps a per-descriptor close-on-exec flag and a status-flag set shared by duplicates (FreeBSD's open file description), created byopen/pipe/dup/dup2and forgotten byclose; descriptors the table has not seen (0 to 2) start from the host's flags. Following FreeBSD 11.4kern_descrip.ckern_fcntl/kern_dup,fcntl.h,sys_pipe.c,vfs_vnops.c,sys_generic.c,randomdev.canddevfs_vnops.c(8c639945):F_GETFD/F_SETFD;F_GETFL(host access mode plus flags, viaNtQueryObjecton Windows) andF_SETFLchanging only the settable bits;F_DUPFD/F_DUPFD_CLOEXEC(lowest free descriptor at or above the start,EINVALfor a negative start beforeEBADF),F_DUP2FD*throughdup2;F_RDAHEAD/F_READAHEADon files; unknown commandsEINVAL; record locks through the host's POSIX locks on Linux.O_NONBLOCKon a pipe switches the Windows pipe to non-blocking mode (empty read and full write returnEAGAIN) and sets the host flag on Linux; on files, directories and the random device it is only recorded because their reads never block.ioctl:FIONBIOon the same flags,FIONREAD(file size minus offset, queued bytes on a pipe read end, 0 on its write end,ENOTTYon the random device), the terminal't'groupENOTTY.O_APPENDon a Windows file,O_FSYNCon a file,O_ASYNCon a pipe or character device (noSIGIO),O_NONBLOCKon a Windows console,F_GETOWN/F_SETOWN/F_SETLK_REMOTE, record locks on Windows or character devices,F_GETLKwithF_UNLCK,FIONREADon a directory or character device, any other ioctl request. Sockets keep the previous path unchanged (they still answerF_GETFD/F_SETFDwithEINVAL; XPSemu may call those on sockets, left for a follow-up). Thefcntl,sceKernelFcntlandioctlTechnicalDebt entries are updated.guest_kernel_fcntlcovers flag round trips on a file, stdin and both pipe ends,F_DUPFDwith a start, theEINVALcases,EAGAINon an empty and a full non-blocking pipe, the ioctl cases, the throw messages and the unchanged socket path;guest_dupchecks that duplicates share status flags and clear close-on-exec. Known pre-existing gap left alone:readv/writevon a non-blocking pipe report 11 (EDEADLK) instead ofEAGAINthrough the host error mapping inStdio.cpp.Tested on Windows 11 Pro 26220, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release,
BUILD_TESTING=ON, full build includinglibs:guest_kernel_fcntl,guest_dup,guest_udp,guest_socket_pair,guest_socket_read_write,guest_poll,guest_terminal,guest_file_vector,guest_aio3/3;ctest -j8 -E "^agc_driver_|^video_out_flip"under heavy host load (five other builds): beyond the knownwindows_exceptions(#3411, fixed by #3415),guest_kernel_sys(#3510),guest_filesystem(#3518) and theguest_ampr_markersflake (#3371), three timeouts (guest_raise_exception,tls_function_coverage_register_address_loads,guest_pthread_start) that pass when rerun serially; withmain'sOpen.cpptwo of the nine tests fail;tools/check_conventions.py --base mainandgit diff --checkpass. Not run on Linux.Written with Claude Code assistance (implementation by a subagent, reviewed and validated in this session).
Imported from boykopovar/AnyPS5. Originally posted by ahir061 on 2026-10-11T17:05:14Z.
I can carry this: I’ll open a PR with your two commits unchanged (they apply cleanly on current main
a11c8f7f) and add Linux results, since it hasn’t been run there yet. Thanks for writing it up.Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T04:56:40Z.
Another title on this stop: PPSA24423, Windows 10, GCC, RTX 4080 SUPER,
mainceb342b94(no open PR), 60 s run, import audit 0 absent imports. Within the 60 s run (the log shows shader disk cache activity before it) it aborts withThe thrown message does not log the
fcntlcommand, so which command the title issues is not known from this run. This is the non-socket descriptor rejection insceKernelFcntl(Open.cpp) this issue describes, so I did not open a separate issue.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T07:53:30Z.
Title test of PR #3840, which carries the commits of this issue's branch, Windows 10, MinGW GCC, RTX 4080 SUPER: this PR merged locally onto current
maind06c06565(clean merge, no conflicts). Full build with-j4succeeded; thectestsubset matchingfcntl|ioctl|file|open|descriptor|stdio|pipe|dup|kernelran 44 tests: 44 passed (video_out_flip_reopenskipped).PPSA24423 (0 absent imports; stopped on
mainceb342b94atsceKernelFcntl: file descriptors are not implemented, fd=6, see #3757): with this change the fcntl abort is gone. The run (150 s limit) then ends after about 70 s with a different abort:So the title gets past
fcntland reaches rendering. I did not look at the picture and one run only.AI-assisted (Claude Code).