fix(libkernel): treat Windows junctions in unlinkat like unlink and rmdir #9095
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9095"
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 mazen320 on 2026-10-21T12:08:48Z.
What
Relative
unlinkaton Windows did not apply the directory-junction rules thatunlinkandrmdiralready use (#7530). WithAT_REMOVEDIR, a junction returnsENOTDIRand the target is not inspected. Without that flag,unlinkatremoves the junction withRemoveDirectoryWand leaves the target, including when the target is not empty. Absolute andAT_FDCWDpaths already went throughunlink/rmdir.Tested
Windows 11, MinGW GCC 15.2, Release,
build-win, headd91194a8b9on currentupstream/main(still Depends on #7530):guest_kernel_syspassed (junction AT_REMOVEDIR → ENOTDIR, plain unlinkat removes junction and keeps non-empty target, file symlink unlinkat removes the link and keeps the target)guest_filesystempassedpython tools/check_conventions.py --base upstream/mainChecklist
Imported from boykopovar/AnyPS5. Originally posted by cadenasynyster on 2026-10-21T21:59:04Z.
Independent Windows run of this PR (head d20190a68). The branch contains #7530's commit (81fe7856f) and this PR's commit, so I checked them separately.
Environment: Windows 11 10.0.26300, Ryzen 7 9800X3D, WinLibs GCC 15.2.0 r7 (MinGW), Release, BUILD_TESTING=ON.
Results:
guest_kernel_sysandguest_filesystempass 3/3 (--repeat until-fail:3).core/libs/prx/libkernel_sys/Export.cppwith the merge-base version (d099bc6cd).guest_kernel_sysfails withKernel sys check failed at line 561 (guest errno 66):unlinkat(base, "junction-full", AT_REMOVEDIR)returnsENOTEMPTYinstead ofENOTDIR.guest_filesystemstill passes.Open.cpp,Stdio.cppandExport.cppfrom the merge base):guest_kernel_sysfails the same way, andguest_filesystemaborts in the newjunction-fullblock, at the first call aftermklink /J(rmdiron the junction), before any check prints. That block comes from #7530.Not run: Linux/macOS, the full repository CTest, and any title.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-21T22:02:08Z.
Thanks for the independent Windows run and the isolation checks — useful confirmation that the head needs both commits together.
Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T13:25:45Z.
Review: COMMENTED
Checked against main
6cd36e6517(read-onlygit merge-tree/range-diff; I didn't build or run it):unlink,rmdirorunlinkat. The rebase since the d20190a68 run left the code hunks unchanged (range-diff shows only test and doc movement).unlinkatwithoutAT_REMOVEDIR(libkernel_sys/Export.cpp:618), the check tests onlyFILE_ATTRIBUTE_REPARSE_POINT, while the other three new sites are restricted to directories (theAT_REMOVEDIRbranch at :582 andsceKernelRmdircheckFILE_ATTRIBUTE_DIRECTORY;sceKernelUnlinkis insideis_directory(symlink_status)). As written, any reparse-point file, such as a guestsymlinklink, now goes throughReadJunction, which throws if CreateFileW or FSCTL_GET_REPARSE_POINT fails, where main went straight to_wunlink. I couldn't run this to see whether it ever trips; adding&& (attributes & FILE_ATTRIBUTE_DIRECTORY) != 0would match the other sites and keep file unlinks on the old path.GuestFilesystem.cpp:1134(const auto fullTarget = ...) lost its indentation in the rebase.ReadJunctiononly returns true when the target is a drive path, so a volume mount point or other mount-point reparse still takes the old path. "returnENOTDIRfor that junction", as the earlierO_NOFOLLOWsentence says, would match the code. The new behaviour also lives inOpen.cpp,Stdio.cppandlibkernel_sys/Export.cpprather thanNativeStat.cpp, the file the entry links.Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.