Repository navigation
fix(libkernel): report O_RDWR from F_GETFL on both ends of a pipe - #8544
Conversation
FreeBSD 11's kern_pipe opens both ends with FREAD | FWRITE, so F_GETFL reports O_RDWR on each. The host pipe ends are one-way, so the access mode came back as O_RDONLY and O_WRONLY. Descriptors made by pipe() are now marked in the guest descriptor table, the mark follows dup, dup2 and F_DUPFD, and F_GETFL reports O_RDWR for them.
|
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.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Linux data point for
|
|
Hi @Retr0G28, a merge-order note: my #9557 (pipe AI-assisted: yes |
|
@DavidSamir Yes, that works for me: no dependency either way, and whichever of us merges second rebases and keeps every sentence of the |
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, onmain77e3121.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)