fix(libkernel): report ELOOP and ENAMETOOLONG from mkdir, rmdir and truncate #6942
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6942"
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 AlexOfTheForest on 2026-10-16T20:35:40Z.
What
#6648 and #6992 made open, unlink and stat report a symbolic link loop (
ELOOP, 62) and an over-long name (ENAMETOOLONG, 63).sceKernelMkdir,sceKernelRmdirandsceKernelTruncatestill lost them. Theirstd::filesystemqueries fail withfilename_too_longortoo_many_symbolic_link_levels, and the code went on to answerENOENT,EIOorENOTDIR. APathLookupFailurecheck after those queries now returns the guest error, as FreeBSD'snameidoes. The POSIXmkdir,rmdirandtruncatewrappers set the same errno.Two commits:
fix(libkernel): report ELOOP and ENAMETOOLONG from mkdir and rmdir, which also addsguest_path_errors. The test covers open, unlink, stat, rename, mkdir and rmdir with a self-referencing link, a two-link cycle, a 300-byte name, and each of those as a path prefix. It is UNIX-only because it creates symbolic links.fix(libkernel): report ELOOP and ENAMETOOLONG from truncate.Tested
Linux x86_64:
guest_path_errors,guest_filesystem,guest_posix_scalar_io,guest_kernel_fcntlandguest_record_lock_ownerspassed 3 of 3 runs. Run against unmodifiedmain,guest_path_errorsfails only at the mkdir, rmdir and truncate checks; open, unlink, stat and rename already pass there.tools/check_conventions.py --base upstream/mainpasses. Not run on Windows or macOS.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T20:44:03Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libkernel/File/src/Stdio.cppL1410Some 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/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/Stdio.cppcore/libs/prx/libkernel/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-17T01:21:43Z.
Windows check, since the PR lists Windows as untested and the Windows CI job is skipped on this head. guest_path_errors is UNIX-only, so this covers build and regressions, not the new error paths themselves:
Windows 11 10.0.26200.9711 (NTFS), WinLibs GCC 15.2.0 posix UCRT r7, Release, BUILD_TESTING=ON, head 4b979592d merged onto main
f3263dfbf(clean merge, no new build errors).Not checked: ELOOP/ENAMETOOLONG behaviour on Windows itself.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-17T01:39:43Z.
Follow-up on Windows behaviour, since guest_path_errors does not run there: I ran GuestPathErrors.cpp on Windows locally, with its symlinks created through CreateSymbolicLinkA (MinGW has no symlink()). The new mapping is not reached on Windows, and the Windows results are the same on main, so this PR neither causes nor fixes them:
sceKernelStat("loop")ELOOPsceKernelOpen("loop")EINVALELOOPsceKernelOpen("loop/inside")ENOENTELOOPENOENTENAMETOOLONGI filed the abort separately as #6983, with repro and details. Just noting it here so the Windows gap is visible next to this fix.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T01:44:08Z.
Issue #6983 reports that this abort persists even with this PR applied: Windows
std::filesystem::statusdoes not expose the self-link failure here, then_wstat64fails insideFillFileStatand its exception escapes. This appears to be a separate native-stat failure path from the filesystem lookup errors handled here. I am evaluating a narrowTryFillFileStatfollow-up for that case; please let me know if you see a merge-order or ownership concern, since both changes touchOpen.cpp.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-17T02:01:34Z.
NevesHenry, the author of #6648, confirmed on #6983 that this is a separate native-stat failure and should merge with the path-status change in either order. This follow-up adds
TryFillFileStatfor the later_wstat64failure insceKernelStat; it does not reuse code from either open PR. I proposeDepends on: nonebecause the change works on current main and should compose either way. AlexOfTheForest, could you confirm you have no ownership or merge-order concern with that follow-up?Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-17T09:44:27Z.
@MarcZX100 No ownership or merge-order concern from my side — go ahead with the TryFillFileStat follow-up for #6983. The two changes are independent (this PR only changes which errno the lookups report; #6983 is the native stat failure path on Windows), so either can merge first and the other rebases. Confirming: Depends on: none.
@cadenasynyster thanks for the Windows runs and the table. Windows returning EINVAL/ENOENT for loops and long names is unchanged by this PR; the guest_path_errors test is UNIX-only for that reason. Mapping those Windows cases is a separate follow-up.
Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-18T12:04:53Z.
No ownership or merge-order concern from my side: the #6983 abort is a separate path, so your TryFillFileStat follow-up can merge before or after this one. "Depends on: none" is right. I also rebased this branch onto current main (a one-line CMakeLists.txt conflict with the record-lock test; both entries kept).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T11:24:47Z.
Review: CHANGES_REQUESTED
Thanks for the measurements. This now conflicts with
maininOpen.cppandStdio.cpp, and not mechanically:ELOOP/ENAMETOOLONGfor open, unlink and stat throughFilesystemError. The newFile::SceErrorFromHostErrno/IsPathLookupErrorduplicates that, and therefactor+ open/unlink + stat commits conflict with it (Open.cpp:172,Open.cpp:357).sceKernelRenamewas rewritten onmain(RenameGuestPath_nid_no_patch,Stdio.cpp:1326), so the rename commit no longer applies.sceKernelMkdir,sceKernelRmdirandsceKernelTruncateonmainstill treat a failedstd::filesystemlookup asENOENT, so that part of the PR is still needed.Could you rebase and reduce the PR to what
mainis still missing (mkdir/rmdir/truncate, using the existingFilesystemErrormapping rather than a new helper), re-check rename against the new implementation, and trimguest_path_errorsto the cases that fail onmain? Please confirm which test rows fail without the change.Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-19T20:46:40Z.
Rebased onto current main and narrowed: #6648 and #6992 already landed the open/unlink/stat part of this, so I dropped my refactor and those commits. What remains is mkdir, rmdir and truncate, which still answered ENOENT/EIO/ENOTDIR for a link loop or an over-long name on main (the test fails there exactly at those checks), plus the test that covers all of these paths. Depends on: none.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-20T15:11:06Z.
Rebased onto current
main; one conflict insceKernelTruncate(it now usesNotFoundError_nid_no_patch), resolved by keeping that and placing thePathLookupFailurecheck before theexistscheck.guest_path_errorsand the libkernel/libs ctest scope pass on the rebased head; merged.