feat: read title files from a read-only app0.zar (ZArchive) layer #5835
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5835"
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 AlexOfTheForest on 2026-10-14T12:59:24Z.
What
Closes #4848. Adds an opt-in, read-only
app0.zar(ZArchive) besideapp0/. A path missing fromapp0/is looked up in the archive case-insensitively; files on disk take precedence. Without an archive nothing changes.build: zstd v1.5.7 and ZArchive as submodules, built from source as static PIC libraries; their symbols are excluded from the.prxexport table on Linux.libc: archive reader, archived-descriptor table with shared positions, and a guard inResolvePath_nid_no_patch. Any call that does not read the archive throwsNotImplementedfor an archive-only path instead of returningENOENT.opendirof a directory present on disk and in the archive,fdopenof an archived descriptor andchdirinto the archive also throw...through an archive-only directory resolves.libkernel:sceKernelOpen/opengive an archived file a read-only null-device descriptor.read,pread,readv,preadvand AIO reads are served from the archive.lseek,fstatandFIONREADare served from the archive.dup,dup2andF_DUPFDshare the position.sceKernelStatandsceKernelCheckReachabilitysee archived paths.EROFS,O_CREAT|O_EXCLwithEEXIST, andO_DIRECTORYon a file withENOTDIR. Opening an archived or merged directory throws untilgetdentscan list it.fopen,access,mmap, record locks, directory listing) are recorded indocs/dev/debt/libc.mdandlibkernel.md; usage is indocs/user/USAGE.md.Tested
Linux x86-64, GCC, full build with
BUILD_TESTING=ON.guest_app_archive_{present,absent,damaged,invalid}andguest_kernel_app_archive_{archive,plain}. They cover:dup,F_DUPFDandclose, anddup2over an archived descriptor;stat/fstat, the error codes, the refusals, a damaged block and an invalid archive;sceKernelReadhook makes the kernel test fail.ctest: only environment failures (UDP/TCP sockets unavailable in the sandbox; shm EACCES check while running as root).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 adriadam10 on 2026-10-14T13:55:25Z.
Review: CHANGES_REQUESTED
Thanks for this, the layering and the tests are careful. One blocking issue before merge:
core/libs/prx/libkernel/File/src/ArchivedFile.cpp:23), and only read/seek/stat/FIONREAD/AIO/dup check for it. Every other descriptor call still runs on the null device:mmap_nid_postfix(DirectMemory/PosixMemory.cpp:92, takes the fd straight to the hostmmap),fchmod,fchown,futimes,flock,ftruncate,fsync/fdatasync(File/src/Stdio.cpp~288-311, 693, 736, 903, 913). They either succeed silently or fail with an unrelated errno, andfchmod/futimesact on the host's/dev/null. That contradicts "any call that does not read the archive throwsNotImplemented" in the description and the exact-or-throw rule (titles commonlymmaptheir assets).NotImplemented(asfdopenalready does), and the debt line indocs/dev/debt/libkernel.mdlists them. Add a test inGuestKernelAppArchive.cppthat calls each one on an archived fd.Also note: the Windows paths (
NULplaceholder, linkingzarchiveinto libc) are not exercised by the PR CI, so the full Build dispatch will be the evidence for them.Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-14T14:11:07Z.
Thanks for the review now it should be fixed
Imported from boykopovar/AnyPS5. Originally posted by AlexOfTheForest on 2026-10-15T05:20:09Z.
@adriadam10 Thanks for the review. Fixed in e403613 (
fix(libkernel): refuse descriptor calls on app0.zar files).On an archived descriptor,
flock,fstatfs,ftruncate,fsync,fdatasync,getdirentries,fchmod,futimesandmmapnow throwNotImplemented. They all go through one guard,File::RefuseArchivedFileinArchivedFile.cpp, the same wayfdopenis refused in libc. libkernel has nofchownexport, so that one needed no change.mmap_nid_postfixis declarednoexceptin several translation units, so its refusal terminates the process. Themmapmode of the test checks the terminate path through libc'sset_terminateand the current exception, asGuestItimer.cppdoes. This is noted indocs/dev/debt/libkernel.md.Tests:
GuestKernelAppArchive.cppchecks each call. Removing any one of the nine guards makes the test fail; with all of them, the 7 archive tests pass on Linux. The Windows paths still need the full Build dispatch, as you said.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T11:24:35Z.
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)docs/dev/debt/libkernel.mdL202core/libs/prx/libc/src/General.cppL194-195, L203-209CMakeLists.txtL273core/libs/prx/libkernel/File/src/Open.cppL225-226core/libs/prx/libkernel/File/src/NativeStat.cppL2docs/dev/debt/libkernel.mdL202docs/dev/debt/libc.mdL83docs/dev/debt/libkernel.mdL202.gitmodulesL42Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
.gitmodulesCMakeLists.txtdocs/dev/debt/libc.mddocs/user/USAGE.mdcore/libs/prx/libkernel/CMakeLists.txt.gitmodulesCMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel/File/src/Open.cppcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libc.mddocs/dev/debt/libkernel.mddocs/user/USAGE.mddocs/dev/debt/libc.mddocs/user/USAGE.mdcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/FileAndHeap.cpp.gitmodulesdocs/user/USAGE.mddocs/user/USAGE.mdCMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libc/CMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/CMakeLists.txtcore/libs/prx/libkernel/DirectMemory/PosixMemory.cppcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libc.mddocs/dev/debt/libkernel.mdcore/libs/prx/libc/include/FilesystemError.hppcore/libs/prx/libkernel/File/src/Stdio.cppdocs/dev/debt/libkernel.mdCMakeLists.txtcore/libs/prx/libc/src/General.cppcore/libs/prx/libkernel/File/src/NativeStat.cppcore/libs/prx/libkernel/File/src/Stdio.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:16:19Z.
Review: APPROVED
Rebased onto current main: the only real conflict was
File/src/Stdio.cppinTransferIovecs, where main addedFile::LockPositionedTransfer(d). Kept both, the archived read first and the lock after it. No other change to the PR.guest_app_archive*andguest_kernel_app_archive*pass on the rebased tree. Merging once the full Build (Windows) is green.