fix(libkernel_sys): fail fpathconf with EOPNOTSUPP and fchdir with EINVAL on a ksem id, as FreeBSD 11.4 does #24484
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/24484"
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 brajankw on 2026-11-20T17:23:53Z.
What
A ksem id is a host null device descriptor here, so
fpathconfanswered it as a file andfchdirfailed withENOTDIR. FreeBSD 11.4'skern_fpathconfanswers_PC_ASYNC_IOfor any descriptor and fails withEOPNOTSUPPfor one without a vnode that is neither a pipe nor a socket, andsys_fchdirtakes the vnode throughgetvnode, which fails withEINVAL.DescriptorHasNoVnode_nid_no_patchnow counts a ksem id, which givesfchdiritsEINVAL.fpathconfusesDescriptorHasNoVnode_nid_no_patchin place of its own kqueue check. So any other descriptor that it finds without a vnode, such as a host block device, also getsEOPNOTSUPPthere instead of file values, askern_fpathconfgives. Pipes and sockets are answered before, as they were.IsKsemDescriptor, which this uses, is replaced byDuplicateKsemDescriptorin open #22191. The two merge without a textual conflict, but whichever lands second needs a rebase that keeps a ksem predicate, or the build breaks. I will rebase this as soon as #22191 lands.GuestKernelSys.cpp, through bothfpathconfexports andfchdir.Tested
Linux (Debian 13, GCC 14.2.0, Release). Head
58b8da419b, the single commit onmainc8f72e905c.main84e16538d4,guest_kernel_sysaborts at the ksemfpathconfcheck with errno 22.58b8da419b,ctestoverguest_kernel_sys,guest_kernel_sys_ksem,guest_kqueueandguest_filesystem: all pass.ctest(6393 tests,-j 12) on this branch and my other eleven branches of this round, merged ontomain84e16538d4: 6378 passed. The 15 failures also fail onmainin this environment:.gitdirectory, network access or a passwd entry for the user:conventions_git_errors,test_script_registration,web_library_assets,title_run,title_run_identity,guest_kernel_sys_login,guest_net_ctl,guest_getloginandguest_getlogin_no_session;agc_driverGPU cases fail the same way onmain:prepared_shaderswith itsindirect,uncachedanddebugforms, andstorage_file_write;agc_driver_image_table_packed_guardsis unstable onmainas well (2 of 10 runs passed on its own onmain3f4693be43).python3 tools/check_conventions.py --base origin/main: passed.python3 tools/pr_overlap.py --branch fix/libkernel-ksem-fpathconf-fchdir: could not compare #7121, #9389, #9557, #9566, #12682, #12688, #12700, #12965, #15037 and #18457, which conflict withmain; none of their diffs touchesDescriptorHasNoVnode_nid_no_patch,_fpathconf_nid_postfixorfchdir_nid_postfix.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 PrivacyOnion on 2026-11-20T18:41:23Z.
Review: APPROVED
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against
58b8da419b:tools/check_conventions.pypassed.guest_kernel_sys_testsbuilt cleanly.guest_kernel_sys):core/libs/prx/libkernel/File/src/DescriptorControl.cpp,core/libs/prx/libkernel_sys/Export.cppreverted tomainand the new tests kept, the suite fails: Restoring the change makes it pass again.Looks Good To Me
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T05:33:48Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the inspected code and included tests support the stated ksem behavior.
What I ran
Read the prepared diff and source context at head
58b8da419b44975c89d09f8fece6e3fd988a1c76. I ran no commands; reported test results below are from the PR description.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read all three changed files listed as reviewed in the manifest:
core/libs/prx/libkernel/File/src/DescriptorControl.cpp,core/libs/prx/libkernel_sys/Export.cpp, andcore/libs/tests/GuestKernelSys.cpp. No files were excluded bymanifest.json. I did not run tests or verify the author-reported results, other platforms, or behavior on a physical console.To get this to a good state
Nothing is required.