feat(libkernel_sys): implement fchown #5562

Closed
Nixitov wants to merge 1 commit from upstream-pr/5562 into main
Nixitov commented 2026-10-13 23:57:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-13T23:57:31Z.


What

Implement fchown in libkernel_sys. Morrowind (mshivam019/morrowind-ps5) stops at it on current main:

FAIL: unresolved ELF import ruyD9QkP8dI from libkernel_sys.prx

Ownership is not modelled: the guest's own owner and group (0) and the unchanged value (-1) are accepted, a descriptor that is not open fails with EBADF, and any other owner or group throws, naming it. The descriptor is read with fstat, ignoring the CRT's invalid-parameter handler on Windows the way DescriptorControl does. Recorded in docs/dev/debt/libkernel_sys.md.

Tested

Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release.

  • guest_kernel_sys is extended: fchown accepts (0, 0) and (-1, -1), fails an invalid descriptor with EBADF, and throws for owner 1 or group 1; it passes.
  • Morrowind (mshivam019/morrowind-ps5, v1.0.1 windows asset), eboot.bin unwrapped and relinked with the built relinker --windows: on current main it stops at ruyD9QkP8dI (fchown); with this change it resolves every start-up import and transfers control to the ELF entry point.
  • python tools/check_conventions.py --base origin/main passes.

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: Morrowind (mshivam019/morrowind-ps5)
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4850999586 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5562). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-13T23:57:31Z. --- ### What Implement `fchown` in libkernel_sys. Morrowind (`mshivam019/morrowind-ps5`) stops at it on current `main`: ``` FAIL: unresolved ELF import ruyD9QkP8dI from libkernel_sys.prx ``` Ownership is not modelled: the guest's own owner and group (0) and the unchanged value (-1) are accepted, a descriptor that is not open fails with `EBADF`, and any other owner or group throws, naming it. The descriptor is read with `fstat`, ignoring the CRT's invalid-parameter handler on Windows the way `DescriptorControl` does. Recorded in `docs/dev/debt/libkernel_sys.md`. ### Tested Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. - `guest_kernel_sys` is extended: `fchown` accepts `(0, 0)` and `(-1, -1)`, fails an invalid descriptor with `EBADF`, and throws for owner 1 or group 1; it passes. - Morrowind (`mshivam019/morrowind-ps5`, v1.0.1 windows asset), `eboot.bin` unwrapped and relinked with the built relinker `--windows`: on current `main` it stops at `ruyD9QkP8dI` (`fchown`); with this change it resolves every start-up import and transfers control to the ELF entry point. - `python tools/check_conventions.py --base origin/main` passes. ### 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](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: Morrowind (`mshivam019/morrowind-ps5`) - [x] GPUs tested: n/a - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-13 23:58:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-13T23:58:12Z.


Progress report (52d134c → 099b8fc)

📉 System libraries: 88.17% (-0.02%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel_sys fchown_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6157740213 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5562#issuecomment-6157740213). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-13T23:58:12Z. --- <!-- progress-report --> ### Progress report (52d134c → 099b8fc) 📉 **System libraries**: 88.17% (-0.02%, +1 declared functions) <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libkernel_sys | `fchown_nid_postfix` | </details>
oneandonlydean commented 2026-10-14 02:25:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:25:19Z.


Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6159500189 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5562#issuecomment-6159500189). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T02:25:19Z. --- Closing: no title is known to reach this. With the queue at 700+ open PRs, please hold off on new PRs that don't name a title needing the change until it's down. If a title stops on this on current main, reopen with the title ID and the log line.

Pull request closed

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!5562
No description provided.