fix(libc): report ELOOP from rename through a Windows symlink loop #8696
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8696"
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 cadenasynyster on 2026-10-20T21:19:45Z.
What
On Windows,
sceKernelRenameand POSIXrenamedo not report ELOOP when the source or the destination goes through a symbolic link that points to itself. FreeBSD returns ELOOP (62). Measured on main withloop -> loop:sceKernelRename("loop/inside", "target")0x80020014)0x8002003e)sceKernelRename("present.txt", "loop/inside")0x80020014)sceKernelRename("loop", ...)sceKernelRename("missing/x", "target")RenameGuestPath_nid_no_patchends with ENOENT or ENOTDIR for these paths, becausestd::filesystemdoes not report the loop on Windows. When it does, the directory part of the source and of the destination is now opened the waysceKernelStatalready tests for a loop (CreateFileWfailing withERROR_CANT_RESOLVE_FILENAME), and the result becomes ELOOP. It runs only on that failure result, so successful renames do no extra work.Rename.cppgets its own private copy of the check. libc does not include libkernel headers, and #8687 adds the same check toWindowsSymbolicLink.hpp. The two can be merged into one helper after both land.Refs #6983. This does not touch the
.and..components (#8217) oropen(#8640, #8655).Tested
guest_filesystemhas four new checks on astat-loop -> stat-looplink:sceKernelRenameand POSIXrenamewith the loop in the source path and in the destination path (POSIX: -1 and errno 62). It passes, and so doesguest_rename_dot.ctest -R "rename|filesystem|path|realpath|file|stat|open|dir": 110 tests, 98 passed. The 12 others are allagc_*(10 stale executables with exit0xc0000139, 2 not built), because a full build stops at an unrelated AGC test that does not compile with this MinGW (#8310 is the open fix).ctest -R "^agc_"runs 882 tests on an RTX 5070 Ti (driver 617.42): 876 pass, 3 are skipped and 3 fail (agc_driver_sample_order,agc_driver_sample_order_grid_reference,agc_driver_sample_order_recipe_depth_locations). The same 3 fail the same way with this PR's production files reverted to main and the libraries rebuilt, so they are not caused by this change. The 10 stale executables were stale builds, not failures._WIN32), and merging this together with #8687, #8640, #8655 or #8217 (the hunks are in different functions and files).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 harisibrar1 on 2026-10-24T13:39:14Z.
Review: APPROVED
Checked against main
522e32e3b6and FreeBSD 11.4 kern_renameat:RenameGuestPathyet.0a238f9matches the source-first order: a loop under the source gives ELOOP, and a loop under the destination gives ELOOP only whenSourceLookupError_nid_no_patch(source)is 0. Renaming the loop link itself to a path under the loop also ends in ELOOP from the destination probe.BelowSymbolicLinkLoopis identical toFile::WindowsSymbolicLinkLoopin libkernel's WindowsSymbolicLink.hpp:125. libc doesn't include libkernel headers today, so the private copy is fine here; a shared header could be a small follow-up.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.