libkernel: open, stat, lstat, access and unlink on a path through a regular file fail with ENOENT instead of ENOTDIR on Windows #8194

Closed
opened 2026-10-20 02:14:30 +00:00 by xXPBSXx · 1 comment
xXPBSXx commented 2026-10-20 02:14:30 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T02:14:30Z.


Repro

Windows host. f is a regular file. open("f/child", O_RDONLY), open("f/child", O_RDWR|O_CREAT), stat, lstat, access(…, F_OK), unlink("f/child") and the same with f/child/leaf.
Expected (FreeBSD 11.4 vfs_cache_lookup, sys/kern/vfs_cache.c:2105: a lookup in a vnode that is not a directory fails with ENOTDIR): ENOTDIR (20).
Actual: ENOENT (2); Linux hosts report ENOTDIR themselves. mkdir, rmdir and chflags already ask for the non-directory prefix.
Test: core/libs/tests/GuestFilesystem.cpp (new cases).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/enotdir-through-file-fb
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5934729215 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8194). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T02:14:30Z. --- ### Repro Windows host. `f` is a regular file. `open("f/child", O_RDONLY)`, `open("f/child", O_RDWR|O_CREAT)`, `stat`, `lstat`, `access(…, F_OK)`, `unlink("f/child")` and the same with `f/child/leaf`. Expected (FreeBSD 11.4 `vfs_cache_lookup`, sys/kern/vfs_cache.c:2105: a lookup in a vnode that is not a directory fails with ENOTDIR): ENOTDIR (20). Actual: ENOENT (2); Linux hosts report ENOTDIR themselves. `mkdir`, `rmdir` and `chflags` already ask for the non-directory prefix. Test: `core/libs/tests/GuestFilesystem.cpp` (new cases). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/enotdir-through-file-fb AI-assisted (Claude Code).
xXPBSXx commented 2026-10-20 02:24:43 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T02:24:43Z.


More calls with the same bug (open, stat, lstat, access and unlink are fixed by #8195): chmod, truncate, utimes and rename in 8199; chdir, remove, opendir, fopen and freopen in 8200. All use the helper from #8195. A trailing-slash path (file/) is a separate case and is not covered.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6281873939 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8194#issuecomment-6281873939). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T02:24:43Z. --- More calls with the same bug (open, stat, lstat, access and unlink are fixed by #8195): chmod, truncate, utimes and rename in 8199; chdir, remove, opendir, fopen and freopen in 8200. All use the helper from #8195. A trailing-slash path (`file/`) is a separate case and is not covered.
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#8194
No description provided.