feat(libkernel_sys): implement fpathconf and _fpathconf #10060

Merged
xXPBSXx merged 4 commits from upstream-pr/10060 into main 2026-10-23 20:03:46 +00:00
xXPBSXx commented 2026-10-23 07:32:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-23T07:32:52Z.


What

Based on #6525 (QuentinRemond, head 8c2943089b, authorship kept); the original no longer compiles on main (GuestEbadf is defined twice since #6411) and libkernel_sys.prx would not load (DescriptorIsOpen_nid_no_patch is not exported by the patched libkernel.prx). Implements fpathconf and _fpathconf in libkernel_sys: a descriptor that is not open fails with EBADF; the values are the FreeBSD 11 UFS constants that pathconf already reports, now from one PathConfigurationValue helper; names that depend on the mount or the kernel throw; unknown names fail with EINVAL. The rebase drops the duplicate constant and keeps main's ENOTDIR handling in pathconf; the descriptor is checked with fstat as fchown does.

Fixes: none

Tested

Measured on main 9d6adeb550 plus these two commits (git merge-tree against the current main 0db47b263d is clean, the head is unchanged): Windows 10 19045, WinLibs GCC 15.2.0, Release: ctest -R '^(patched_libraries|guest_kernel_sys)$' passes 2 of 2. WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal), GCC 13.3.0, Release: passes 2 of 2. Before the descriptor fix (the earlier base ab347d144d, only the rebase of the original commit), patched_libraries failed on both: Windows libkernel_sys.prx: LoadLibraryEx failed with error 127 (359 patched libraries loaded, 1 failed), Linux libkernel_sys.prx: undefined symbol: _Z29DescriptorIsOpen_nid_no_patchi; guest_kernel_sys passed there, as it loads the unpatched PRXs. tools/check_conventions.py --base upstream/main: no error, one warning (the libkernel_sys.md debt entry is 1260 characters, from the original PR). Not tested: macOS, a title run.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

Co-authored by the original author of #6525.
AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4979426579 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10060). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-23T07:32:52Z. --- ### What Based on #6525 (QuentinRemond, head `8c2943089b`, authorship kept); the original no longer compiles on `main` (`GuestEbadf` is defined twice since #6411) and `libkernel_sys.prx` would not load (`DescriptorIsOpen_nid_no_patch` is not exported by the patched `libkernel.prx`). Implements `fpathconf` and `_fpathconf` in `libkernel_sys`: a descriptor that is not open fails with `EBADF`; the values are the FreeBSD 11 UFS constants that `pathconf` already reports, now from one `PathConfigurationValue` helper; names that depend on the mount or the kernel throw; unknown names fail with `EINVAL`. The rebase drops the duplicate constant and keeps `main`'s `ENOTDIR` handling in `pathconf`; the descriptor is checked with `fstat` as `fchown` does. Fixes: none ### Tested Measured on `main` `9d6adeb550` plus these two commits (`git merge-tree` against the current `main` `0db47b263d` is clean, the head is unchanged): Windows 10 19045, WinLibs GCC 15.2.0, Release: `ctest -R '^(patched_libraries|guest_kernel_sys)$'` passes 2 of 2. WSL2 Ubuntu 24.04 (virtualised kernel, not bare-metal), GCC 13.3.0, Release: passes 2 of 2. Before the descriptor fix (the earlier base `ab347d144d`, only the rebase of the original commit), `patched_libraries` failed on both: Windows `libkernel_sys.prx: LoadLibraryEx failed with error 127` (359 patched libraries loaded, 1 failed), Linux `libkernel_sys.prx: undefined symbol: _Z29DescriptorIsOpen_nid_no_patchi`; `guest_kernel_sys` passed there, as it loads the unpatched PRXs. `tools/check_conventions.py --base upstream/main`: no error, one warning (the `libkernel_sys.md` debt entry is 1260 characters, from the original PR). Not tested: macOS, a title run. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's technical 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes Co-authored by the original author of #6525. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-23 13:26:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:26:16Z.

Review: DISMISSED


Reviewed exact head fba61c0da01cf7fd4346cb94a6b3a9d86b68862c. The implementation addresses the two FreeBSD kern_fpathconf cases raised in the thread: _PC_ASYNC_IO returns 200112 after validating the descriptor, and FIFO descriptors return 512 for _PC_PIPE_BUF and EINVAL for other names. The added guest tests cover both exported aliases, file/directory descriptors, invalid descriptors, and both pipe ends. The author reports Windows and WSL2 focused patched_libraries and guest_kernel_sys runs passing 2/2; I did not independently reproduce those runs here because CMake configuration stops before generation: this checkout lacks the 3rdparty/SDL2 CMake project and the environment lacks XRandR development support. git diff --check and tools/check_conventions.py --base upstream/main pass locally. Hosted eligibility, conventions, labels, and report checks are green; platform build jobs are skipped by workflow policy.

A landing-order item remains: the exact-head three-way preview between #10060 and #10196 conflicts in core/libs/prx/libkernel_sys/Export.cpp and docs/dev/debt/libkernel_sys.md. #10196's body acknowledges the shared switch and says it will carry #10060's changes if #10060 lands first, but both checklists currently say Depends on: none, and I don't see an explicit agreement from both authors on the order. Please coordinate and record the agreed dependency/order in the PR body, while preserving both implementations and debt documentation whichever lands second. This is a sequencing request only; I am not asking either author to close their PR.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5628875125 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10060#pullrequestreview-5628875125). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-23T13:26:16Z. **Review:** DISMISSED --- Reviewed exact head `fba61c0da01cf7fd4346cb94a6b3a9d86b68862c`. The implementation addresses the two FreeBSD `kern_fpathconf` cases raised in the thread: `_PC_ASYNC_IO` returns 200112 after validating the descriptor, and FIFO descriptors return 512 for `_PC_PIPE_BUF` and `EINVAL` for other names. The added guest tests cover both exported aliases, file/directory descriptors, invalid descriptors, and both pipe ends. The author reports Windows and WSL2 focused `patched_libraries` and `guest_kernel_sys` runs passing 2/2; I did not independently reproduce those runs here because CMake configuration stops before generation: this checkout lacks the `3rdparty/SDL2` CMake project and the environment lacks XRandR development support. `git diff --check` and `tools/check_conventions.py --base upstream/main` pass locally. Hosted eligibility, conventions, labels, and report checks are green; platform build jobs are skipped by workflow policy. A landing-order item remains: the exact-head three-way preview between #10060 and #10196 conflicts in `core/libs/prx/libkernel_sys/Export.cpp` and `docs/dev/debt/libkernel_sys.md`. #10196's body acknowledges the shared switch and says it will carry #10060's changes if #10060 lands first, but both checklists currently say `Depends on: none`, and I don't see an explicit agreement from both authors on the order. Please coordinate and record the agreed dependency/order in the PR body, while preserving both implementations and debt documentation whichever lands second. This is a sequencing request only; I am not asking either author to close their PR.
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!10060
No description provided.