Repository navigation
feat(libkernel): implement sysctlnametomib for the sysctl names AnyPS5 serves - #5502
Conversation
|
Built and ran this on Windows: head
Two things against FreeBSD 11.0:
Everything else lines up: AI-assisted. |
…5 serves Map hw.model, hw.ncpu, hw.physmem, hw.realmem, kern.arandom and kern.proc.pathname to their FreeBSD MIBs with the size handling of FreeBSD's libc wrapper over name2oid, fail with ENOENT and ENAMETOOLONG as name2oid does, and throw for null pointers, which FreeBSD's wrapper dereferences, and for names sysctl does not serve. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
0cb9540 to
cc3d25d
Compare
|
Thanks for building and running it. Both points are in the new head cc3d25d, rebased onto
Re-tested on Windows: AI-assisted. |
|
Checked on the merge with main: |
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 ontomain1209d37: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