libkernel: unlink, remove, rename and open fail with ENOENT or EINVAL instead of ENOTDIR for a regular file named with a trailing slash on Windows #8679

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

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T20:53:13Z.


Repro

Windows host, file a regular file: unlink("file/") fails with errno 22, remove("file/") with 2, rename("file/", "other") with 5 and open("file/", O_RDONLY) with 22. Under a mount alias (/app0/file/) the slash is dropped from the resolved path.
Expected (FreeBSD 11.4 lookup, sys/kern/vfs_cache.c:2104-2105): ENOTDIR (20), and the file stays.
Actual: ResolveAlias keeps the trailing slash only off Windows, and the four calls do not check for a non-directory named with a slash.
Test: core/libs/tests/GuestFilesystem.cpp (the trailing-slash block, built only off Windows so far; it fails at its first line on Windows before the fix).
Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/trailing-slash-enotdir
Earlier attempts: #5165 and #5266 (closed).
AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5949476763 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/8679). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-20T20:53:13Z. --- ### Repro Windows host, `file` a regular file: `unlink("file/")` fails with errno 22, `remove("file/")` with 2, `rename("file/", "other")` with 5 and `open("file/", O_RDONLY)` with 22. Under a mount alias (`/app0/file/`) the slash is dropped from the resolved path. Expected (FreeBSD 11.4 lookup, sys/kern/vfs_cache.c:2104-2105): ENOTDIR (20), and the file stays. Actual: `ResolveAlias` keeps the trailing slash only off Windows, and the four calls do not check for a non-directory named with a slash. Test: `core/libs/tests/GuestFilesystem.cpp` (the trailing-slash block, built only off Windows so far; it fails at its first line on Windows before the fix). Fix branch: https://github.com/xXPBSXx/AnyPS5/tree/fix/trailing-slash-enotdir Earlier attempts: #5165 and #5266 (closed). 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#8679
No description provided.