Repository navigation
feat(libkernel): implement tcgetattr and tcsetattr - #1738
Conversation
|
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.
|
|
Windows run, since the description lists Linux only: Windows 11 Pro (26200), MinGW-w64 GCC 15.2.0 (WinLibs r7, the CI build), Release, configured like CI, Ryzen 9 5900X. This commit merged onto
So the Windows-only branch, AI-assisted: yes (Claude Code). |
|
Second Linux run, on current main: Ubuntu 24.04, GCC 13.3.0, glibc 2.39, Release. The commit cherry-picks cleanly onto Since the description names the kernel routines without linking them, I checked the socket error codes against FreeBSD stable/11:
The |
A title's descriptors are taken as never being terminals: a file or pipe gets ENOTTY with the termios untouched, a socket gets what its protocol answers a termios ioctl on FreeBSD (EADDRNOTAVAIL for AF_INET, EOPNOTSUPP otherwise), and a closed or invalid descriptor EBADF. tcsetattr gives EINVAL for an action other than TCSANOW, TCSADRAIN or TCSAFLUSH, with or without TCSASOFT, before anything else, and EFAULT for a null termios before the descriptor is checked; with TCSASOFT a null termios throws, where FreeBSD's libc faults copying it. What the console gives a title as descriptors 0 to 2 is unknown, as recorded in TechnicalDebt. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Checked against FreeBSD 11 ( Added one commit:
Merging once CI is green. |
af948ec to
96418e0
Compare
What
Adds
tcgetattrandtcsetattrto libkernel, in a newFile/src/Terminal.cpp, on the assumption that a title's descriptors are never terminals: a title runs without a controlling terminal, and what the console gives it as descriptors 0 to 2 is unknown (recorded in TechnicalDebt). The errors are the ones FreeBSD 11'stermios.candioctlpath give for a descriptor that is not a terminal:ENOTTY, andtcgetattrleaves thetermiosuntouched, asTIOCGETAcopies out only on success. A guest socket gets what its protocol's control routine returns to a termios ioctl,EADDRNOTAVAILforAF_INET(in_controlwithout an interface) andEOPNOTSUPPotherwise (in6_control,pru_control_notsupp).tcsetattrgivesEINVALfor an action other thanTCSANOW,TCSADRAINorTCSAFLUSH, with or withoutTCSASOFT, before anything else;EFAULTfor a nulltermios, whichsys_ioctlcopies in before it looks at the descriptor. WithTCSASOFTand a nulltermiosFreeBSD's libc faults while copying it, so that case throws.EBADF) when it is negative, a closed guest socket, or a host descriptor the host does not know:fcntl(F_GETFD)on Linux,_get_osfhandleon Windows under the thread-local invalid-parameter handler, asNativeCloseinOpen.cppdoes.Of the 34 relinked titles in the homebrew catalog (#1578), 16 import
tcgetattrandtcsetattrand one stops attcgetattronmain4b6ab6b, PPSA99728 OpenRCT2 Native Port: relinked withmain's relinker and run for 8 s in a bubblewrap sandbox on Linux, it dies in the host loader withapp.elf: symbol lookup error: app.elf: undefined symbol: 5kBfZ40bAuk.Overlap: #1613 adds
isattyto libScePosixForWebKit through the host'sisatty, which can say yes to a host terminal on descriptors 0 to 2 where this says no; the two should agree once either lands. #1645 and #1192 insert source lines next toStdio.cppinlibkernel/CMakeLists.txt; this one goes afterNativeStat.cpp, so none of the three overlap. #1727 and #1091 add declarations toSocketRuntime.hppwhere this addsFamily; whichever merges second rebases one line.Tested
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ONon this branch (based onmain2b29784):ctest --repeat until-fail:3468/468;tools/check_test_registration.pyandtools/check_conventions.py --base upstream/mainpass.guest_terminaltest:ENOTTYwith an untouchedtermiosfromtcgetattr, and fromtcsetattrwith every valid action, on a file opened throughopen, descriptors 0, 1 and 2 and both ends of apipe;EADDRNOTAVAILon anAF_INETsocket with thetermiosuntouched;EINVALfor actions 3, -1 andTCSASOFT | 3even on an invalid descriptor;EFAULTfor a nulltermioseven on an invalid descriptor;EBADFfor -1, a closed socket and a closed file. Written before the implementation; it failed on the two unresolved exports and passes with it.libkernel.prxexports the NIDs (5kBfZ40bAuk,La7xW-jcZwQ).tools/import_audit.pyon five of the 16 catalog titles, absent imports onmain4b005b2 → this branch: PPSA17641 SymphonyStation5 35 → 33, PPSA97510 PSXS5 72 → 70, PPSA99000 ProsperoStore 40 → 38, PPSA99009 ProsperoLichess 37 → 35, PPSA99039 EVO Player 24 → 22. None of them loads yet; the remaining imports are listed in Four open-source homebrew titles stop at start-up on unresolved imports (sysctl, pthread_set_name_np, isatty, mkstemp, signal sets, Opus decoders) #1578.main6b56175), run 37822114975:guest_terminalpasses its three repeats, full suite 474/474. The only host call there is_get_osfhandleunder the invalid-parameter guard; the UCRT keeps descriptors 0 to 2 open in a child process, so the test'sENOTTYchecks on them hold.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)🤖 Generated with Claude Code