feat(libkernel): enumerate archived app directories #8520
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8520"
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-20T14:48:28Z.
What
Support archive-only and disk/archive merged directory enumeration through libc and libkernel, preserving disk overrides, shared directory cursors, seek/rewind and native host directories. This is separate from #7447's archive-backed stdio and does not implement console PFS.
The Windows review regressions are addressed:
NativeFutimesandNativeSyncretain the path-based route for native-backed directory descriptors as well as virtual placeholders. Virtual archive-directory guards remain in place. The rename regression verifies filesystem identity instead of identical path spelling, exercises different Windows drive-letter casing, and rejects the recreated replacement directory. The inode and directory-entry checks remain, while ordinary-directory chmod, timestamp and sync checks now require success explicitly.Merged current main
acb900c194325b9ee8c23c10768a9a491454f0b2without rewriting the published branch. Merge resolutions use the canonical export headers, including the owning libSceLibcInternal declaration for fdopendir. #8116, #8591 and #9502 are merged; no open dependency remains. The combined tree retains both the pipe and virtual-directory guards from the previously coordinated #9502 overlap.Tested
Validated source head:
9b2dd8dce9e1da356fd04eadb92b5d5c767e52e2.guest_file_timestampsandguest_kernel_app_archive_plain.The native Windows path probe separately demonstrated that a case-variant drive prefix can compare unequal lexically while identifying the same renamed directory, and not the replacement. This proves the test assumption is unsafe; it does not assert the exact spelling observed in the earlier CI failure.
CTest selection on each configured build:
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-20T14:48:37Z.
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 oneandonlydean on 2026-10-20T15:28:34Z.
Thanks, this reads well, and the stacked #8116 part is unchanged. I reviewed only this PR's own share (main + #8116 vs main + this head). Two small things before it can go in:
File number 0 for large inodes.
MakeEntry(libc/src/Directory.cpp) andAdd(libkernel/File/src/DirectoryDescriptor.cpp) storeinode <= UINT32_MAX ? inode : 0. FreeBSD 11'sreaddirskips any entry whosed_filenois 0 (lib/libc/gen/readdir.c:83,if (dp->d_ino == 0 && skip) continue;). So on a Linux host whose filesystem hands out 64-bit inode numbers (XFS with inode64, for example), a guest that reads a merged directory throughgetdentsand its own FreeBSD-stylereaddirsilently loses those entries. #8116 already solved this for Windows:WindowsFileNumber_nid_no_patch(std::uint64_t)folds the high half in and never returns 0, and its test requires a nonzero number. Using that same fold, or a shared helper, in both places would keep the two paths consistent.The
g_directoryCountfast path. On main,IsDirectoryDescriptor,ForgetDirectoryDescriptor,DuplicateDirectoryDescriptorandSeekDirectoryDescriptorreturn before takingg_mutexwhile no directory descriptor is open (DirectoryDescriptor.cpp:96,:105). This PR removes that and, at the same time, callsIsDirectoryDescriptorat the top of everyread/write/pread/pwrite/readv/writev/preadv/pwritev, pluslseek,closeand the AIO pread/pwrite, on Linux as well as Windows. So every guest file read now takes one process-wide mutex, even in titles that never open a directory. Keeping the atomic count (incremented inOpenDirectoryDescriptorandDuplicateDirectoryDescriptor, decremented on erase) and checking it beforeFindrestores the old cost.Neither changes the archive behaviour your tests cover. Please also keep "merge #8116 first" in the description, since this head contains its commit.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T18:42:26Z.
One concurrency detail in the Windows
sceKernelGetdirentriespath: the new code callsSeekDirectoryDescriptor(fd, 0, 1)to setbasep, then callsReadDirectoryDescriptor; those take the directory-state mutex separately. Two threads reading the same descriptor can both observe the same cursor forbasep, while the second read consumes entries after the first and should report the advanced start position. Could you add a concurrent-read regression or capturebasepfrom insideReadDirectoryDescriptorwhile it holds the state mutex? PR #8591 proposes an optional base out-parameter on that helper, which would make the reported position atomic with the read.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-20T19:30:01Z.
Coordination update from #8591: its author says they are happy to rebase onto whichever PR lands first and have no objection to #8520 adopting the
ReadDirectoryDescriptorbase out-parameter. If you choose to use that helper, they would then reduce #8591 to the Windows test-registration change. Either merge order remains possible; this just gives you the option without duplicating the concurrency-sensitive cursor read.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T11:31:46Z.
Review: CHANGES_REQUESTED
Thanks for the work. #8116 is merged, and this head now conflicts with
maininlibkernel/File/src/DirectoryDescriptor.cpp,libkernel/File/src/Stdio.cppanddocs/dev/debt/libkernel.md. These need a real resolution, so please rebase. Three points are still open:libc/src/Directory.cpp:253andlibkernel/File/src/DirectoryDescriptor.cpp:92storeinode <= UINT32_MAX ? inode : 0. FreeBSD'sreaddirskips entries withd_fileno == 0(lib/libc/gen/readdir.c), so entries on filesystems with 64-bit inodes disappear. Reuse the fold fromWindowsFileNumber_nid_no_patch(never returns 0), or a shared helper, in both places, and add a test row with an inode above 2^32.g_directoryCountfast path removed:IsDirectoryDescriptor,Forget,DuplicateandSeekused to return before takingg_mutexwhile no directory was open. Now everyread/write/pread/pwrite/readv/writev/lseek/closeand the AIO paths take the process-wide mutex. Keep the atomic count (incremented on open/duplicate, decremented on erase) and check it beforeFind.baseprace on Windows (@MarcZX10's point):SeekDirectoryDescriptor(fd, 0, 1)followed byReadDirectoryDescriptortakes the state mutex twice, so two threads can report the same start position. Capture the base inside the read while the mutex is held (see the out-parameter proposed in #8591), and add a concurrent-read test.Please keep "merge #8116 first" out of the description now that it has landed, and update
Depends onaccordingly.Imported from boykopovar/AnyPS5. Originally posted by qpavyros on 2026-10-21T22:57:17Z.
Addressed in c5e28b09a, after merging main
a6dcea927without force-pushing.Focused validation: Windows 17/17 and WSL Linux 13/13; conventions and diff checks pass. No full-suite or console validation is claimed. The description now contains the current evidence and limits.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:29:50Z.
The current overlap scan flags #9502’s
sceKernelFchmodpipe guard against your virtual-directory guard in the same function. I reviewed both hunks: the checks are distinct and should compose, but the shared function region needs the repository-required author coordination. Please coordinate with #9502’s author on rebase/merge order and have the dependent PR documentDepends onif one must land first.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-25T06:46:46Z.
Review: CHANGES_REQUESTED
The full Build on the exact head (run 40124700259) fails two Windows tests that
maindoes not fail:guest_file_timestamps:update later modification time (guest errno 13)on a directory.Stdio.cpp:190(NativeFutimes) now takes the path-based route only forIsVirtualDirectoryDescriptor; onmainany descriptor with aDirectoryDescriptorPathtook it. A native-backed directory descriptor on Windows now falls through toReOpenFileand fails with EACCES.NativeSync(Stdio.cpp:210) has the same change and probably the same problem. Fix: keep the path-based route for native-backed directory descriptors on Windows too.guest_kernel_app_archive_plain:app0.zar kernel check failed at line 498(GuestKernelAppArchive.cpp:498,File::DirectoryDescriptorPath(fd) == renamedafter renaming an open directory). It holds on Linux (/proc/self/fd) but not on Windows with a native-backed descriptor. Please check whatWindowsDescriptorPath_nid_no_patchreturns for that descriptor, or relax the check to what Windows can guarantee.Both tests ran in 0.01-0.03 s, so this is not a timeout or runner problem. The branch also conflicts with current
mainnow, so it needs a rebase on top of the fix. A local Linux run does not cover either path; the Windows job does.