fix(libc): expand %VAR% mount tokens in guest paths #4565
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4565"
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 ahmedhamouda78 on 2026-10-12T15:47:12Z.
What
ASTRO BOT (PPSA21564) stops during start-up because its asset paths carry a
literal
%ASOBI_ROOT%token that reaches the file API unresolved, so the soundconfig XML never loads and its
SoundManagerasserts.This expands
%VAR%tokens at the/hostpath-translation layer. InResolve()'sexisting per-segment loop, a path segment that is exactly
%NAME%is replacedby the value of guest environment variable
NAME(via a new read-onlyLookupGuestEnvironment_nid_no_patchover the same tablegetenvuses — no guestABI, no mutation). The variable's own directory separators split into components,
and a leading separator is stripped so an absolute value extends the guest path
rather than escaping the guest root.
Scope is deliberately narrow, matching the issue's guidance and avoiding the two
closed wrong-layer attempts (libc
%expansion in #3959; a guest env var in #4274):only a whole-segment token is touched, so a segment that merely contains
%(a filenamed
100%done.txt) is unchanged, and a token naming no set/empty variable is leftliteral — behaviour is identical to today for every path without a resolvable token.
Tested
Linux, GCC 16.2.0, C++20.
core/libs/tests/GuestPathCase.cpp(guest_path_casetarget) is extended with a self-contained, cross-platform block asserting: a
%VAR%segment expands to a known variable's directory; a value with nesteddirectories splits into components; a backslash-separated value resolves; an
unset token stays literal (proven by a successful read of a real file named
%UNSET_TOKEN%); and empty-value and separator-only-value tokens stay literal.The full
guest_path_casetarget links the wholelibc/libkernelbuild (needsthe graphics stack this headless host cannot build), so it runs in CI; locally the
same resolver logic was exercised directly against
ResolvePath_nid_no_patchandadversarial
../absolute values were confirmed to stay under the guest root.Not run on hardware or against the title.
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)The in-band
%VAR%substitution has no escape syntax (%%is not handled), so afile whose name is exactly
%NAME%for a set variableNAMEwould be expandedrather than opened literally. No such collision is known on a PS5 title; this
tradeoff is recorded in
docs/dev/TechnicalDebt.md.Fixes #3480
Imported from boykopovar/AnyPS5. Originally posted by ahmedhamouda78 on 2026-10-13T09:50:34Z.
Closing as a duplicate —
%VAR%path-token expansion for #3480 already landed inaa3f7b7b9c(feat(libc): add %VAR% environment variable expansion in path resolution), which closed the issue. Thanks to @StarMrGamer for the fix.Pull request closed