feat(libkernel_sys): implement POSIX file operations #12687

Closed
xdCloudy wants to merge 1 commit from upstream-pr/12687 into main
xdCloudy commented 2026-10-29 02:18:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xdCloudy on 2026-10-29T02:18:16Z.


What

Implement the pwrite, futimesat and symlinkat exports in libkernel_sys. pwrite forwards to libkernel's existing positioned-write implementation. futimesat resolves paths with the supplied directory descriptor and uses libkernel's native timestamp implementation. symlinkat shares the existing symlink implementation and path resolution.

Firmware 13.60 evidence: pwrite at libkernel_sys VA 0x13630 passes the four POSIX arguments to syscall 476. FreeBSD 11.4 syscall definitions support the futimesat and symlinkat prototypes. The current symlink limitations remain: absolute targets and targets containing .. throw as unimplemented. Directory-relative host paths also do not model guest aliases or constrain .. to the guest root. Console results remain unverified; details are recorded in docs/dev/debt/libkernel_sys.md.

Tested

Windows with WinLibs GCC 15.2: configured the full project, built guest_kernel_sys_tests, and passed ctest --test-dir build-win -R '^guest_kernel_sys$' --output-on-failure. The test covers all three exports and error cases.

python3 tools/check_conventions.py --base origin/main passed. python3 tools/pr_overlap.py --branch feat/libkernel-sys-posix-file-ops scanned 1,410 open PRs and found no overlap. Linux was not tested.

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5060950467 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/12687). Originally posted by [xdCloudy](https://github.com/xdCloudy) on 2026-10-29T02:18:16Z. --- ### What Implement the `pwrite`, `futimesat` and `symlinkat` exports in `libkernel_sys`. `pwrite` forwards to libkernel's existing positioned-write implementation. `futimesat` resolves paths with the supplied directory descriptor and uses libkernel's native timestamp implementation. `symlinkat` shares the existing `symlink` implementation and path resolution. Firmware 13.60 evidence: `pwrite` at `libkernel_sys` VA `0x13630` passes the four POSIX arguments to syscall 476. FreeBSD 11.4 syscall definitions support the `futimesat` and `symlinkat` prototypes. The current `symlink` limitations remain: absolute targets and targets containing `..` throw as unimplemented. Directory-relative host paths also do not model guest aliases or constrain `..` to the guest root. Console results remain unverified; details are recorded in `docs/dev/debt/libkernel_sys.md`. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Windows with WinLibs GCC 15.2: configured the full project, built `guest_kernel_sys_tests`, and passed `ctest --test-dir build-win -R '^guest_kernel_sys$' --output-on-failure`. The test covers all three exports and error cases. `python3 tools/check_conventions.py --base origin/main` passed. `python3 tools/pr_overlap.py --branch feat/libkernel-sys-posix-file-ops` scanned 1,410 open PRs and found no overlap. Linux was not tested. ### 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] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes

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