fix(libkernel): fail unlink, remove, rename and open of a file named with a trailing slash with ENOTDIR on Windows #8680
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8680"
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-20T20:53:17Z.
What
A name that ends in
/must be a directory. FreeBSD 11.4 fails the lookup withENOTDIRotherwise (vfs_cache_lookup, sys/kern/vfs_cache.c:2104-2105). On WindowsResolveAliasdropped the slash for paths under a mount alias (it kept it only off Windows, #4681), andunlink/sceKernelUnlink,remove,renameandopen/sceKernelOpennever asked whether a name with a slash is a non-directory, so they failed withENOENT,EINVALorEIO.ResolveAliasnow keeps the slash on every host, and a shared helper (NamesNonDirectoryWithSlash_nid_no_patch) makes the four calls answerENOTDIR(the source, and an existing source's destination, inrename). The trailing-slash block ofguest_filesystem, which was compiled only off Windows, now runs on Windows.Fixes #8679
Scope note: this changes the guest path resolver (
General.cpp,ResolveAlias) and the kernel-style lookup ofunlink,remove,renameandopen, not the stdio/printf formatting that the console implements with Dinkumware;removeandrenamefollow the kernel lookup like the merged #8200 and #8199.git merge-treeagainstupstream/main, #8626, #8522, #8603, #8663, #8312 and #5528 is clean;pr_overlapwas not run.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0, Release,
-j4, on upstream/main26740077bd+ this commit:guest_filesystem: fails at the first trailing-slash check (guest errno 2) with the code taken back to main and the block enabled, passes with the change (3 of 3 runs).unlink,remove,renameoropen(65 test targets, 87 ctest entries): 85 pass, 2 were not run (guest_memory_pool_stats,guest_fstatvfs_conversion; their executables were not built, unrelated).python tools/check_conventions.py --base upstream/main: passes.lstat,access,chmod,truncate,utimes,readlink,fopenandopendirstill answer ENOENT or EINVAL forfile/on Windows; they are left for follow-ups. Earlier attempts: #5165, #5266 (closed).Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryAI-assisted (Claude Code).
🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T20:57:30Z.
Review: COMMENTED
One related trailing-slash case appears to fall through: with
filea regular file,NamesNonDirectoryWithSlash_nid_no_patch("file/child/")strips the final slash tofile/child, wherestd::filesystem::statusreports not-found plus an error.exists(status)is false, so the helper returns false even though an earlier component is a regular file; the Windows operation may then map that toENOENTinstead ofENOTDIR.HasNonDirectoryPrefix_nid_no_patch(native)already walks existing parent components and looks suitable as the fallback when the named path itself is not found. Could you add a nested case (at leastopenand one removal path) and use that fallback?Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T21:03:16Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libc/src/General.cppcore/libs/prx/libc/src/Rename.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/tests/GuestFilesystem.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libc/src/Rename.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/tests/GuestFilesystem.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/tests/GuestFilesystem.cppcore/libs/prx/libc/src/General.cppcore/libs/prx/libc/src/Rename.cppcore/libs/prx/libkernel/File/src/Open.cppImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T21:26:33Z.
Thanks for the review. I checked the nested case
file/child/(stripped tofile/child, which does not exist). It already answers ENOTDIR forunlink,remove,openandsceKernelUnlink: the callers fall back to the non-directory-prefix check on ENOENT. I added these four cases toguest_filesystem(head9eb680d17a). They pass on Windows (MinGW GCC 15.2, Release) with and without aHasNonDirectoryPrefix_nid_no_patchfallback insideNamesNonDirectoryWithSlash_nid_no_patch, so I did not add the fallback, since I could not show a failing case for it. If you have a call that still answers ENOENT for this shape, please name it and I will add it with a failing test. Not tested:renamewith a nested name, Linux, macOS, a console.AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T01:09:31Z.
Thanks for this. Since it changes Windows path resolution and we don't yet know of a title that needs it, I'm closing it for now, as with #5165/#5266. Please reopen with the title ID and the log line that shows the problem, and we'll pick it up.
Pull request closed