Skip to content

feat(libkernel_sys): implement openat - #3968

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel_sys-openat
Oct 12, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel_sys-openat

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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 (feat(libkernel_sys): implement fchdir #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 12c2266 it stops at openat; tracked in #1578:

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 51e2c51, 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

@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Progress report (0694c57 → c154b8b)

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

✅ 1 implemented
Library Name
libkernel_sys openat_nid_postfix

@babyhuey
babyhuey force-pushed the feat/libkernel_sys-openat branch from 5bb1c0c to c154b8b Compare October 11, 2026 22:03
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 11, 2026
@github-actions

github-actions Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants