Repository navigation
fix(libkernel): answer mkdir and file creation on app0.zar paths with EEXIST and EROFS - #28117
Conversation
… EEXIST and EROFS Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
PrivacyOnion
left a comment
There was a problem hiding this comment.
Verified on Linux (Ubuntu 24.04, GCC 13.3, Ninja, Release) against 9acd90797b:
- Conventions:
tools/check_conventions.pypassed. - Build:
guest_app_archive_tests,guest_kernel_app_archive_testsbuilt cleanly. - CTest (
guest_app_archive_present,guest_app_archive_absent,guest_app_archive_damaged,guest_app_archive_invalid,guest_kernel_app_archive_archive,guest_kernel_app_archive_plain,guest_kernel_app_archive_mmap,guest_kernel_app_archive_mmap-failure,guest_kernel_app_archive_mmap-damaged):1/9 Test #1261: guest_app_archive_absent ................ Passed 0.00 sec 2/9 Test #1260: guest_app_archive_present ............... Passed 0.01 sec 3/9 Test #1262: guest_app_archive_damaged ............... Passed 0.01 sec 4/9 Test #1263: guest_app_archive_invalid ............... Passed 0.01 sec 5/9 Test #6709: guest_kernel_app_archive_plain .......... Passed 0.01 sec 6/9 Test #6708: guest_kernel_app_archive_archive ........ Passed 0.01 sec 7/9 Test #6711: guest_kernel_app_archive_mmap-failure ... Passed 0.01 sec 8/9 Test #6712: guest_kernel_app_archive_mmap-damaged ... Passed 0.01 sec 9/9 Test #6710: guest_kernel_app_archive_mmap ........... Passed 0.49 sec 100% tests passed, 0 tests failed out of 9 - Negative control: with
core/libs/prx/libc/include/AppArchive.hpp,core/libs/prx/libc/src/AppArchive.cpp,core/libs/prx/libc/src/FileAndHeap.cpp,core/libs/prx/libkernel/File/src/Open.cpp,core/libs/prx/libkernel/File/src/Stdio.cppreverted tomainand the new tests kept, the suite fails:Restoring the change makes it pass again.3/9 Test #6711: guest_kernel_app_archive_mmap-failure ... Passed 0.01 sec 4/9 Test #6709: guest_kernel_app_archive_plain .......... Passed 0.01 sec 5/9 Test #1260: guest_app_archive_present ...............***Failed 0.01 sec 6/9 Test #1262: guest_app_archive_damaged ............... Passed 0.01 sec 7/9 Test #1263: guest_app_archive_invalid ............... Passed 0.01 sec 8/9 Test #1261: guest_app_archive_absent ................ Passed 0.00 sec 9/9 Test #6710: guest_kernel_app_archive_mmap ........... Passed 0.53 sec 78% tests passed, 2 tests failed out of 9 - Code reading:
- Verified AppArchiveCreateError_nid_no_patch normalizes path components and trailing separators via parent_path() loop, correctly identifying archive parent directory vs file.
- Verified error codes (EROFS = 30 / SCE_KERNEL_ERROR_EROFS, ENOTDIR = 20 / SCE_KERNEL_ERROR_ENOTDIR, EEXIST = 17 / SCE_KERNEL_ERROR_EEXIST) match FreeBSD 11.4 VFS lookup specifications.
- Verified sceKernelMkdir, mkdir, sceKernelOpen, and fopen integration across libc and libkernel without introducing unhandled exceptions or thread-safety issues.
- Verified AGENTS.md compliance: debt documentation fragments in docs/dev/debt/changes/ added with proper structure, no forbidden code comments, and no title-specific hardcoding.
Looks Good To Me
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
|
Linux check of the exact head
AI-assisted: yes |
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed — no blocking findings
Nothing blocks this change based on the source reviewed; the test commands were not run.
What I ran
Inspected the prepared diff and all eight changed files at head 9acd90797b4c443f5ff2e53263125b84abcb7224. No test or build command was run.
Results
| Check | Result | Note |
|---|---|---|
| Changed source review | passed | All changed files read |
| Tests and build | not run | No execution environment available |
Negative control
Not run; no test execution was available.
Findings
Blocking
None identified in the source reviewed.
Non-blocking
None.
Sources
The implementation routes mkdir, O_CREAT and fopen creation attempts through the shared archive-parent check, while preserving archived-file lookup first. The added tests cover existing archive entries, archive-only parents, file parents, missing paths and host-side non-creation.
Not verified
The author-reported Windows and title runs were not independently verified. Changed files read: core/libs/prx/libc/include/AppArchive.hpp, core/libs/prx/libc/src/AppArchive.cpp, core/libs/prx/libc/src/FileAndHeap.cpp, core/libs/prx/libkernel/File/src/Open.cpp, core/libs/prx/libkernel/File/src/Stdio.cpp, core/libs/tests/GuestAppArchive.cpp, core/libs/tests/GuestKernelAppArchive.cpp, and docs/dev/debt/changes/fix-libkernel-app0-zar-mkdir.md. All eight files listed as reviewed in the manifest were read; files.json was not available in the prepared bundle.
To get this to a good state
Nothing is required.
|
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.
Some 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.
|
|
Windows check of head Setup: Windows 11 Pro 10.0.26300, Ryzen 7 7800X3D, WinLibs GCC 15.2.0 r7, Ninja, Release,
Not run: any title. AI-assisted: yes |
What
sceKernelMkdirandmkdirthrew "reading /app0/engine in app0.zar not implemented" for a path that exists only inapp0.zar: the path lookup refused archive-only entries beforemkdircould answer. Creating a file directly inside an archive-only directory, throughsceKernelOpenwithO_CREATor libcfopenin aworamode, answeredENOENTbecause the host has no such directory; the console's read-only mount answersEROFS. All of them now see the archive and answer as FreeBSD 11.4 does on a read-only mount, without creating anything on the host:mkdirof a path in the archive (/app0/engine,/app0/engine/)EEXISTkern_mkdiratreturns it once the lookup finds the entry, before any write check, as AnyPS5 already does for a directory on diskmkdir,O_CREATorfopenw/aof a new name inside an archive-only directoryEROFSEROFSwhen opened for writingENOTDIRsceKernelOpenwithoutO_CREAT,fopenr+)ENOENTAn existing archived file keeps its answers (
EEXISTwithO_EXCL,EROFSfor writing), and paths that also exist on disk keep today's behaviour. The check lives in one libc helper,AppArchiveCreateError_nid_no_patch, used by all three. The console's/app0PFS answers are not measured; the debt fragment says so./app0/enginesceKernelMkdir, creating the directories forengine/saved/config/ps4/manifest.iniOverlaps #18190 at
mkdir_nid_postfixinStdio.cpp, which it renames tomkdir_nid_no_patchwith a wrapper, and #27855 inOpenNative, which renames itsflagsparameter torequestedFlagswhere the newO_CREATcheck reads it. Neither does the same work; whichever lands second keeps the other's rename and these lines.Tested
Windows 10, WinLibs GCC 15.2.0 r7:
guest_kernel_app_archive_*(5 modes) andguest_app_archivepass, with the newsceKernelMkdir,mkdir,O_CREATandfopencases and checks that nothing was created. CUSA12982, packed inapp0.zarand built with #28088, #28089, #27342 and #27937, now gets past/app0/engine, tries its config files and readstitle.json, then stops on its own "PSN: Failed to initialize the np toolkit" assertion, which is unrelated to the archive.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)🤖 Generated with Claude Code
Summary by CodeRabbit
EEXIST, attempts to create new items in read-only archive directories reportEROFS, and invalid paths report errors such asENOTDIRorENOENT.