fix(libkernel_sys): fail readlink through a regular file with ENOTDIR on Windows #8312
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8312"
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 altuux on 2026-10-20T09:45:28Z.
What
A path whose directory part is a regular file, such as
file/child, failed withENOENTinreadlinkandreadlinkaton Windows, where FreeBSD 11.4 fails it withENOTDIR(vfs_cache_lookup,sys/kern/vfs_cache.c). The not-found error ofReadNativeLinknow checks whether the nearest existing ancestor is not a directory (HasNonDirectoryPrefix), matching the behavior ofopen,stat,lstat,access,unlink,chmod,truncate,utimes,rename,remove,opendir, andfopen.Tested
tools/check_conventions.py --base upstream/mainandtools/pr_overlap.py --branch fix/libkernel-sys-readlink-notdirpassed cleanly. Added assertions inGuestKernelSys.cppforreadlink_nid_postfixandreadlinkat_nid_postfixverifying that paths through a regular file return -1 with error 20 (ENOTDIR).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-20T10:00:11Z.
Some 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_sys/Export.cppcore/libs/prx/libkernel_sys/Export.cppcore/libs/tests/GuestKernelSys.cppcore/libs/tests/GuestKernelSys.cppcore/libs/prx/libkernel_sys/Export.cppImported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-20T16:59:39Z.
Windows data point for this PR (not a review of the approach, which matches the other ENOTDIR changes).
Measurement
CMAKE_BUILD_TYPE=Releasein the CMakeCache),ninja -j4.7d40d6f420merged ontomain1b08a33b12(the merge completes without conflicts).readlink_nid_postfix((file / "child").string().c_str(), ...)needs adjusting to currentmain(the variablefileis now astd::string):GuestKernelSys.cpp:301:40: error: no match for 'operator/' (operand types are 'const std::__cxx11::basic_string<char>' and 'const char [6]'). I changed only that line to(root / "file.txt" / "child").string().c_str(); nothing else.guest_kernel_sys:Kernel sys check failed at line 301 (guest errno 2), 3 of 3 runs. That is the newreadlinkline, which expects errno 20.ReadNativeLink(if (error) return Fail(GuestError(error));becomesif (error) return Fail(error == std::errc::no_such_file_or_directory && HasNonDirectoryPrefix(native) ? GuestEnotdir : GuestError(error));),guest_kernel_syspasses, 3 of 3 runs.Interpretation (probably, not verified further)
On this Windows host
std::filesystem::symlink_statusseems to return ano_such_file_or_directoryerror code forfile.txt/childinstead of anot_foundstatus.ReadNativeLinkthen returns at theif (error)line, whereGuestErrormaps that code to ENOENT, before thenot_foundbranch that this PR changes, so the branch is not reached for this path. I did not check other hosts.Suggestion
Apply the same prefix check in the
if (error)branch ofReadNativeLink, and rebase the test line onto the currentmain. My own ENOTDIR change forlink,symlink,pathconfandfchmodat(#8522) leavesreadlinkandreadlinkatout so the two PRs do not overlap (merge-treeof the two branches is clean).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by altuux on 2026-10-20T18:26:44Z.
Thanks a lot for the data point and testing it on MinGW! Rebased onto current main, adjusted the test path to
(root / "file.txt" / "child"), and applied theHasNonDirectoryPrefixcheck to theif (error)branch as suggested.