libkernel_sys: fchdir on a pipe or socket fails with ENOTDIR, where FreeBSD fails with EINVAL; fix branch ready #9130
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 xXPBSXx on 2026-10-21T12:47:37Z.
fchdir(fd)on a pipe end or a socket returnsENOTDIR. FreeBSD 11.4'ssys_fchdirresolves the descriptor withgetvnode, which fails withEINVALfor a descriptor that has no vnode; only a vnode that is not a directory (a regular file) reacheschange_dirand getsENOTDIR. A caller that tells "not a directory" from "not a file descriptor of that kind" by the error sees the wrong one.Cause.
fchdir_nid_postfixpasses theENOTDIRofGetDirectoryDescriptorPath_nid_no_patchstraight through for every descriptor that is not a directory.Observed on
main865166414f, Windows 10 (10.0.19045), WinLibs GCC 15.2.0 r7, Release (probe, other rows for comparison):fchdir(-1)fchdir(regular file)fchdir(pipe read end)fchdir(socket)I have not found a title that stops on this.
Fix.
xXPBSXx:fix/fchdir-non-vnode(c8edf9477d, one commit onmain865166414f, three files, +15/-1). When the lookup fails withENOTDIRand the descriptor is neither a vnode (File::IsVnode) nor the random device,fchdirreturnsEINVAL; the debt entry records the three errors.guest_kernel_sysgets pipe and socket cases: it fails without the change (exit code 0xc0000409 on Windows, 3 of 3;Subprocess abortedon Linux) and passes with it (Windows 3 of 3, Linux 3 of 3); the filesystem, rename, dup and directory tests pass (12 of 12 on Windows).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-21T22:47:21Z.
PR #9131 now carries the reported fix, and the current diff limits
EINVALto descriptors without vnode, character-device or random-device status. I left a focused test note there: its/dev/randomcase is covered by the explicit random-device exception, so an ordinary character device (/dev/nullorNUL) would better pin the preservation ofENOTDIRthat this issue identified.