fix(libkernel): report Windows directory junctions #7273
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7273"
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-17T21:06:16Z.
What
lstatandreadlinkabort on a Windows directory junction. A junction is a directory reparse point, not a symbolic link, so the existing reader rejects it andNotImplementedends the process.statalready follows the junction.A directory junction is now reported like a symbolic link when the name left after removing a
\??\or\\?\prefix is a drive path (X:\...).lstatuses symlink mode and the target length.readlinkreturns the print name when that is a drive path, and otherwise the substitute name, with/separators. A mounted volume uses the same reparse tag, but its substitute name is\??\Volume{GUID}\, so it still throws.This builds on #7111. The junction reader uses that pull request's
TextAtandWithoutNtPrefix.TextAttakes the start of the path buffer, because a mount point has no Flags field.Tested
guest_filesystemandguest_kernel_syson Windows, GCC 15.2, after creating a junction withmklink /J.lstatreports a symlink,statfollows it to the directory, andreadlinknames that directory. The filesystem test passes a relativemklinktarget; the substitute name is the drive path that is returned.guest_kernel_sysremoves the junction and the target.python tools/check_conventions.py --base upstream/mainChecklist
python tools/check_conventions.py --base upstream/mainpasses.Depends on: #7111
Unblocks: none
GPUs tested: n/a
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T21:31:12Z.
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/NativeStat.cppL54-56Some 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.
docs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel_sys/Export.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/tests/GuestFilesystem.cppcore/libs/tests/GuestKernelSys.cppcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel_sys/Export.cppdocs/dev/debt/libkernel.mdcore/libs/prx/libkernel_sys/Export.cppdocs/dev/debt/libkernel_sys.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/NativeStat.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel_sys/Export.cppcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel_sys/Export.cppcore/libs/tests/GuestKernelSys.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel_sys.mdImported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T21:40:27Z.
Thanks for this. Junctions aborting in
lstat/readlinkis worth fixing. Two things before it can go in:Volume mount points come back as a relative path. Mounted folders use the same
IO_REPARSE_TAG_MOUNT_POINTtag as junctions. Their substitute name is\??\Volume{GUID}\and the print name is usually empty, soReadJunctionreturnsVolume{GUID}/. The guest resolves that against the link's own directory, a silent wrong answer wheremainfailed withNotImplemented. Please keep throwing unless the name left after removing\??\/\\?\is drive-absolute (X:\...), e.g. return false fromReadJunctionso the existingNotImplementedfires, and mention mounted volumes in the two debt lines.Overlap with #7111. #7111 (also yours) adds
TextAt,WithoutNtPrefixandReadtoWindowsSymbolicLink.hpp, and this PR re-implements the same reparse-text and prefix handling inline. The two PRs conflict inNativeStat.cppandlibkernel_sys/Export.cpp. Could you either fold the junction case into #7111, or rebase this one on it (Depends on: #7111) and reuse its helpers? #7202 also conflicts here (NativeStat.cpp,GuestFilesystem.cpp); whichever lands second will need a rebase.Minor: the new
GuestKernelSys.cppblock doesn't remove its junction and target afterwards (theGuestFilesystem.cppblock does).For the maintainers rather than a change request: junction targets are always host-absolute, so the guest now receives host text such as
C:/.... The debt notes have said an absolute link "has no guest form". Linux already returns host-absolute targets throughread_symlink, so this matches Linux.Imported from boykopovar/AnyPS5. Originally posted by mazen320 on 2026-10-18T09:00:08Z.
Addressed the review on
bd0caa451.ReadJunctionreturns false unless the name left after removing\??\or\\?\is a drive path (X:\...). A mounted volume (\??\Volume{GUID}\) still hits the existingNotImplemented. The print name is used when it is a drive path; otherwise the substitute name, which is whatmklink /Jstores. Both debt lines mention mounted volumes.This branch now includes #7111.
ReadJunctionuses itsTextAtandWithoutNtPrefix. Depends on: #7111.TextAttakes the start of the path buffer because a mount point has no Flags field, so the symbolic-link header size is four bytes too far.guest_kernel_sysremoves the junction and the target.guest_filesystemandguest_kernel_syspassed here on Windows GCC 15.2 without administrator rights.python tools/check_conventions.py --base upstream/mainpassed. A pull-request push does not start the full Windows job.