fchdir on a kqueue descriptor fails with ENOTDIR on Windows, FreeBSD answers EINVAL #9993

Closed
opened 2026-10-23 03:22:57 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-23 03:22:57 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-23T03:22:57Z.


FreeBSD 11.4 sys_fchdir takes the descriptor through getvnode (sys/kern/vfs_syscalls.c, the fp->f_vnode == NULL || fp->f_ops == &badfileops check at lines ~3871-3875), which fails a descriptor without a vnode, and a kqueue has none, with EINVAL. fchdir_nid_postfix asks DescriptorHasNoVnode_nid_no_patch and answers ENOTDIR only for descriptors that have a vnode; the kqueue's host placeholder is a character device (NUL on Windows, /dev/null on POSIX hosts), which the helper counts as a vnode. Probe on Windows 10: fchdir(kqueue()) -> ENOTDIR (20), FreeBSD EINVAL (22); fchdir(pipe end) -> 22 already (since #9131).

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5991296635 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/9993). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-23T03:22:57Z. --- FreeBSD 11.4 `sys_fchdir` takes the descriptor through `getvnode` (sys/kern/vfs_syscalls.c, the `fp->f_vnode == NULL || fp->f_ops == &badfileops` check at lines ~3871-3875), which fails a descriptor without a vnode, and a kqueue has none, with `EINVAL`. `fchdir_nid_postfix` asks `DescriptorHasNoVnode_nid_no_patch` and answers `ENOTDIR` only for descriptors that have a vnode; the kqueue's host placeholder is a character device (`NUL` on Windows, `/dev/null` on POSIX hosts), which the helper counts as a vnode. Probe on Windows 10: `fchdir(kqueue())` -> ENOTDIR (20), FreeBSD EINVAL (22); `fchdir(pipe end)` -> 22 already (since #9131). AI-assisted (Claude Code).
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#9993
No description provided.