fix(libc): match guest path components case-insensitively on Linux #1079
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1079"
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 johnhumphrys on 2026-10-07T09:41:09Z.
What
Closes #1047. On Linux,
ResolvePathnow resolves each guest path component against the host directory case-insensitively when the exact name does not exist. Exact names stay on the fast path, and two names that differ only in case fail as before (an exact name is still preferred). Windows is unchanged.Adds
guest_path_case(core/libs/tests/GuestPathCase.cpp): mixed-case files and directories, backslash separators, aDup.txt/dup.txtpair, and paths that do not exist yet.Deliberate choices: no directory-listing cache (a stale listing could hide files created later; the cost is one directory scan per exact-name miss, e.g. when creating a file), ASCII-only case folding, and aliased mounts such as
/savedata0are not matched.Tested
GuestPathCase.cppandGeneral.cppcompiled standalone. The test passes with the change and aborts without it.guest_working_directorywas not run through ctest.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-07T12:09:41Z.
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/libc/src/General.cppL9, L70-71Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-07T21:09:41Z.
I filed #1047 from Demon's Souls (PPSA01341 v1.07), so I can test this where it matters: x86-64 Linux, full CMake/ctest build, and the title itself, which you list as untested. I'll post the results here.
I have a version of the same fix locally (it got the title past the black screen in #1025). Two differences that may be worth discussing:
/savedata0/...and other mounted paths are covered too. Demon's Souls only needed/app0, so I can't point to a title that depends on this yet.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-08T05:12:42Z.
guest_path_caseaborts on the Windows runner (Exit code 0xc0000409): the case matching is Linux-only, butlibc/CMakeLists.txt:142-150registers the test on every platform. Please register it on Linux only.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-08T12:30:43Z.
Review: CHANGES_REQUESTED
Verified the implementation against the source and against #1047's design. The ambiguity rule matches what the issue proposed (exact spelling preferred via
exists(), ambiguous falls back to the guest spelling and fails at open as before), and the test covers the fixed/relative, mixed-separator, ambiguous and new-file cases. Three things before this can go in; the first two have been raised already and I can confirm them in the code, the third is new.1. Windows CI is red, and it is a test-semantics problem, not just registration.
guest_path_caseaborts with0xc0000409because on WindowsResolvereturns the guest's spelling (the matching is#ifdef __linux__), and the mixed-case assertions comparestd::filesystem::pathlexically, so e.g.MEDIA/movies/Main_Menu.bk2can never equalMedia/Movies/main_menu.bk2there. Registering the test on Linux only, as @oneandonlydean suggested, is the right fix — note theDup.txt/dup.txtfixture also cannot exist on NTFS (the secondTouchopens the first file), so making the test cross-platform would need more than an#ifdefaround the assertions.2. Aliased mounts bypass the matching (confirming @fisherjoey, with the line).
ResolveAliasreturns early (General.cpp:89), and its result joins the guest's remaining components verbatim, so every path under a mounted prefix keeps the old case-sensitive behaviour on Linux. If the fix stays out ofResolveAlias, at least the limitation should be stated in the PR description so nobody spends an evening on a/savedata0case mismatch.3. New: the Linux fast path regressed from zero filesystem syscalls to O(depth) stats per resolve — and deep working directories multiply it.
MatchHostCasecallsexists(result / *component)for every component, including when the guest's spelling is exactly right, which is the overwhelmingly common case. Before this change,Resolvewas pure string manipulation. Worse,Resolvebuildsguestfrom the whole cwd chain (state.current.lexically_relative(state.root)), so a title running with a deep working directory pays the full walk fromstate.rooton every relative-path resolve, not just per input component.A single upfront check restores the fast path:
as the first line of
MatchHostCase. One stat when the spelling is right (which the eventualopenwould pay anyway), and the per-component walk only runs for actual case misses. It is also compatible with the exact-match preference:existson the full path is exactly the "exact spelling" case that should win.Beyond that, two smaller notes:
FoldCaseis ASCII-only. That matches the console's apparent behaviour for these titles, but it means non-ASCII names won't match across case variants; fine, just worth a line in the description.And mechanically: the head conflicts with current
main(General.cpphas moved ~123 lines since the merge base), so this needs a rebase and a CI rerun before it can be judged.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T12:37:59Z.
Closing in favour of #1321, which covers the same case-insensitive path resolution (same function and test file) on both Linux and Windows, prefers exact matches and rejects ambiguous names. Thanks for the work here; if something this PR handled is missing from #1321, please say so there.
Imported from boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-08T14:40:07Z.
These are the results I said I'd post. This PR was closed in favour of #1321 while they were running, so they're mostly for the record.
Setup: Nobara (Fedora 44) x86-64, RTX 5070 Ti, NVIDIA 595.91.07, gcc 16.2.1. This PR (
7be744b2) merged ontomaindf16c4c2without conflicts.ctest, run serially (
-j1 --timeout 60) in the same build directory for both:The 101 failures are the dma-buf import probe from #943 poisoning the device on this driver; #1329 has since fixed that on
main. With it, the only failure on both builds isguest_force_tls_destructor, which predates this PR, andguest_path_casepasses.Demon's Souls (PPSA01341 v1.07), with my local case fix removed and this PR applied: the title opens
/app0/packagecmdlineargs.txt, the PR findsPackageCmdLineArgs.txt, and the boot gets past the black screen from #1025. The logo and attract movie play until I stopped it at 250 s. Of 33,091 host opens underapp0, none failed. A mixed-case/app0\Movies\Main_Menu.bk2resolves tomovies/main_menu.bk2.Over a full boot through the new-game intro, the exact name misses once (the args file), plus once for the new log file under
/hostapp/logs. On an existing path the per-component check costs about 4 stats per lookup (~100 us on my NTFS fuse mount, ~1.3 us onmain), which adds up to a few ms per boot. I don't think a directory listing cache is worth it for this title, so I've dropped mine.AI-assisted: yes
Pull request closed