feat(libkernel_sys): implement openat #3968

Merged
babyhuey merged 1 commit from upstream-pr/3968 into main 2026-10-12 03:08:11 +00:00
babyhuey commented 2026-10-11 20:08:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by babyhuey on 2026-10-11T20:08:49Z.


What

Exports openat (A8Yk5AhNDck) from libkernel_sys, the module titles import it from.

  • AT_FDCWD (-100) and absolute paths go to open, so guest path aliases, case-insensitive matching and the guest root apply as before.
  • A relative path is opened inside the directory descriptor. The descriptor's host directory is looked up the same way fchdir does it (#3392): the recorded path on Windows, the /proc/self/fd link on Linux. It returns EBADF for a descriptor that is not open and ENOTDIR for one that is not a directory.
  • mode is read from the variadic arguments only with O_CREAT, as _open does, including the SysV va_list on Windows.
  • To share the open path, the part of sceKernelOpen after path resolution is moved into a static OpenNative with no change in behaviour. libkernel also gets a small OpenInDirectory_nid_no_patch helper.
  • The TechnicalDebt entry after fchdir lists the limits. A path relative to a descriptor does not go through aliases or case-insensitive matching, and a .. component is not kept inside the guest root. As in open, O_NOFOLLOW and O_NONBLOCK are ignored.

ProsperoTV (PPSA99003, catalog 01.000.060) opens a directory with O_DIRECTORY | O_NOFOLLOW, then openats entries in it with O_NONBLOCK | O_NOFOLLOW. On main 12c22662 it stops at openat; tracked in #1578:

  • Linux: app.elf: symbol lookup error: app.elf: undefined symbol: A8Yk5AhNDck (openat)
  • Windows: FAIL: unresolved ELF import A8Yk5AhNDck (openat) from libkernel_sys.prx
  • with this PR, both: it loads, opens the TV menu and then stops in poll after opening /dev/crypto (Linux: poll: descriptor 6 is not a socket; Windows: poll: descriptor 4 is not a socket). #3649 fixes that.
  • with this PR and #3649 (they merge cleanly): Linux reaches Vulkan device ready, then stops at the headless DisplayWindow. Windows renders, then stops at AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported (#3581). That is a graphics gap, not an import.

Tested

Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: guest_kernel_sys passes 5/5 (--repeat until-fail:5) on both. There are no new warnings in Open.cpp, libkernel_sys/Export.cpp or GuestKernelSys.cpp. The new cases cover:

  • reading a file through a directory descriptor
  • creating one with O_CREAT | O_EXCL and mode 0644, then EEXIST on a second try
  • ENOENT for a missing name
  • an absolute path with descriptor -1 (ignored)
  • AT_FDCWD with a relative path
  • ENOTDIR for a file descriptor, EBADF for -1
  • EFAULT for a null path and ENOENT for an empty one

With #3649 stacked, guest_poll also passes 5/5 on Windows. check_conventions.py passes. Rebased onto main 51e2c511, over #3485 (sceKernelOpen now resolves through ResolvePathError_nid_no_patch before OpenNative) and #3685 (libkernel_sys errno constants): guest_kernel_sys 5/5 on both and the same ProsperoTV results. Windows ran with #4021 stacked, since main does not build on Windows without it.

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 in TechnicalDebt
  • 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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4821975506 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3968). Originally posted by [babyhuey](https://github.com/babyhuey) on 2026-10-11T20:08:49Z. --- ### What Exports `openat` (`A8Yk5AhNDck`) from libkernel_sys, the module titles import it from. - `AT_FDCWD` (-100) and absolute paths go to `open`, so guest path aliases, case-insensitive matching and the guest root apply as before. - A relative path is opened inside the directory descriptor. The descriptor's host directory is looked up the same way `fchdir` does it (#3392): the recorded path on Windows, the `/proc/self/fd` link on Linux. It returns `EBADF` for a descriptor that is not open and `ENOTDIR` for one that is not a directory. - `mode` is read from the variadic arguments only with `O_CREAT`, as `_open` does, including the SysV `va_list` on Windows. - To share the open path, the part of `sceKernelOpen` after path resolution is moved into a static `OpenNative` with no change in behaviour. libkernel also gets a small `OpenInDirectory_nid_no_patch` helper. - The TechnicalDebt entry after `fchdir` lists the limits. A path relative to a descriptor does not go through aliases or case-insensitive matching, and a `..` component is not kept inside the guest root. As in `open`, `O_NOFOLLOW` and `O_NONBLOCK` are ignored. ProsperoTV (PPSA99003, catalog 01.000.060) opens a directory with `O_DIRECTORY | O_NOFOLLOW`, then `openat`s entries in it with `O_NONBLOCK | O_NOFOLLOW`. On `main` 12c22662 it stops at `openat`; tracked in #1578: - Linux: `app.elf: symbol lookup error: app.elf: undefined symbol: A8Yk5AhNDck (openat)` - Windows: `FAIL: unresolved ELF import A8Yk5AhNDck (openat) from libkernel_sys.prx` - with this PR, both: it loads, opens the TV menu and then stops in `poll` after opening `/dev/crypto` (Linux: `poll: descriptor 6 is not a socket`; Windows: `poll: descriptor 4 is not a socket`). #3649 fixes that. - with this PR and #3649 (they merge cleanly): Linux reaches `Vulkan device ready`, then stops at the headless `DisplayWindow`. Windows renders, then stops at `AGC graphics: last provoking vertex with explicit per-vertex flat interpolation is unsupported` (#3581). That is a graphics gap, not an import. ### Tested Linux (Ubuntu 24.04, GCC 13) and Windows 11 (MinGW-w64 GCC 15.2 from WinLibs), Release: `guest_kernel_sys` passes 5/5 (`--repeat until-fail:5`) on both. There are no new warnings in `Open.cpp`, `libkernel_sys/Export.cpp` or `GuestKernelSys.cpp`. The new cases cover: - reading a file through a directory descriptor - creating one with `O_CREAT | O_EXCL` and mode `0644`, then `EEXIST` on a second try - `ENOENT` for a missing name - an absolute path with descriptor -1 (ignored) - `AT_FDCWD` with a relative path - `ENOTDIR` for a file descriptor, `EBADF` for -1 - `EFAULT` for a null path and `ENOENT` for an empty one With #3649 stacked, `guest_poll` also passes 5/5 on Windows. `check_conventions.py` passes. Rebased onto `main` 51e2c511, over #3485 (`sceKernelOpen` now resolves through `ResolvePathError_nid_no_patch` before `OpenNative`) and #3685 (libkernel_sys errno constants): `guest_kernel_sys` 5/5 on both and the same ProsperoTV results. Windows ran with #4021 stacked, since `main` does not build on Windows without it. ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
github-actions[bot] commented 2026-10-11 20:09:08 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T20:09:08Z.


Progress report (0694c57 → c154b8b)

📈 System libraries: 85.72% (+0.01%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel_sys openat_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6113211794 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3968#issuecomment-6113211794). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T20:09:08Z. --- <!-- progress-report --> ### Progress report (0694c57 → c154b8b) 📈 **System libraries**: 85.72% (+0.01%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libkernel_sys | `openat_nid_postfix` | </details>
github-actions[bot] commented 2026-10-11 22:44:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T22:44:23Z.


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
#3840 core/libs/prx/libkernel/File/src/Open.cpp L188-199
#4253 core/libs/prx/libkernel_sys/Export.cpp L1
docs/dev/TechnicalDebt.md L391
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114733371 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3968#issuecomment-6114733371). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T22:44:23Z. --- <!-- 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 | |---|---|---|---| | #3840 | `core/libs/prx/libkernel/File/src/Open.cpp` [L188-199](https://github.com/boykopovar/AnyPS5/blob/34a16b7f087d923b5ce9069c8d2382d9ffecd421/core/libs/prx/libkernel/File/src/Open.cpp#L188-L199) | | | | #4253 | `core/libs/prx/libkernel_sys/Export.cpp` [L1](https://github.com/boykopovar/AnyPS5/blob/34a16b7f087d923b5ce9069c8d2382d9ffecd421/core/libs/prx/libkernel_sys/Export.cpp#L1)<br>`docs/dev/TechnicalDebt.md` [L391](https://github.com/boykopovar/AnyPS5/blob/34a16b7f087d923b5ce9069c8d2382d9ffecd421/docs/dev/TechnicalDebt.md#L391) | | |
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!3968
No description provided.