feat(libc): support archive-backed stdio reads #7447
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7447"
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 qpavyros on 2026-10-18T06:58:45Z.
What
Allow libc
fopenandfopen_sto read entries found only in AnyPS5's optionalapp0.zarpackaging layer, while preserving disk overrides and case-insensitive lookup.Materialize each opened entry into a temporary file in 64 KiB chunks, reopen it with genuine read-only OS access, and use the existing native stdio implementation. This covers reads, seeking, EOF/error state, narrow scanning and wide input without a separate stdio backend. Independent opens have independent positions; duplicated descriptors share the native backing and preserve archive metadata. Close, reopen and descriptor replacement retire the metadata.
Add archive-aware
accessandlstat; preserve the existing archive-awarestatpath. Prevent unsupported descriptor operations from acting on temporary-file metadata.Opening decompresses the whole entry and needs temporary disk space equal to its uncompressed size for each independent open. No performance improvement or title bring-up is claimed. Directory merging,
fdopenon the existing virtual kernel archive descriptors andfreopento an archive-only path remain unsupported. Host stdio buffering rules still apply when mixing streams and descriptor I/O. This is not support for the console's PFS format.Integration follow-up: merged main
1a745ae38without rewriting published history. Resolved the FileStream close conflict by retaining both archive metadata detachment and main's Windows directory-stream deregistration. Directory merging remains separate in #8520; it is not a prerequisite for stdio reads.Merge order: agreed to #9478 landing first, as its author proposed. This PR lists it as a dependency and will take
ResolvePathError_nid_no_patch(path, native, true, true)when integrating that change, retaining module lookup and archive lookup. Until #9478 lands this branch retains its existing archive resolver flags. #9474's author has agreed to land after #7447 and retain both the early archive access lookup and the Windows host symlink checks.Tested
dead12eba, integrating main1a745ae38.python tools/check_conventions.py --base origin/main: 0 errors, two debt-length warnings.git diff --checkpassed.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 copilot-pull-request-reviewer[bot] on 2026-10-18T06:58:52Z.
Review: COMMENTED
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-19T06:28:46Z.
Rebase handoff — rebased onto current
main(authorship unchanged). One docs-debt conflict, unioned withmain's entries.Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV): builds; conventions pass; full suite green apart from the two knownmainregressions (agc_driver_tessellation— Mesa, #5444;agc_driver_bda_device— #7584), neither from this PR.To pick it up:
Head is
f725dfca4.Imported from boykopovar/AnyPS5. Originally posted by qpavyros on 2026-10-21T23:14:26Z.
Updated the published branch to
86279a794by merging maina6dcea927without force-pushing. Resolved the libkernel debt conflict while retaining both the archive-stream limitations and main's module-loading entry.Rebuilt and checked the focused archive/stream targets: Windows 17/17 and WSL Linux 18/18 passed, including all five archive stdio cases. Conventions reports 0 errors and diff checks pass. The description now records the current head, evidence and remaining limits; this is not a full-suite or console result.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T00:50:09Z.
@qpavyros a merge-order note: #9478 changes the same
ResolvePathError_nid_no_patchcall inlstat. It sets the resolver'smoduleflag, solstatfindsX.guest.prxfor a relinked module asstatdoes, where this PR sets thearchivedflag. The two should compose asResolvePathError_nid_no_patch(path, native, true, true), the callsceKernelCheckReachabilitymakes onmain. As #9478 is a one-line change, it proposes going first, and this PR would taketrue, truewhen it rebases. If you'd rather this one went first, say so and #9478 will list it under Depends on.Imported from boykopovar/AnyPS5. Originally posted by Gruzzberry on 2026-10-22T06:49:10Z.
#9474 changes the Windows host branch of
access_nid_postfix(it follows a symbolic link before reading the attributes and the security descriptor), next to the archive lookup this PR adds at the start of the same function. The two compose: the archive branch returns before the host checks. Either order works for me; whichever lands second keeps both and rerunsguest_accessand your archiveaccesschecks. Happy to rebase #9474 onto this one if it lands first.Imported from boykopovar/AnyPS5. Originally posted by Gruzzberry on 2026-10-22T11:49:38Z.
For the record: #9474 will go after this PR and rebase, keeping both the archive lookup and its link following; nothing is needed here. Its checklist now says so.
Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:04:18Z.
Review: COMMENTED
Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement;
Unblocks: noneis allowed. The technical points below are unaffected.1. No title reaches this on
main. "No PS5, game title, full-suite or performance validation is claimed" and "Unblocks: none". A title ID with a log line showing a libcfopenof anapp0.zar-only path would settle whether this is needed.2. Cost model of the design. Every
fopenof an archive-only entry decompresses the whole entry into a temp file (anyps5-app0-XXXXXXon POSIX,AnyPS5-app0-<pid>-<id>.tmpon Windows) before the first read returns, and each independent open does it again. For a title that opens a multi-hundred-MB asset to read a header, the stall and the disk traffic scale with the uncompressed size, not with the bytes read, and temporary space is needed per open. The body states this and does not size it. Two questions:sceKernelOpen/open. Why does libc not read the same entry on demand (chunked, askChunkSizealready is) instead of materializing it? "No separate stdio backend" is a reason of convenience, but the price is paid at runtime by every title.fopenthen returnNULLwith an errno that reflects ENOSPC, or a generic failure? A test for that case would pin it.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T02:42:24Z.
Review: COMMENTED
Reviewed — comments
No blocking defect was verified in the code inspected, but the review is incomplete because tests were not run and not every changed file was read.
What I ran
Inspected the prepared diff for head
7faf2fff1fffad65690a893f489943616d129aaaand targeted source ranges usingrepo_read.py. No build or test command was run.Results
Negative control
Not run; no test command was run.
Findings
Blocking
None verified in the inspected code.
Non-blocking
None.
Sources
Reviewed the prepared diff and source at the pinned head. Inspected
AppArchiveStream.cpp,AppArchive.hpp,AppArchive.cpp,FileAndHeap.cpp,Filesystem.cpp,ArchivedFile.cpp,Stdio.cpp, andFileStream.hppin whole or in targeted ranges.Not verified
Tests, builds, and runtime behavior were not verified. The changed files
CMakeLists.txt,GuestArchiveStdio.cpp,docs/dev/debt/libc.md, anddocs/dev/debt/libkernel.mdwere not read from their full head text;AppArchive.cpp,FileAndHeap.cpp,Stdio.cpp, andFileStream.hppwere only read in selected ranges. The manifest lists 12 changed files, all included; no exclusions were reported by the file listing.To get this to a good state
Nothing is required. Optional: run the focused archive stdio tests on Windows and Linux, and review the changed files and ranges not inspected here.
Pull request closed