feat(libkernel_sys): implement fchown #6411

Merged
Nixitov merged 1 commit from upstream-pr/6411 into main 2026-10-18 23:56:49 +00:00
Nixitov commented 2026-10-15 14:15:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Nixitov on 2026-10-15T14:15:56Z.


What

Implement fchown in libkernel_sys. Morrowind (mshivam019/morrowind-ps5) and Morrowind / OpenMW (PPSA99630) stop at it on current main:

FAIL: unresolved ELF import ruyD9QkP8dI from libkernel_sys.prx

(#5562 was the same change, closed for naming no title. It cannot be reopened ΓÇö GitHub reported that the branch "was force-pushed or recreated" while the PR was closed ΓÇö so this is re-filed with the title evidence.)

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.
  • Independently verified by @nicolasfalesy on Linux (Intel Arc, Mesa ANV): on main 5d9dcc42d the title stops at load with ./app.elf: symbol lookup error: ./app.elf: undefined symbol: ruyD9QkP8dI (fchown, libkernel_sys); with this PR Morrowind / OpenMW (PPSA99630, from the homebrew catalog) loads and runs to OpenMW's own check, Fatal error: Archive 'Morrowind.bsa' not found, and exits with status 0.
  • 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:4874706158 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6411). Originally posted by [Nixitov](https://github.com/Nixitov) on 2026-10-15T14:15:56Z. --- ### What Implement `fchown` in libkernel_sys. Morrowind (`mshivam019/morrowind-ps5`) and Morrowind / OpenMW (`PPSA99630`) stop at it on current `main`: ``` FAIL: unresolved ELF import ruyD9QkP8dI from libkernel_sys.prx ``` (#5562 was the same change, closed for naming no title. It cannot be reopened ΓÇö GitHub reported that the branch "was force-pushed or recreated" while the PR was closed ΓÇö so this is re-filed with the title evidence.) 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. - Independently verified by @nicolasfalesy on Linux (Intel Arc, Mesa ANV): on `main` `5d9dcc42d` the title stops at load with `./app.elf: symbol lookup error: ./app.elf: undefined symbol: ruyD9QkP8dI` (`fchown`, libkernel_sys); with this PR Morrowind / OpenMW (`PPSA99630`, from the homebrew catalog) loads and runs to OpenMW's own check, `Fatal error: Archive 'Morrowind.bsa' not found`, and exits with status 0. - `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-15 14:16:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:16:43Z.


Progress report (940eba9 → 443df05)

📉 System libraries: 88.69% (-0.03%, +1 declared functions)

🆕 1 declared as stubs
Library Name
libkernel_sys fchown_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194244055 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6411#issuecomment-6194244055). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T14:16:43Z. --- <!-- progress-report --> ### Progress report (940eba9 → 443df05) 📉 **System libraries**: 88.69% (-0.03%, +1 declared functions) <details> <summary>🆕 1 declared as stubs</summary> | Library | Name | | - | - | | libkernel_sys | `fchown_nid_postfix` | </details>
github-actions[bot] commented 2026-10-15 14:33:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T14:33:58Z.


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 7563 core/libs/prx/libkernel_sys/Export.cpp L511
core/libs/tests/GuestKernelSys.cpp L55, L567-568

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 core/libs/prx/libkernel_sys/Export.cpp
PR 6044 core/libs/tests/GuestKernelSys.cpp
PR 6447 core/libs/prx/libkernel_sys/Export.cpp
PR 7039 core/libs/tests/GuestKernelSys.cpp
PR 7201 core/libs/prx/libkernel_sys/Export.cpp
PR 7332 core/libs/prx/libkernel_sys/Export.cpp
core/libs/tests/GuestKernelSys.cpp
docs/dev/debt/libkernel_sys.md
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6194615965 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6411#issuecomment-6194615965). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T14:33:58Z. --- <!-- 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 7563](https://www.github.com/boykopovar/AnyPS5/pull/7563) | `core/libs/prx/libkernel_sys/Export.cpp` [L511](https://github.com/boykopovar/AnyPS5/blob/8b8edc56195f2ff6ec8e1a87b2463dc408580c54/core/libs/prx/libkernel_sys/Export.cpp#L511)<br>`core/libs/tests/GuestKernelSys.cpp` [L55](https://github.com/boykopovar/AnyPS5/blob/8b8edc56195f2ff6ec8e1a87b2463dc408580c54/core/libs/tests/GuestKernelSys.cpp#L55), [L567-568](https://github.com/boykopovar/AnyPS5/blob/8b8edc56195f2ff6ec8e1a87b2463dc408580c54/core/libs/tests/GuestKernelSys.cpp#L567-L568) | | | 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) | `core/libs/prx/libkernel_sys/Export.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/tests/GuestKernelSys.cpp` | | [PR 6447](https://www.github.com/boykopovar/AnyPS5/pull/6447) | `core/libs/prx/libkernel_sys/Export.cpp` | | [PR 7039](https://www.github.com/boykopovar/AnyPS5/pull/7039) | `core/libs/tests/GuestKernelSys.cpp` | | [PR 7201](https://www.github.com/boykopovar/AnyPS5/pull/7201) | `core/libs/prx/libkernel_sys/Export.cpp` | | [PR 7332](https://www.github.com/boykopovar/AnyPS5/pull/7332) | `core/libs/prx/libkernel_sys/Export.cpp`<br>`core/libs/tests/GuestKernelSys.cpp`<br>`docs/dev/debt/libkernel_sys.md` |
nicolasfalesy commented 2026-10-16 02:40:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nicolasfalesy on 2026-10-16T02:40:45Z.


A title that reaches this: Morrowind / OpenMW (PPSA99630) from the homebrew catalog, on Linux (Intel Arc, Mesa ANV).

  • main 5d9dcc42d: stops at load with ./app.elf: symbol lookup error: ./app.elf: undefined symbol: ruyD9QkP8dI (fchown, libkernel_sys).
  • main 5d9dcc42d + this PR: it loads and runs to OpenMW's own check, Fatal error: Archive 'Morrowind.bsa' not found, then [ps5-opengl-native] gate completed status=1 and exits with status 0 (no game data was installed for the test).

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6206823430 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6411#issuecomment-6206823430). Originally posted by [nicolasfalesy](https://github.com/nicolasfalesy) on 2026-10-16T02:40:45Z. --- A title that reaches this: **Morrowind / OpenMW (PPSA99630)** from the homebrew catalog, on Linux (Intel Arc, Mesa ANV). - `main` 5d9dcc42d: stops at load with `./app.elf: symbol lookup error: ./app.elf: undefined symbol: ruyD9QkP8dI` (`fchown`, libkernel_sys). - `main` 5d9dcc42d + this PR: it loads and runs to OpenMW's own check, `Fatal error: Archive 'Morrowind.bsa' not found`, then `[ps5-opengl-native] gate completed status=1` and exits with status 0 (no game data was installed for the test). AI-assisted: yes
babyhuey commented 2026-10-18 15:41:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-18T15:41:45Z.


Windows run of head 443df0551, merged onto main e5f18ea99 (clean merge). Windows 11, RTX 3080, WinLibs GCC 15.2, Release:

  • guest_kernel_sys passes 5/5 (--repeat until-fail:5); no warnings in libkernel_sys/Export.cpp or GuestKernelSys.cpp.
  • Morrowind / OpenMW (PPSA99630, catalog v1.0.1), 2 runs of 60 s each:
    • main: fails to load with an unresolved ruyD9QkP8dI (fchown) from libkernel_sys, its only missing import (0xC0000139, no window).
    • With this PR: it loads and reaches engine init. Its own log shows OpenMW PS5: entering engine, PS5 on-screen keyboard ready, OpenGL Renderer: PS5 AGC / 4.6 (Compatibility Profile) Mesa 26.2.0 and Using reverse-z depth buffer. It then exits 0 after about 1 s with [E] Fatal error: Archive 'Morrowind.bsa' not found, which is the expected stop without user-supplied game data. No UCRT or FATAL reports.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251819613 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6411#issuecomment-6251819613). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-18T15:41:45Z. --- Windows run of head `443df0551`, merged onto `main` `e5f18ea99` (clean merge). Windows 11, RTX 3080, WinLibs GCC 15.2, Release: - `guest_kernel_sys` passes 5/5 (`--repeat until-fail:5`); no warnings in `libkernel_sys/Export.cpp` or `GuestKernelSys.cpp`. - Morrowind / OpenMW (PPSA99630, catalog v1.0.1), 2 runs of 60 s each: - `main`: fails to load with an unresolved `ruyD9QkP8dI` (`fchown`) from libkernel_sys, its only missing import (`0xC0000139`, no window). - With this PR: it loads and reaches engine init. Its own log shows `OpenMW PS5: entering engine`, `PS5 on-screen keyboard ready`, `OpenGL Renderer: PS5 AGC / 4.6 (Compatibility Profile) Mesa 26.2.0` and `Using reverse-z depth buffer`. It then exits 0 after about 1 s with `[E] Fatal error: Archive 'Morrowind.bsa' not found`, which is the expected stop without user-supplied game data. No UCRT or FATAL reports. AI-assisted: yes
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!6411
No description provided.