feat(libkernel): support _SC_ARG_MAX, _SC_OPEN_MAX and _SC_IOV_MAX in sysconf #6833
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6833"
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 ErenYeager1836 on 2026-10-16T13:45:16Z.
What
Support standard FreeBSD system configuration limit queries in
sysconf(libkernel):_SC_ARG_MAX(1): returns262144(FreeBSDNCARGS, maximum length of arguments and environment)._SC_OPEN_MAX(5): returns1024(FreeBSD per-process maximum open file descriptors limit)._SC_IOV_MAX(56): returns1024(FreeBSDUIO_MAXIOV, maximumiovecstructures forreadv/writev).Updated
docs/dev/debt/libkernel.mdwith descriptions of the new supported queries, and added test assertions verifying the returned values inGuestSystemConfiguration.cpp.Tested
Windows 11, unit test suite (
guest_system_configuration_tests). Verifiedsysconf_nid_postfixreturns262144for_SC_ARG_MAX,1024for_SC_OPEN_MAX,1024for_SC_IOV_MAX, and preservesEINVALfor unsupported identifiers.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 github-actions[bot] on 2026-10-16T14:39:42Z.
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.
main)docs/dev/debt/libkernel.mdL19-21docs/dev/debt/libkernel.mdL18-19docs/dev/debt/libkernel.mdL18-19Some 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.
docs/dev/debt/libkernel.mdcore/libs/tests/GuestSystemConfiguration.cppdocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mddocs/dev/debt/libkernel.mdImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-16T16:25:37Z.
Review: COMMENTED
Tested on Linux, since the PR was only run on Windows. One semantic note on
_SC_OPEN_MAX.BUILD_TESTING=ON.2e4f63b81merged intomainat452494439.guest_system_configurationpasses. With onlyGuestSystemConfiguration.cppfrom the PR onmain, it aborts, so the new assertions catch the missing cases.-E "^agc|gpu|vulkan|video_out"): 648/650, same asmain. The two failures arefile_writer_binary/file_writer_text(uutilscp, fixed by #6877)._SC_ARG_MAX262144 and_SC_IOV_MAX1024 matchARG_MAXandIOV_MAXinsyslimits.hat the FreeBSD commit the debt file already cites, andIOV_MAXmatchesKERNEL_IOV_MAXinStdio.cpp, whichreadv/writevenforce._SC_OPEN_MAXis not a constant in FreeBSD:sysconfreturnsgetrlimit(RLIMIT_NOFILE).rlim_cur, and the only fixed value there isOPEN_MAX64. AnyPS5's guestgetrlimit(RLIMIT_NOFILE)already reports a limit (8192 on Windows, the host limit on Linux), so with this PR the two disagree in the same process. With a temporary probe inguest_system_configurationon this machine:A guest that sizes a descriptor table from
sysconf(_SC_OPEN_MAX)gets a smaller bound than the limit it can actually reach. Returning the guestgetrlimitsoft limit, as the closed #6506 did, would keep them consistent.Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by ErenYeager1836 on 2026-10-16T17:49:01Z.
Good catch and explanation, thank you @jotitadev! Updated _SC_OPEN_MAX to return the RLIMIT_NOFILE soft limit via getrlimit_nid_postfix (matching FreeBSD libc sysconf.c) and updated the test assertion and debt documentation accordingly.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T11:38:52Z.
Checked the three values against FreeBSD
sysconf.c/syslimits.h(_SC_OPEN_MAXviagetrlimit(RLIMIT_NOFILE),NCARGS,UIO_MAXIOV), the sysconf numbers, the debt entry, and that the new assertions fail on main (confirmed on Linux by @jotitadev); merged.