Repository navigation
Conversation
fcntl and sceKernelFcntl answered EBADF (sceKernelFcntl threw) for every descriptor outside the libSceNet socket table, so files, pipes, directories and descriptors 0 to 2 could not be queried or changed. Observed: Yamagi Quake II (PPSA99007) stops with "Sys_Error: change stdin to blocking Bad file descriptor", from fcntl(fileno(stdin), F_SETFL, fcntl(0, F_GETFL, 0) & ~FNDELAY) (yquake2 src/backends/unix/system.c:81-86). Predicted from the titles' sources and decoded call sites: XPSemu (PPSA97358, 97 fcntl sites: F_GETFD 12, F_SETFD 20, F_GETFL 8, F_SETFL 9, F_DUPFD 1, F_DUPFD_CLOEXEC 7, F_GETLK 9) fails in qemu_init_main_loop, where its pipe2 (pipe plus F_SETFD FD_CLOEXEC) and glib's g_unix_set_fd_nonblocking (F_GETFL, F_SETFL) build the event notifier (util/event_notifier-posix.c:44-67); VLC (PPSA85300, 43 sites, F_RDAHEAD on every file it opens), RetroArch (PPSA99169, 17), Porpoise (PPSA99764, 13) and Ruffle (9) call it on files and pipes. The commands follow FreeBSD 11.4 kern_fcntl and kern_dup (sys/kern/kern_descrip.c:479-799, 812, release/11.4.0 8c639945): F_GETFD/F_SETFD keep the close-on-exec flag per descriptor, F_GETFL reports the host access mode with the status flags, F_SETFL changes only O_NONBLOCK, O_APPEND, O_ASYNC, O_FSYNC, O_DIRECT and FRDAHEAD, F_DUPFD/F_DUPFD_CLOEXEC give the lowest free descriptor at or above the start through dup (EINVAL for a negative start), F_DUP2FD goes through dup2, F_RDAHEAD/F_READAHEAD set FRDAHEAD on files (EBADF on pipes, ENOTTY elsewhere), and unknown commands fail with EINVAL. Status flags live in a guest table shared by dup, dup2 and F_DUPFD like an open file description. O_NONBLOCK switches a pipe (PIPE_NOWAIT on Windows, where an empty read and a full write now report EAGAIN; the host flag on Linux). Record locks use the host POSIX locks on Linux and throw on Windows. Changes the host cannot model throw naming the flag and descriptor kind. Sockets keep their path unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
ioctl and _ioctl answered EBADF for every descriptor outside the libSceNet socket table. Decoded call sites: PS5MC (PPSA99420, FIONBIO x3, FIONREAD x2, TIOCGWINSZ x3), ProsperoTV (PPSA99003, FIONBIO on a pipe once poll on pipes is in), XPSemu (PPSA97358, 21 sites). Following FreeBSD 11.4 kern_ioctl (sys/kern/sys_generic.c:758), vn_ioctl (sys/kern/vfs_vnops.c:1488), pipe_ioctl (sys/kern/sys_pipe.c:1346) and randomdev_ioctl (sys/dev/random/randomdev.c:301), release/11.4.0 8c639945: FIONBIO sets or clears O_NONBLOCK through the same status flags as fcntl F_SETFL (EFAULT for a null argument before EBADF); FIONREAD reports the size past the offset of a file, the queued bytes of a pipe's read end, 0 on its write end, ENOTTY on the random device, and throws on a directory or another character device; termios requests (group 't', TIOCGWINSZ included) fail with ENOTTY, as tcgetattr already takes these descriptors as not a terminal; any other request throws naming the request and descriptor kind. Sockets keep their path unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This was referenced Oct 11, 2026
|
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Carry #3757 by @screamm (
feat(libkernel): support fcntl on non-socket descriptorsandfeat(libkernel): support ioctl on non-socket descriptors).fcntl,sceKernelFcntl,ioctland_ioctlpreviously answeredEBADFfor every descriptor outside thelibSceNetsocket table. This blocked titles such as Yamagi Quake II (PPSA99007, stops with "Sys_Error: change stdin to blocking Bad file descriptor"), XPSemu (PPSA97358), VLC (PPSA85300), RetroArch (PPSA99169), Porpoise (PPSA99764), and Ruffle.DescriptorControl.cpptracking close-on-exec flags and shared status flags across duplicated file descriptors (dup,dup2,F_DUPFD), matching FreeBSD's open file description model.F_GETFD/F_SETFD,F_GETFL/F_SETFL,F_DUPFD/F_DUPFD_CLOEXEC,F_DUP2FD*, andF_RDAHEAD/F_READAHEAD.ioctlrequestsFIONBIOandFIONREADon non-socket descriptors (files, pipes, random device), returningENOTTYfor terminal group 't' requests (TIOCGWINSZ).EAGAINon empty reads and full writes on both Windows and Linux.Closes #3757.
Tested
guest_kernel_fcntlandguest_duptests pass.tools/check_conventions.pypasses with zero errors.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)