feat(libkernel): support _SC_ARG_MAX, _SC_OPEN_MAX and _SC_IOV_MAX in sysconf #6833

Merged
ErenYeager1836 merged 2 commits from upstream-pr/6833 into main 2026-10-19 11:37:45 +00:00
ErenYeager1836 commented 2026-10-16 13:45:16 +00:00 (Migrated from github.com)

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): returns 262144 (FreeBSD NCARGS, maximum length of arguments and environment).
  • _SC_OPEN_MAX (5): returns 1024 (FreeBSD per-process maximum open file descriptors limit).
  • _SC_IOV_MAX (56): returns 1024 (FreeBSD UIO_MAXIOV, maximum iovec structures for readv/writev).

Updated docs/dev/debt/libkernel.md with descriptions of the new supported queries, and added test assertions verifying the returned values in GuestSystemConfiguration.cpp.

Tested

Windows 11, unit test suite (guest_system_configuration_tests). Verified sysconf_nid_postfix returns 262144 for _SC_ARG_MAX, 1024 for _SC_OPEN_MAX, 1024 for _SC_IOV_MAX, and preserves EINVAL for unsupported identifiers.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4889276722 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6833). Originally posted by [ErenYeager1836](https://github.com/ErenYeager1836) on 2026-10-16T13:45:16Z. --- ### What Support standard FreeBSD system configuration limit queries in `sysconf` (`libkernel`): - `_SC_ARG_MAX` (`1`): returns `262144` (FreeBSD `NCARGS`, maximum length of arguments and environment). - `_SC_OPEN_MAX` (`5`): returns `1024` (FreeBSD per-process maximum open file descriptors limit). - `_SC_IOV_MAX` (`56`): returns `1024` (FreeBSD `UIO_MAXIOV`, maximum `iovec` structures for `readv`/`writev`). Updated `docs/dev/debt/libkernel.md` with descriptions of the new supported queries, and added test assertions verifying the returned values in `GuestSystemConfiguration.cpp`. ### Tested Windows 11, unit test suite (`guest_system_configuration_tests`). Verified `sysconf_nid_postfix` returns `262144` for `_SC_ARG_MAX`, `1024` for `_SC_OPEN_MAX`, `1024` for `_SC_IOV_MAX`, and preserves `EINVAL` for unsupported identifiers. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-16 14:39:42 +00:00 (Migrated from github.com)

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.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 7541 docs/dev/debt/libkernel.md L19-21
PR 7542 docs/dev/debt/libkernel.md L18-19
PR 7554 docs/dev/debt/libkernel.md L18-19

Some 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.

Pull request Shared files not compared
PR 5021 docs/dev/debt/libkernel.md
PR 6044 core/libs/tests/GuestSystemConfiguration.cpp
PR 6149 docs/dev/debt/libkernel.md
PR 6446 docs/dev/debt/libkernel.md
PR 6469 docs/dev/debt/libkernel.md
PR 6519 docs/dev/debt/libkernel.md
PR 6740 docs/dev/debt/libkernel.md
PR 6836 docs/dev/debt/libkernel.md
PR 6936 docs/dev/debt/libkernel.md
PR 6977 docs/dev/debt/libkernel.md
PR 7039 docs/dev/debt/libkernel.md
PR 7049 docs/dev/debt/libkernel.md
PR 7075 docs/dev/debt/libkernel.md
PR 7088 docs/dev/debt/libkernel.md
PR 7105 docs/dev/debt/libkernel.md
PR 7121 docs/dev/debt/libkernel.md
PR 7129 docs/dev/debt/libkernel.md
PR 7149 docs/dev/debt/libkernel.md
PR 7192 docs/dev/debt/libkernel.md
PR 7299 docs/dev/debt/libkernel.md
PR 7332 docs/dev/debt/libkernel.md
PR 7509 docs/dev/debt/libkernel.md
PR 7543 docs/dev/debt/libkernel.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6217900012 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6833#issuecomment-6217900012). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-16T14:39:42Z. --- <!-- pr-overlap --> 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**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | [PR 7541](https://www.github.com/boykopovar/AnyPS5/pull/7541) | `docs/dev/debt/libkernel.md` [L19-21](https://github.com/boykopovar/AnyPS5/blob/97d5d7a52aedb162c17ff48c13553af25a9d7ba1/docs/dev/debt/libkernel.md#L19-L21) | | | | [PR 7542](https://www.github.com/boykopovar/AnyPS5/pull/7542) | `docs/dev/debt/libkernel.md` [L18-19](https://github.com/boykopovar/AnyPS5/blob/97d5d7a52aedb162c17ff48c13553af25a9d7ba1/docs/dev/debt/libkernel.md#L18-L19) | | | | [PR 7554](https://www.github.com/boykopovar/AnyPS5/pull/7554) | `docs/dev/debt/libkernel.md` [L18-19](https://github.com/boykopovar/AnyPS5/blob/97d5d7a52aedb162c17ff48c13553af25a9d7ba1/docs/dev/debt/libkernel.md#L18-L19) | | | Some 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. | Pull request | Shared files not compared | |---|---| | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `docs/dev/debt/libkernel.md` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestSystemConfiguration.cpp` | | [PR 6149](https://www.github.com/boykopovar/AnyPS5/pull/6149) | `docs/dev/debt/libkernel.md` | | [PR 6446](https://www.github.com/boykopovar/AnyPS5/pull/6446) | `docs/dev/debt/libkernel.md` | | [PR 6469](https://www.github.com/boykopovar/AnyPS5/pull/6469) | `docs/dev/debt/libkernel.md` | | [PR 6519](https://www.github.com/boykopovar/AnyPS5/pull/6519) | `docs/dev/debt/libkernel.md` | | [PR 6740](https://www.github.com/boykopovar/AnyPS5/pull/6740) | `docs/dev/debt/libkernel.md` | | [PR 6836](https://www.github.com/boykopovar/AnyPS5/pull/6836) | `docs/dev/debt/libkernel.md` | | [PR 6936](https://www.github.com/boykopovar/AnyPS5/pull/6936) | `docs/dev/debt/libkernel.md` | | [PR 6977](https://www.github.com/boykopovar/AnyPS5/pull/6977) | `docs/dev/debt/libkernel.md` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `docs/dev/debt/libkernel.md` | | [PR 7049](https://www.github.com/boykopovar/AnyPS5/pull/7049) | `docs/dev/debt/libkernel.md` | | [PR 7075](https://www.github.com/boykopovar/AnyPS5/pull/7075) | `docs/dev/debt/libkernel.md` | | [PR 7088](https://www.github.com/boykopovar/AnyPS5/pull/7088) | `docs/dev/debt/libkernel.md` | | [PR 7105](https://www.github.com/boykopovar/AnyPS5/pull/7105) | `docs/dev/debt/libkernel.md` | | [PR 7121](https://www.github.com/boykopovar/AnyPS5/pull/7121) | `docs/dev/debt/libkernel.md` | | [PR 7129](https://www.github.com/boykopovar/AnyPS5/pull/7129) | `docs/dev/debt/libkernel.md` | | [PR 7149](https://www.github.com/boykopovar/AnyPS5/pull/7149) | `docs/dev/debt/libkernel.md` | | [PR 7192](https://www.github.com/boykopovar/AnyPS5/pull/7192) | `docs/dev/debt/libkernel.md` | | [PR 7299](https://www.github.com/boykopovar/AnyPS5/pull/7299) | `docs/dev/debt/libkernel.md` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `docs/dev/debt/libkernel.md` | | [PR 7509](https://www.github.com/boykopovar/AnyPS5/pull/7509) | `docs/dev/debt/libkernel.md` | | [PR 7543](https://www.github.com/boykopovar/AnyPS5/pull/7543) | `docs/dev/debt/libkernel.md` |
jotitadev commented 2026-10-16 16:25:37 +00:00 (Migrated from github.com)

Imported 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.

  • Machine: Linux, i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release with BUILD_TESTING=ON.
  • Head 2e4f63b81 merged into main at 452494439.
  • guest_system_configuration passes. With only GuestSystemConfiguration.cpp from the PR on main, it aborts, so the new assertions catch the missing cases.
  • Non-GPU suite (-E "^agc|gpu|vulkan|video_out"): 648/650, same as main. The two failures are file_writer_binary/file_writer_text (uutils cp, fixed by #6877).

_SC_ARG_MAX 262144 and _SC_IOV_MAX 1024 match ARG_MAX and IOV_MAX in syslimits.h at the FreeBSD commit the debt file already cites, and IOV_MAX matches KERNEL_IOV_MAX in Stdio.cpp, which readv/writev enforce.

_SC_OPEN_MAX is not a constant in FreeBSD: sysconf returns getrlimit(RLIMIT_NOFILE).rlim_cur, and the only fixed value there is OPEN_MAX 64. AnyPS5's guest getrlimit(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 in guest_system_configuration on this machine:

getrlimit(RLIMIT_NOFILE) rc=0 cur=524288 max=524288
sysconf(_SC_OPEN_MAX)=1024

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 guest getrlimit soft 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.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5550659277 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6833#pullrequestreview-5550659277). Originally posted by [jotitadev](https://github.com/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`. - Machine: Linux, i7-8700, Ubuntu 26.04, GCC 15.2, CMake 4.2.3, Ninja, Release with `BUILD_TESTING=ON`. - Head 2e4f63b81 merged into `main` at 452494439. - `guest_system_configuration` passes. With only `GuestSystemConfiguration.cpp` from the PR on `main`, it aborts, so the new assertions catch the missing cases. - Non-GPU suite (`-E "^agc|gpu|vulkan|video_out"`): 648/650, same as `main`. The two failures are `file_writer_binary`/`file_writer_text` (uutils `cp`, fixed by #6877). `_SC_ARG_MAX` 262144 and `_SC_IOV_MAX` 1024 match `ARG_MAX` and `IOV_MAX` in [`syslimits.h`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/sys/sys/syslimits.h#L49-L65) at the FreeBSD commit the debt file already cites, and `IOV_MAX` matches `KERNEL_IOV_MAX` in `Stdio.cpp`, which `readv`/`writev` enforce. `_SC_OPEN_MAX` is not a constant in FreeBSD: [`sysconf`](https://github.com/freebsd/freebsd-src/blob/8c639945a44588f6cfdddfb057bb5aad88735da0/lib/libc/gen/sysconf.c#L106-L115) returns `getrlimit(RLIMIT_NOFILE).rlim_cur`, and the only fixed value there is `OPEN_MAX` 64. AnyPS5's guest `getrlimit(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 in `guest_system_configuration` on this machine: ``` getrlimit(RLIMIT_NOFILE) rc=0 cur=524288 max=524288 sysconf(_SC_OPEN_MAX)=1024 ``` 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 guest `getrlimit` soft 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.
ErenYeager1836 commented 2026-10-16 17:49:01 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221395769 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6833#issuecomment-6221395769). Originally posted by [ErenYeager1836](https://github.com/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.
adriadam10 commented 2026-10-19 11:38:52 +00:00 (Migrated from github.com)

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_MAX via getrlimit(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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6266325570 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6833#issuecomment-6266325570). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-19T11:38:52Z. --- Checked the three values against FreeBSD `sysconf.c` / `syslimits.h` (`_SC_OPEN_MAX` via `getrlimit(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.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!6833
No description provided.