feat(libkernel_sys): implement statfs symlinkat and futimesat #9161
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9161"
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 yabanana on 2026-10-21T14:04:55Z.
What
Implement
statfs,symlinkatandfutimesatfrom the libkernel_sys discovery exports.statfsresolves the guest path and shares the existing host-volume translation with_fstatfs, without opening the file for reading. Its 472-byte output uses the commonGuestCopyOut_nid_no_patchchecked-write boundary, returningEFAULTfor inaccessible, read-only or partly inaccessible buffers and retaining host-write tracking. Archive-only paths still throw.symlinkatreuses the existing symlink implementation with a descriptor-relative destination;futimesatreuses timestamp conversion and application. Absolute paths ignore the descriptor andAT_FDCWDuses the guest working directory. Invalid descriptors, non-directory descriptors, path limits, timestamp limits and null arguments are checked. FreeBSD's null-pathEFAULTis retained for futimesat, rather than Linux's descriptor-only extension.Export/NID presence was checked against the PS5 3.20 table. Signatures and semantics follow FreeBSD 11.4 symlink(2), statfs(2) and kern_utimesat. Existing mount identity, guest-root resolution, symlink-target and Windows path/privilege limitations are recorded in technical debt; no console or title-unblock claim.
#9008 is now merged. This branch includes its fstat-stub removal and retains the typed futimesat provider, so there is no remaining landing dependency.
The current-main integration keeps its checked guest-path copies and one shared symlink implementation. symlink/symlinkat have one definition each; statfs, futimesat and symlinkat have their typed declarations in libkernel_sys/include/Api.hpp. The statfs/timestamp helpers now use main's checked path snapshots as well.
Tested
9 November refresh at
38c80b83372f5a7d55958550712898a9a6184704withmain67092e70b5211ed86d7a15e22cd10bca651901f5merged. The merge retains both the raw-socket skip from upstream and the two privilege-only symlink skips. The relocation registrations and fixture follow upstream’s split suite.14 focused Linux full-kernel executions pass. All 40 skip-checker tests pass, along with 9 macOS x86_64 relinker checks covering the split relocation suite and web packaging. All 39 web packaging tests, conventions, whitespace and the public-header audit (407 libraries and 33,818 exports) pass. Linux results use GCC 13.3 and a full Alpine 6.12.110 kernel under QEMU TCG with SMAP off, with fresh SHA256-verified binaries. macOS checks use macOS 27.3 and Apple clang 21 on ARM64 with an x86_64 target. New hosted checks are pending.
5 November CI fix: head
3adb34cdc76db8d17fd13fe98f6f4477ccee70efcherry-picks maintainer commitacdbf77838with its authorship. The macOS x86_64 hosted job timed out guest_none_relocations at20.07s. Upstream has reproduced the same budget issue and split its plain and SCE conversion groups into separate tests, each retaining TIMEOUT20; default all mode remains compatible with importing tests. Fresh local Release x86_64 relinker build passes none_relocations plus both guest halves, each repeated3times:9 executions, zero skips,10.92s total. macOS27.2/Appleclang21/ARM64 host running the x86_64 slice via Rosetta. Conventions and whitespace pass; syscall source and previously approved path tests are unchanged. New hosted CI is pending.4 November update: head
e0de57dc217c355b75b188f334caa2bf96df5b44, mainb11c7bf84fintegrated with published ancestry preserved. Removed stale parent-target refusal tests/wrapper; successful symlink creation now also checks a../datatarget inside a child directory in the supported AT_FDCWD path. The error cases remain.statfsnow uses shared GuestCopyOut_nid_no_patch instead of its private checked-write implementation, and debt reflects main's conditional parent-target refusal. The Windows privilege-only skip allowance remains necessary for the new symlink test; 37 skip-checker regressions pass.14/14 focused full-kernel Linux executions pass (six common suites and eight syscall DLL/case combinations). Public-header ownership audit passes:406 libraries /28,350 exports. Conventions and whitespace pass. GCC13.3 cross on ARM64/Ubuntu24.04, Alpine6.12.110 kernel under QEMU8.2.2TCG cpu=max,smap=off,2vCPUs1536MiB, SHA256-verified fresh binaries. No fresh native Windows run; hosted checks must confirm this head. Earlier contributor reports remain tied to their original revisions. The first VM packaging attempts omitted main's new libSceNet/NetCtl dependencies; those loader failures are excluded and retained separately. The final run includes the actual built dependency closure.
29 October documentation update: the debt entry now explicitly records that Linux FIFO/socket paths report their containing filesystem and that console special-file behaviour remains unmeasured. Runtime source and tests are unchanged from
d2f98f3910f054a76c793738be3d04d070a88c30.benjaminmathias's native Windows report covers that source head integrated with main
2227f1366188cda5699dd20e2e756a18006a5d4bas treec5708ba8076e89775a81e05416f97d67862a03dd: Windows 11 Pro 10.0.26300, Ryzen 7 5700X3D, WinLibs GCC 15.2.0 r7 UCRT Release. The integration has 48 passing executions and two explicit symlink-privilege skips; matched main has 24 passes. The actual JUnit passes this PR's skip checker and fails main's checker for exactly those two skips. Successful symlink creation/reparse assertions still require a privileged Windows run. This is attributed contributor evidence, not a local rerun or full-suite approval.xdCloudy's firmware 13.60 wrapper analysis identifies statfs forwarding path/output to syscall 396; that supports the wrapper shape, not unmeasured console filesystem semantics. #12695 removed its duplicate statfs and depends on this provider.
28 October refresh: head
d2f98f3910f054a76c793738be3d04d070a88c30, mainc02d287bd0eb9fe0718940b2735811e97c2eb509integrated by normal merge, preserving published ancestry. 14/14 focused Linux full-kernel executions pass on SHA256-verified binaries (GCC 13.3, Alpine 6.12.110, QEMU system 8.2.2 TCG, two vCPUs, 1536 MiB, cpu=max,smap=off). Tests/assertions were not changed. With SMAP enabled, the general kernel test hits a kernel fault at the new upstream context-restore IRET and times out; this CPU profile is not qualified by this refresh. No blanket native-hardware or zero-failure claim is made. Public-header ownership audit passes (368 libraries / 13,051 exports), as does full header compilation; conventions and whitespace checks pass; all 34 skip-checker tests pass. Fresh supported Windows runtime/full maintainer CI remains required. Earlier results below retain their original revisions.27 October: maintainer @oneandonlydean merged main
74acfad65binto headd086e569050ed0d3a68d20444f8eae5a39cb10fd. That merge and authorship are retained. The reparse fixture and skip checker are byte-identical toc24c61778c; the exported symlinkat implementation/declaration is retained and the relocated sysKernelGet* stubs follow main. Current-head conventions, public-header audit and standalone/combined compilation pass (368 libraries, 12,368 exports), using native ARM64 Python and the x86-64 cross compiler. The historical runtime results below remain tied to their stated heads. Automatic relinker/ASan checks pass; full product Linux/Windows jobs in that automatic run are skipped. The maintainer announced full CI; its exact-head native result is not yet verified here.26 October head
c24c61778c688066de6ec0f4258c95c145133432, integrated maine796ed4e5ewithout rewriting published history. The public-header conflict retains both the typed futimesat declaration and main's typed get_authinfo declaration.The Windows fixture now opens the link with FILE_FLAG_OPEN_REPARSE_POINT and reads FSCTL_GET_REPARSE_POINT. It requires IO_REPARSE_TAG_SYMLINK, the relative flag, bounded reparse data and the stored substitute target
data. Linux retains read_symlink. Content reads, duplicate/absolute/descriptor-relative path assertions, both DLL modes, error and subprocess-refusal checks remain. The only privilege skip remains EPERM, with return code 77.14/14 Linux full-kernel VM executions pass: four API/error selections in both library modes plus six common regressions. Linux x86-64 outputs built with GCC 13.3 cross compiler hosted on ARM64 / Ubuntu 24.04; copied binary SHA256s verified. Runtime: Alpine 6.12.110-0-virt, QEMU system 8.2.2 TCG cpu=max, two vCPUs, 1536 MiB. This is emulated CPU execution with real guest-kernel syscalls.
34 skip-checker tests pass after the main merge, including exact Windows creation privilege skips and rejection of mixed/prefixed unrelated reasons. Public-header audit passes (368 libraries, 12,228 exports); the affected libc/libkernel/libkernel_sys canonical headers compile together with repeated includes, and the complete targeted build passes. The all-library standalone and combined header compilation now also passes with native ARM64 Python and the existing GCC 13.3 x86-64 cross compiler. The earlier blocked emulated-Python run is retained separately; no ABI assertion was changed. Conventions and whitespace checks pass. The complete Windows fixture passes MinGW 13.2 UCRT syntax checks; this is not supported-toolchain native execution.
Native Windows CI 40249312977 identifies preceding head
16e92129ba: both creation cases abort onread_symlink: Function not implemented, while both error and both refusal cases pass. No JUnit artifact was available from that run. A private Wine 9 attempt cannot validate successful creation: Wine logs CreateSymbolicLinkW as a stub and opening the purported link fails with ERROR_FILE_NOT_FOUND. It is retained as an unsuccessful environment probe, not passing Windows evidence.Please rerun both creation, error and refusal modes plus check_skips.py --job windows on the runner's WinLibs toolchain for this head. Full Linux/Windows CI requires maintainer dispatch. Prior contributor native results remain tied to their original heads. No native creation, console, macOS or title execution claim for this update.
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 CnRJay on 2026-11-01T20:04:54Z.
Review: COMMENTED
Scope: the diff also edits
tools/check_skips.pyand addstools/tests/test_check_skips.py, which has nothing to do with the three syscalls. Is that needed for the newGuestKernelSysPathRefusaltest? If so say why; otherwise it belongs in its own PR.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-03T03:54:05Z.
Review: CHANGES_REQUESTED
Windows 11, WinLibs GCC, Release,
BUILD_TESTING=ON, head9f173116femerged onto currentmainf6232fcfda(clean merge):guest_kernel_sys_paths_statfs,_futimesat,_symlinkat_errors(each plus_patched),check_skips,check_skips_ctestguest_kernel_sys_paths_symlinkatand_patchedguest_kernel_sys_paths_symlinkat_refused_unpatchedand_patchedBlocking: the refusal tests are stale against current
main. Dom3005's69a7bd2c19("create symlink targets with parent-directory components", 2026-10-24) changedmain's symlink. A..target is now created whenever the host would follow it to the guest path it names. Only otherwise does it refuse, and with a different message: "symlink: a parent-directory target the host would not follow to the guest path it names" (core/libs/prx/libkernel_sys/Export.cpp:948onmain).This fixture still calls
symlinkat("../data", base, "refused")(core/libs/tests/GuestKernelSysPaths.cpp:229-231) and requires the old "parent-directory targets not implemented" text (core/libs/tests/GuestKernelSysPathRefusal.cmake:9-10). That call is now allowed and returns 0. The fix belongs in the test: either drop the refusal case, or pick a targetHostFollowsGuestTargetrejects and match the new message. The positive case could then assert that a../datalink is created where the privilege allows it.Firmware 13.42:
system/common/lib/libkernel_sys.sprx(sha2563d361753f6c472cd5442bf92652b4a1dee04051297a0155fe197ede0c2002d4a) supports the FreeBSD-syscall model. This is disassembly only, not measured on a console.statfs(0x1a90),futimesat(0x2190) andsymlinkat(0x2270) are bare wrappers:mov $0x18c,%rax,$0x1eeand$0x1f6respectively, thensyscall, and on carry a jump to the errno setter at0xd4. Those are FreeBSD's syscall numbers 396, 494 and 502 for the same calls, matching what xdCloudy reported for 13.60'sstatfs.Non-blocking:
check_skips.pyaudit rejected the new privilege skip (@oneandonlydean, 2026-10-24), so the allowance belongs here. It does conflict with #15095, which also extendscheck_skips.py: merging both ontomainconflicts intools/tests/test_check_skips.py, so whichever lands second needs a resolution.CopyStatfs(core/libs/prx/libkernel/File/src/Stdio.cpp) has its own checked write (VirtualQuery+WriteProcessMemory,process_vm_writev,mach_vm_write).mainnow hasGuestCopyOut_nid_no_patch(core/libs/prx/libc/include/General.hpp:36), which could replace it.Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-04T13:16:53Z.
Review: APPROVED
@yabanana thanks, my blocking point is resolved at
e0de57dc21. The stale refusal registrations (GuestKernelSysPathRefusal.cmakeand thesymlinkat_refusedcase) are gone. The positive case now creates../datafrom a child directory throughAT_FDCWDand reads the file back, which is whatmain's conditionalHostFollowsGuestTargetpath allows.What I ran: head
e0de57dc21(it fast-forwards ontomainb11c7bf84f), Windows 11, WinLibs GCC, Release,BUILD_TESTING=ON:guest_kernel_sys_paths_statfs,_symlinkat_errorsand_futimesat(each plus_patched),check_skipsandcheck_skips_ctestpass;guest_kernel_sys_paths_symlinkatand_patchedskip (77) for the missing symlink privilege on this machine. So the new../datacase didn't run here, and I'm relying on your Linux run for it;tools/check_conventions.py --base upstream/mainon the head: all checks passed;tools/pr_overlap.py --branch: no shared exports. None of the 12 PRs it couldn't compare addsstatfs,symlinkatorfutimesatlines.Approving.
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-05T14:16:28Z.
Review: APPROVED
@yabanana re-checked at
3adb34cdc7. The only new commit is the relinker test split, andgit range-diffshows it is the same patch asacdbf77838onmain; the PR's own changes are unchanged since my approval ofe0de57dc21. @oneandonlydean, that approval had already replaced my change request when you asked on the 4th; sorry I didn't say so on the thread.On
3adb34cdc7merged ontomain78e4248fea(Windows 11, WinLibs GCC 15.2.0, Release,BUILD_TESTING=ON):guest_kernel_sys_paths_statfs,_symlinkat_errorsand_futimesat(each plus_patched),check_skips,check_skips_ctest,guest_none_relocationsandguest_none_relocations_scepass;guest_kernel_sys_paths_symlinkatand_patchedskip (77) for the missing symlink privilege on this machine, as before.main'stools/check_skips.py,check_skipsfails and the rest pass. That control covers only the skip allowance, not the kernel calls.check_conventions.pypasses.pr_overlap.py --branchfinds no shared exports; #11034, #14902, #15037 and #15095 share lines, and 36 PRs that conflict withmaincouldn't be compared.Approving again at
3adb34cdc7.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-09T22:39:09Z.
Review: COMMENTED
@yabanana re-checked at
38c80b8337as asked. The merge is clean against currentmaine7c3bfd130, the eight tests and the tool test pass here, each export's own mutation control fails as it should, and nothing overlaps. One finding below, on the descriptor-relativefutimesatpath, reproduced here as a crash; everything else I approved at3adb34cdc7is unchanged.What moved since that approval.
38c80b8337is a merge commit, its parents are3adb34cdc7andmain67092e70b5, and it carries no other commit. Comparing the branch's own added and removed lines at the two heads, they are identical in seven of its files. Two differ, both correctly:tools/check_skips.pykeepsmain's raw-socket pattern in thedevice_limitationscall attools/check_skips.py:98and its sentence, and re-applies the branch's own filter in the same line. The filter itself istools/check_skips.py:29.docs/dev/debt/libkernel_sys.mdhas the same two entries, with one blank line added above them.The two relinker files left the branch:
mainregisters that test per mode and system atcore/relinker/CMakeLists.txt:656, the merge tookmain's version, and the branch's two-halves split is gone.main's split is the finer of the two, and I have no objection to the branch taking it.Finding (P2, reproduced below): the descriptor-relative
futimesatdereferences the guesttimesarray atcore/libs/prx/libkernel/File/src/Stdio.cpp:2089and hands the same pointer toNativeUtimesatcore/libs/prx/libkernel/File/src/Stdio.cpp:2098, with no copy-in on that path.Its three neighbours call
CopyInTimesfirst:core/libs/prx/libkernel/File/src/Stdio.cpp:2066,core/libs/prx/libkernel/File/src/Stdio.cpp:2080andcore/libs/prx/libkernel/File/src/Stdio.cpp:2104, each returning a failure for a pointer it cannot read rather than reading it. The function atcore/libs/prx/libkernel/File/src/Stdio.cpp:2088forwards toutimes_nid_postfixwhen the descriptor is -100 or the path is absolute. That path copies in atcore/libs/prx/libkernel/File/src/Stdio.cpp:2080. Only the descriptor-relative branch is in question, and I did not run the forwarding case against a bad pointer.The failing case, added as one more case to your own futimesat section right after
core/libs/tests/GuestKernelSysPaths.cpp:164: commit two pages, make the second one unreadable the way your statfs case does atcore/libs/tests/GuestKernelSysPaths.cpp:131, and callfutimesat(base, "data", <start of that second page>), expecting -1 and error 14. Both futimesat tests then end this way, in two separate runs at38c80b8337merged ontomaine7c3bfd130(0 of 2 passed, nothing Not Run):Your output-buffer cases already ask for -1 and error 14 in that situation, first with a read-only page at
core/libs/tests/GuestKernelSysPaths.cpp:128and then with a destination straddling an unreadable page atcore/libs/tests/GuestKernelSysPaths.cpp:136. I read those two as the answer you want for an unreadable input as well. Copying the array in before the check atcore/libs/prx/libkernel/File/src/Stdio.cpp:2089, the way the three lines above do it, would be enough, and it would also make the two spellings of the same call agree for one pointer. If you would rather keep the direct read, a line indocs/dev/debt/libkernel_sys.mdwould record it: I have not read firmware 13.42'sfutimesat, so I cannot say what the console does with an unreadabletimes.Scope question from @CnRJay (1 Nov). The
tools/check_skips.pychange is for this pull request's own tests, and this run shows it. On a Windows host without the symbolic-link privilege,guest_kernel_sys_paths_symlinkatandguest_kernel_sys_paths_symlinkat_patchedprint the reason atcore/libs/tests/GuestKernelSysPaths.cpp:172and exit 77 atcore/libs/tests/GuestKernelSysPaths.cpp:234, whichcheck_skips.pyreports as an unexpected skip without the new filter; the filter attools/check_skips.py:29matches that exact string for exactly those two test names. That places it with these tests rather than in a pull request of its own.Runs. Windows 11 Pro 10.0.26300, AMD Ryzen 7 5800X3D, WinLibs GCC, Release,
BUILD_TESTING=ON, head38c80b8337merged intomaine7c3bfd130(clean merge), withguest_kernel_sys_paths_tests,libkernel_sysandlibkernelrebuilt at that tree:guest_kernel_sys_paths_statfs,guest_kernel_sys_paths_statfs_patched,guest_kernel_sys_paths_symlinkat_errors,guest_kernel_sys_paths_symlinkat_errors_patched,guest_kernel_sys_paths_futimesatandguest_kernel_sys_paths_futimesat_patchedpass;guest_kernel_sys_paths_symlinkatandguest_kernel_sys_paths_symlinkat_patchedare Skipped for the privilege reason above. No symbolic-link creation ran on this host: both of those tests stop atcore/libs/tests/GuestKernelSysPaths.cpp:172, ahead of the reparse-point assertions and the-100, absolute-path and existing-link cases.py -3 -I tools/tests/test_check_skips.py: 40 tests, OK.guest_kernel_sys_paths_testsrelinked at the mutated tree.statfs_nid_postfixreturning 0 instead of callingPosixStatfs_nid_no_patch: both statfs tests fail.futimesat_nid_postfixreturning 0: both futimesat tests fail.symlinkat_nid_postfixreturning 0: all four symlinkat tests fail, the creation pair included, since with a reported success the skip branch atcore/libs/tests/GuestKernelSysPaths.cpp:172is not reached.core/libs/prx/libkernel_sys/include/Api.hpp, somain's implementations do not compile against this test. The mutations above stand in for it.tools/pr_overlap.py --branch ov-9161 --jobs 8on the merged head: no overlap with open pull requests, exit 0 — no shared file, export, line or new file.I have not reproduced @JJenkx's Windows
remove_alltimeout, and this host cannot: both symlinkat tests stop atcore/libs/tests/GuestKernelSysPaths.cpp:172before creating a link. Their finding and #17894 rest on their own runs, not on anything I checked.AI-assisted: yes (Claude Code)