fix(libkernel): unlink a dangling Windows directory symbolic link #14197
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/14197"
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 JJenkx on 2026-10-31T22:58:28Z.
What
On Windows,
unlinkon a directory symbolic link whose target is missing failed withEACCES(13), where FreeBSD removes the link.sceKernelUnlinkenters its Windows directory-link branch (FindFirstFileW→IO_REPARSE_TAG_SYMLINK→RemoveDirectoryW, added inb28edaf954) only whenstd::filesystem::is_directory(std::filesystem::symlink_status(native))is true. With MinGW's libstdc++,symlink_statusfollows the link. A dangling directory link therefore reports "not found" rather than "directory", and the call falls through to the file delete. Windows removes a directory link only throughRemoveDirectoryW, so that delete fails with access denied.As a result,
guest_filesystemaborts at line 1551 onmainon any Windows host that may create symbolic links (Developer Mode or administrator):Under gdb, the abort comes from
Checkfor line 1551, with guest errno 13. On a host that cannot create links, the test skips this block, which is why hosted Windows CI does not see it.unlinknow also takes the directory-link branch whenGetFileAttributesWreports bothFILE_ATTRIBUTE_DIRECTORYandFILE_ATTRIBUTE_REPARSE_POINTon the path. That call describes the link itself, without following it. Inside the branch,FindFirstFileWfinds the link entry whether or not its target exists, soRemoveDirectoryWremoves the dangling link.Linux and macOS are unchanged.
Tested
Windows 11 Enterprise 10.0.22621 (Developer Mode: unelevated symbolic link creation works), Ryzen 9 5950X, WinLibs GCC 15.2.0 UCRT r7, Ninja, Release, full build with
BUILD_TESTING=ON, onmain7a5d9bf02a.guest_filesystem:Open.cpprestored tomain(the control build relinkedlibkernel.prx): aborts again (0xc0000409).ctest -R "file|fs|stat|dir|link|path|unlink|rename|kernel_sys" -j8 --repeat until-fail:3: 223/223 pass.main7a5d9bf02a(ctest -E ^agc, 2023 tests). It was one of two failures there; the other isngs2_pitchshift, a separate known issue.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 MarcZX10 on 2026-10-31T23:14:48Z.
Review: APPROVED
Reviewed — looks good
The Windows path identifies a dangling directory symlink from its attributes and removes the link itself; the existing filesystem regression covers linked and dangling directory symlinks.
What I ran
Reviewed head
b476f50b8e62718024ed5c1e5db1da5766330268against PR base7a5d9bf02af636382aec927593b1a5867899ed0f; the merge preview was clean. Reviewed on Linux x86_64, Python 3.11.2. The hosted Windows job ran on Windows Server 2025 with MinGW GCC 15.2.0. No local build or CTest was run.Results
Raw hosted status
Negative control
No negative control was run; I did not alter the code or locally build the Windows-specific regression.
Sources
Not verified
To get this to a good state
No blocking change is apparent from the code review and passing Windows job. The remaining labels check is administrative; no further code change is required for this review.