feat(libkernel): implement sysctlnametomib for the sysctl names AnyPS5 serves #5502
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5502"
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 ahmad3a4 on 2026-10-13T21:30:35Z.
What
sysctlnametomib(UkEV4hvMo1E) is not exported, so Java 25 LAN / DNS (PPSA99869) stops in the loader onmain:It is added in
SystemConfiguration.cppfor the names whose MIBsysctlalready serves, with their FreeBSD numbers from<sys/sysctl.h>:hw.modelhw.ncpuhw.physmemhw.realmemkern.arandomkern.proc.pathnameThe rest follows FreeBSD:
sysctlnametomib.c, which runsname2oidthroughsysctlwith*sizepscaled to bytes and back. With a nullmibpit reports the entry count. With a short buffer it copies what fits, sets*sizepto the entries copied and fails withENOMEM, through the sameCopyOutthatsysctluses.sysctl_sysctl_name2oidinkern_sysctl.c: an empty name fails withENOENT, and a name ofMAXPATHLEN(1024) bytes or more fails withENAMETOOLONG.machdep.cacheline_sizefails withENOENT, assysctlbynamealready answers it.invalid_argument:sysctlnametomib.cdereferences both (strlen(name),*sizep *= sizeof(int)) before the syscall, so FreeBSD faults there.Any other name throws "unsupported name", as
sysctlbynamedoes.kern.sdk_version,kern.rng_pseudo,machdep.tsc_freqandvm.overcommitthrow too:sysctlbynameanswers them by name, butsysctlserves no MIB for them that this could return.The new function sits at the end of the file, apart from the
sysctlandsysctlbynamebranches other pull requests change.guest_system_configurationchecks, for every name:It then checks that:
hw.ncpuMIB reads the processor count back throughsysctl;hw.realmemMIB reads throughsysctlthe valuesysctlbyname("hw.realmem")gives;kern.proc.pathnameplus-1reads/app0/eboot.bin;ENOMEMand keeps the copied entry;machdep.cacheline_sizeand a 1024-byte name give the errors above, and null pointers throw;kern.cp_timesthrow.On
mainthe test does not link (undefined reference to sysctlnametomib_nid_postfix).Tested
Windows 11 Pro (26200), WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, rebased ontomain1209d370:guest_system_configurationpasses (3 runs).ctestpass: 1140 tests, 8 of them skipped by their own environment checks.libkernel.prxsucceeds.With the PR, Java 25 LAN / DNS (PPSA99869, relinked with
--trap-sdk-syscall-stubs) gets past this import, and the loader stops at the next one:psx0YiAKm7kisfegetenv(#5563).tools/import_audit.pygoes from 4 absent imports to 3.Linux not tested.
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
Imported from boykopovar/AnyPS5. Originally posted by pipe1os on 2026-10-14T05:42:03Z.
Built and ran this on Windows: head
0cb9540abmerged ontomainf5424b4db(no conflicts), Windows 11, WinLibs GCC 15.2.0, Ninja Release.guest_system_configurationpasses. WithSystemConfiguration.cppput back tomainand the test kept, it doesn't link (undefined reference to sysctlnametomib_nid_postfix).--windows --to-intel --trap-sdk-syscall-stubs. Onmainthe loader stops atUkEV4hvMo1E; with this PR it gets toFAIL: unresolved ELF import psx0YiAKm7k from libSceLibcInternal.prx(#5563).Two things against FreeBSD 11.0:
hw.realmemisn't in the table.mainserves it throughsysctl(6.12) andsysctlbynamesincefe5493849, which landed after this branch's base. On the merge,sysctlbyname("hw.realmem")returns 0 butsysctlnametomib("hw.realmem")throwsunsupported name hw.realmem. Probably just needs{"hw.realmem", {6, 12}, 2}.nameorsizereturnsEFAULT.sysctlnametomib.cdereferences both in userland (*sizep *= sizeof(int),strlen(name)) before the syscall, so the caller faults there.sysctlbynameonmainalready answersEFAULTthe same way, so maybe that's the accepted convention, but a throw would be closer.Everything else lines up:
ENOENTfor an empty name andENAMETOOLONGfrom 1024 bytes (sysctl_sysctl_name2oid), a short buffer copying what fits withENOMEMand the copied length (sysctl_old_user,userland_sysctlL1996-L1999), and the MIB numbers (sysctl.h).AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by ahmad3a4 on 2026-10-14T08:02:50Z.
Thanks for building and running it. Both points are in the new head
cc3d25d63, rebased ontomain1209d370:hw.realmemmaps to{6, 12}.guest_system_configurationreads it throughsysctlwith that MIB and compares it withsysctlbyname("hw.realmem").invalid_argument, sincesysctlnametomib.cfaults on both before the syscall.sysctlbynameis left as it is.kern.sdk_version,kern.rng_pseudo,machdep.tsc_freqandvm.overcommitstill throw:sysctlbynameanswers them by name, butsysctlserves no MIB for them.Re-tested on Windows:
guest_system_configurationpasses, and the fullctestpasses (1140 tests, 8 skipped by their environment checks). PPSA99869 still gets pastUkEV4hvMo1Eand stops atpsx0YiAKm7k(#5563).AI-assisted.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T11:49:27Z.
Progress report (
31bfc4e→cc3d25d)➖ System libraries: 88.19% (+0.0%, +1 implemented functions)
✅ 1 implemented
sysctlnametomib_nid_postfixImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:50:38Z.
Checked on the merge with main:
guest_system_configurationpasses and fails to link without the change, the MIB numbers,name2oiderrors andENOMEMhandling match FreeBSD, and both points from the earlier review (hw.realmem, null name/size) are addressed with tests. Windows run by @pipe1os also confirms the loader gets pastUkEV4hvMo1E. Merging.