Repository navigation
fix(libc): match guest path components case-insensitively on Linux - #1079
johnhumphrys wants to merge 1 commit into
Conversation
The PS5 and Windows hosts ignore case, so titles open files with a casing that differs from the package. On Linux ResolvePath now looks up a component with a case-insensitive directory match when the exact name does not exist. Exact names stay on the fast path and ambiguous matches fail as before. Closes boykopovar#1047 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
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:
|
|
|
blawesom
left a comment
There was a problem hiding this comment.
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_case aborts with 0xc0000409 because on Windows Resolve returns the guest's spelling (the matching is #ifdef __linux__), and the mixed-case assertions compare std::filesystem::path lexically, so e.g. MEDIA/movies/Main_Menu.bk2 can never equal Media/Movies/main_menu.bk2 there. Registering the test on Linux only, as @oneandonlydean suggested, is the right fix — note the Dup.txt/dup.txt fixture also cannot exist on NTFS (the second Touch opens the first file), so making the test cross-platform would need more than an #ifdef around the assertions.
2. Aliased mounts bypass the matching (confirming @fisherjoey, with the line). ResolveAlias returns 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 of ResolveAlias, at least the limitation should be stated in the PR description so nobody spends an evening on a /savedata0 case mismatch.
3. New: the Linux fast path regressed from zero filesystem syscalls to O(depth) stats per resolve — and deep working directories multiply it. MatchHostCase calls exists(result / *component) for every component, including when the guest's spelling is exactly right, which is the overwhelmingly common case. Before this change, Resolve was pure string manipulation. Worse, Resolve builds guest from the whole cwd chain (state.current.lexically_relative(state.root)), so a title running with a deep working directory pays the full walk from state.root on every relative-path resolve, not just per input component.
A single upfront check restores the fast path:
std::error_code error;
if (std::filesystem::exists(base / relative, error)) return base / relative;as the first line of MatchHostCase. One stat when the spelling is right (which the eventual open would pay anyway), and the per-component walk only runs for actual case misses. It is also compatible with the exact-match preference: exists on the full path is exactly the "exact spelling" case that should win.
Beyond that, two smaller notes:
- The per-miss directory scan is uncached (fisherjoey's listing-cache point). Whether that matters depends on how often titles probe with wrong case — the upfront check above keeps that off the common path either way.
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.cpp has moved ~123 lines since the merge base), so this needs a rebase and a CI rerun before it can be judged.
|
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 (7be744b) merged onto ctest, run serially (
The 101 failures are the dma-buf import probe from #943 poisoning the device on this driver; #1329 has since fixed that on Demon's Souls (PPSA01341 v1.07), with my local case fix removed and this PR applied: the title opens 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 AI-assisted: yes |
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