feat(libc): implement realpath #3147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3147"
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 SleglJan on 2026-10-10T23:14:20Z.
What
Adds
realpathto libc (imported fromlibSceLibcInternal), in a newsrc/RealPath.cpp. It follows FreeBSD 11'srealpath.con the guest side:EINVAL, an empty oneENOENT. A relative path starts from the guest working directory (getcwd); an absolute one from/..components are skipped;..drops the last resolved component and never climbs above/. Every other component must exist, and one that is not a directory with anything after it (file/x,file/,file/.,file/..) isENOTDIR. A missing component isENOENTeven when a later..would drop it. Backslashes are separators, as everywhere in the path layer.ENAMETOOLONGwhere FreeBSD gives it: 1024 bytes (PATH_MAX) or more in the input after the leading separator, in the result while a component remains, or in the result after appending one. A working directory that long already fails ingetcwd.ResolvePath_nid_no_patch, so a mount alias resolves and a blocked mount isENOENT; a host symlink is followed for existence and type but not expanded (see below).resolvedis aPATH_MAXbuffer from the application heap, which the title'sfreereleases (libcurl does,lib/vtls/vtls_scache.c). With a caller's buffer, a failure leaves the path that failed in it, as FreeBSD does.Symlinks: the console's guest filesystem has none, but a host directory under the guest root can. This
realpathdoes not expand a host link, and it drops..lexically. That is how the path layer resolves every guest path foropenandstat(Resolveinlibc/src/General.cppuseslexically_normal), so the result names the same file the title opens with the input. @Amoenus's probe on #1692 shows the difference from FreeBSD: throughlinkdir -> sub/deep,/fixture/linkdir/../marker.txtgives/fixture/marker.txt, where FreeBSD gives/fixture/sub/marker.txt. It is listed in TechnicalDebt. #1624 (lstat) and #1627 (readlink), merged since #1692, report host links to the guest on Linux. Expanding them here would makerealpathoflinkdir/../xname a different file thanopenof it.This is XashPS5's stop on
mainnow that #2968 (gethostname) is merged, as @babyhuey reported on #1692. #1692 was closed becauserealpathwas not a title's stop then; this is the same change rebased onto currentmain.In the Linux audit of the homebrew catalog (#1578),
realpathwas absent for 17 of the 34 relinked titles. The callers are statically linked libraries: Mesa'sutil_dl_get_path_from_proc, libcurl's CA path keys and fontconfig'sFcStrRealPath; all of them accept a null return.Tested
BUILD_TESTING=ONandANYPS5_ENABLE_SPIRV_TOOLS=ON, this branch onmaine4045bbb:ctest: of 739 tests, 733 pass and fourvideo_out_flip_*tests skip under the offscreen SDL driver. Two fail:agc_driver_dcc_keys_first_write(#2767);guest_avplayer, the intermittent failure in #2709. It passes 5 of 5 repeats on its own.guest_realpathpasses 3 repeats.tools/check_conventions.py --base upstream/main,tools/check_test_registration.pyandgit diff --checkpass.guest_realpathtest on a directory tree under the guest root:/, a directory with and without a trailing slash,..,., doubled slashes,..above the root, backslashes, an upper-cased directory name returned as typed, relative paths afterchdirincluding..back to/, a mount alias and a blocked mount, the allocated form freed withfree;EINVALfor null,ENOENTfor empty and for a missing component before..,ENOTDIRfor the four non-directory forms,ENAMETOOLONGfor an input longer than 1024 bytes and for/plus 1023 bytes (the append boundary),ENOENTfor a 1023-byte path of missing components, and the failing path left in the caller's buffer in the missing-component cases, forfile/andfile/x, and at the append boundary. Written before the implementation; it failed on the unresolved export and passes with it.RealPath.cppand test, oldermain):guest_realpathpassing 3 repeats and the full suite 474/474;guest_realpath5/5, and 5/5 failing with theENOTDIRcheck disabled;guest_realpathandguest_working_directory5/5 each.sce_module/libc.prxunwrapped) in a bubblewrap sandbox:maine4045bbb(Release, tests and SPIRV-Tools off) the loader stops withsymbol lookup error: app.elf: undefined symbol: vhtcIgZG-Lk(exit 127). The import audit lists 18 absent imports.cjt-4ySmYTs(libkernel_sys).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
https://claude.ai/code/session_01Fnrk5Dazjb2tLooVSpdRQq
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T23:18:46Z.
Progress report (
5b4709f→e1f168a)➖ System libraries: 85.53% (+0.0%, +1 implemented functions)
✅ 1 implemented
realpath_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T23:22:36Z.
Checked on Linux (merged onto current
main): build andguest_realpathpass, and the test no longer links withoutRealPath.cpp. Error codes (EINVAL,ENOENT,ENOTDIR,ENAMETOOLONGboundaries, failing path left in the caller's buffer) match FreeBSD 11realpath.c, the lexical..deviation is listed in TechnicalDebt, and the Windows runs in the thread cover the same code. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-10T23:28:47Z.
Windows title run to go with the Linux one above:
e1f168a2merged ontomain2b5d119f(clean), Windows 11, MinGW-w64 GCC 15.2 from WinLibs, Release, XashPS5 (PPSA19111) catalog build withsce_module/libc.prxunwrapped.guest_realpathpasses 5/5 (--repeat until-fail:5), no warnings.main:FAIL: unresolved ELF import vhtcIgZG-Lk (realpath) from libSceLibcInternal.prxFAIL: unresolved ELF import cjt-4ySmYTs (fork) from libkernel_sys.prx, the same next stop as on Linux (also checked here,undefined symbol: cjt-4ySmYTs).