fix(libkernel): report O_RDWR from F_GETFL on both ends of a pipe #8544
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8544"
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 Retr0G28 on 2026-10-20T16:07:24Z.
What
fcntl(F_GETFL)on apipeend reportedO_RDONLYfor the read end andO_WRONLYfor the write end, because the access mode came from the host, where pipe ends are one-way. FreeBSD 11 pipes are bidirectional:kern_pipeopens both ends withfinit(..., FREAD | FWRITE, ...)(sys/kern/sys_pipe.c), andkern_fcntlbuildsF_GETFLfromOFLAGS(fp->f_flag)(sys/kern/kern_descrip.c), so both ends reportO_RDWR.The guest descriptor table now marks descriptors created by
pipe. The mark followsdup,dup2andF_DUPFDwith the shared status flags, an entry made byopenreplaces it, andclosedrops it.F_GETFLreportsO_RDWRfor a marked descriptor and still asks the host for every other descriptor, so a FIFO opened withO_RDONLYkeeps reportingO_RDONLY, as on FreeBSD. The sentence about this gap is cut from the fcntl entry indocs/dev/debt/libkernel.md.Test changes:
guest_kernel_fcntl(PipeFlagsRoundTrip) now expectsO_RDWRon both ends, with and withoutO_NONBLOCK, and on anF_DUPFDcopy of the write end.guest_dupnow expectsO_RDWR | O_NONBLOCKin its shared-status-flags case.Tested
Windows 11, WinLibs MinGW-w64 GCC 15.2.0 r7, CMake + Ninja, Release,
-DBUILD_TESTING=ON, onmain77e31219c.guest_kernel_fcntlwith the new expectations fails (exit 0xc0000409 from the failedRequire). With this PR it passes.-R "fcntl|pipe|dup|poll|select|kqueue|stdio|descriptor|socket" -E "^agc_": 40 of 40 pass when run serially.guest_test (547): the only failures that remain when run alone areguest_module_dirandguest_module_identity. They fail the same way onmainon this machine (Windows Defender blocks a file they generate, WinError 225).python tools/check_conventions.py --base origin/mainreports no errors. The one warning is the existing length of the fcntl debt entry, which this PR shortens.guest_dupandguest_kernel_fcntlpass, and both fail withmain'sDescriptorControlandStdio.cpp(comment below). Not run on bare-metal Linux.Overlap:
tools/pr_overlap.pycould not compare some open PRs. I checked the ones that touch the same code files (#7121, #6977, #6044, #5021, #6936, #7201, #7530). None changes the access modeF_GETFLreports for a pipe. The rest touch only other lines ofdocs/dev/debt/libkernel.md.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)Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-21T08:45:34Z.
Linux data point for
2d1fa5aea5: WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal Linux), GCC 13.3.0, Release,BUILD_TESTING=ON, PR head alone (not merged ontomain).ctest -R '^(guest_dup|guest_kernel_fcntl)$'passes 3 of 3 (both tests).DescriptorControl.hpp,DescriptorControl.cppandStdio.cpp(libkernel/File) restored to the merge-base (new test cases kept): both fail (Subprocess aborted).Not tested: macOS, Windows, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by DavidSamir on 2026-10-22T08:50:03Z.
Hi @Retr0G28, a merge-order note: my #9557 (pipe
SIGIOowner) and #9561 (O_FSYNC) edit the samefcntlrow ofdocs/dev/debt/libkernel.mdas this PR, and they conflict in that file only. Proposal: no dependency either way; whichever merges second keeps every sentence. Does that work for you? I'll record it in their checklists.AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Retr0G28 on 2026-10-22T15:27:48Z.
@DavidSamir Yes, that works for me: no dependency either way, and whichever of us merges second rebases and keeps every sentence of the
fcntlrow. I checked withgit merge-tree: this PR conflicts with #9557 and #9561 only in that row ofdocs/dev/debt/libkernel.md.