fix(libkernel): report ENOTDIR from mkdir and rmdir when a path component is a file #2707
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2707"
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 husseinkad on 2026-10-10T11:44:22Z.
What
On Windows,
mkdir,sceKernelMkdir,rmdirandsceKernelRmdirwith a regular file as a path component returned ENOENT (or a raw Windows code that maps to EIO). FreeBSD returns ENOTDIR: mkdir(2) "[ENOTDIR] A component of the path prefix is not a directory", rmdir(2) "[ENOTDIR] A component of the path is not a directory".A new helper
HasNonDirectoryPrefixwalks up to the nearest existing ancestor and reports whether it is not a directory (a trailing separator is ignored). It runs only on the failure path: the POSIXmkdirremaps a native ENOENT or EINVAL to ENOTDIR when it is true (EINVAL because_wmkdirrejectsfile/a:b/xbefore it looks at the prefix),sceKernelMkdirandsceKernelRmdiruse it the same way, andsceKernelRmdir("file/")is ENOTDIR.errnois captured before the helper runs.sceKernelMkdir("new/")used to takenative.parent_path(), which isnewitself, and failed with ENOENT whilemkdir("new/")succeeded; both now strip the trailing separator and succeed. The Linux host already returns ENOTDIR for these paths and is unchanged. Out of scope and unchanged:mkdir("file/")andmkdir("file/.")(EEXIST), and the other path-taking calls (sceKernelTruncate,sceKernelRename, ...), which have the same defect and need their own changes.Tested
Windows 11 (10.0.26200), WinLibs GCC 15.2.0 r7, Release:
guest_filesystemgainsfile/childandfile/child/leaffor the four functions,rmdir("file/"),<file>/a:b/x,dir/missing/leaf(stays ENOENT),rmdir("missing/")and trailing-separator mkdir for both variants; it fails without the change (exit0xc0000409) and passes with it.ctest -R "guest_filesystem|guest_directory"passes.main'sStdio.cppbuilt into a secondlibkernel.prx: 371 identical; 104 changed ENOENT/EINVAL to ENOTDIR, all with a regular file as a path prefix (including junctions, case differences, non-ASCII names,NUL/x, 400 nested components, a file under a read-only directory); 20 trailing-separatorsceKernelMkdirforms now create the directory likemkdir; none changed from success to failure; a 3-thread create/delete race against a flipping ancestor showed no hang or stale errno.tools/check_conventions.py --base origin/mainpasses;tools/pr_overlap.py --branchreports no overlap.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T11:44:33Z.
Thank you for your interest in the project! We are sorry, but we cannot accept more PRs while we work through the existing backlog. This PR has been automatically closed and labeled "intake paused". This is not a judgment of the quality of your changes.
Pull request closed