libkernel_sys: link, symlink, pathconf and fchmodat fail with ENOENT instead of ENOTDIR when a path component is a regular file (Windows) #8521

Closed
opened 2026-10-20 14:51:19 +00:00 by xXPBSXx · 0 comments
xXPBSXx commented 2026-10-20 14:51:19 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T14:51:19Z.


Repro

Windows host, file a regular file: link("file/child", "new"), link("other", "file/child"), symlink("t", "file/child"), pathconf("file/child", _PC_NAME_MAX) and fchmodat(AT_FDCWD, "file/child", 0600, 0) return -1 with errno 2.
Expected (FreeBSD 11.4 vfs_cache_lookup, sys/kern/vfs_cache.c:2104-2105; the same lookup as for open, stat, unlink, chmod, rename, chdir, opendir): ENOTDIR (20).
Actual: link_nid_postfix, symlink_nid_postfix, pathconf_nid_postfix and fchmodat_nid_postfix (libkernel_sys Export.cpp) map the host's not-found error to ENOENT without checking for a non-directory prefix.
Test: core/libs/tests/GuestKernelSys.cpp (new cases; guest_kernel_sys fails at them before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/enotdir-through-file-4
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5943877223 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8521). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T14:51:19Z. --- ### Repro Windows host, `file` a regular file: `link("file/child", "new")`, `link("other", "file/child")`, `symlink("t", "file/child")`, `pathconf("file/child", _PC_NAME_MAX)` and `fchmodat(AT_FDCWD, "file/child", 0600, 0)` return -1 with errno 2. Expected (FreeBSD 11.4 `vfs_cache_lookup`, sys/kern/vfs_cache.c:2104-2105; the same lookup as for open, stat, unlink, chmod, rename, chdir, opendir): ENOTDIR (20). Actual: `link_nid_postfix`, `symlink_nid_postfix`, `pathconf_nid_postfix` and `fchmodat_nid_postfix` (libkernel_sys `Export.cpp`) map the host's not-found error to ENOENT without checking for a non-directory prefix. Test: `core/libs/tests/GuestKernelSys.cpp` (new cases; `guest_kernel_sys` fails at them before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/enotdir-through-file-4 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#8521
No description provided.