Skip to content

feat(libkernel_sys): implement fstatat - #7563

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel_sys-fstatat
Oct 20, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel_sys-fstatat

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

What

Implements fstatat (t6haf4s-eE0) in libkernel_sys, next to openat, mkdirat, fchmodat and unlinkat, and following them:

  • AT_FDCWD (-100) and absolute paths go to stat, or to lstat with AT_SYMLINK_NOFOLLOW (0x200).
  • Any other relative path is joined to the descriptor's host directory through a new libkernel helper, StatInDirectory_nid_no_patch, the same way OpenInDirectory_nid_no_patch does for openat. It returns EBADF for a descriptor that is not open and ENOTDIR for one that is not a directory. Following links, it uses sceKernelStat's native-path code, moved into StatNative unchanged, so a trailing / on a non-directory gives ENOTDIR as in stat. Without following, it uses File::FillLinkStat like lstat.
  • Flags other than AT_SYMLINK_NOFOLLOW return EINVAL; a null path EFAULT; an empty one ENOENT.

The technical debt entry follows the other *at functions (no guest path aliases or case-insensitive matching below a descriptor, .. not kept inside the guest root).

Tested

On 15649b7 (rebased onto main a373e85 after #6411 merged), 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. The new cases cover a file and a directory below a descriptor, a trailing /, AT_SYMLINK_NOFOLLOW, AT_FDCWD, an absolute guest path, ENOENT, EFAULT, EINVAL, EBADF and ENOTDIR for a file descriptor, plus a symbolic link followed and not followed (not on Windows, like the existing fchmodat link cases).
  • No new warnings in the files this PR touches on either OS.

Stremio Plus (PPSA74126, catalog release 0.5.11) stops on main with symbol lookup error: ... undefined symbol: t6haf4s-eE0 (fstatat); nothing open provides it (checked all 851 open PR diffs). With this PR:

  • Linux (headless): it gets past fstatat, starts its threads and stops at the headless DisplayWindow Vulkan check, like the other UI titles in a headless run.
  • Windows 11, 60 s, on main 5bf2e13 it fails to load (unresolved ELF import t6haf4s-eE0 (fstatat) from libkernel_sys.prx, exit 0xC0000139, no window). With this PR it runs the full 60 s at 59.94 fps with no UCRT reports and draws its "Link your account" page (QR code, link code, countdown and the "Request a new link" button). Rechecked on the rebased head: 59.93 FPS, same page; Morrowind (PPSA99630) still reaches its own Archive 'Morrowind.bsa' not found exit through feat(libkernel_sys): implement fchown #6411's fchown.

The stat consumers (ctest -R "filesystem|fstat|timestamp|app_archive|kernel_sys|stat", 39 tests on the rebased head) also pass 5/5 on both after sceKernelStat moved to StatNative, as they do on main.

check_conventions.py 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. feat(libkernel_sys): implement fchown #6411 (fchown) merged first; this is rebased onto it, keeping both functions and both test blocks in libkernel_sys/Export.cpp and GuestKernelSys.cpp.
  • Unblocks: PPSA74126
  • AI-assisted: yes

@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Progress report (c22eb87 → 15649b7)

➖ System libraries: 91.56% (+0.0%, +1 implemented functions)

✅ 1 implemented
Library Name
libkernel_sys fstatat_nid_postfix

@github-actions

github-actions Bot commented Oct 18, 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
PR 8457 core/libs/tests/GuestKernelSys.cpp L632-637

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/File/src/Open.cpp
core/libs/prx/libkernel_sys/Export.cpp
PR 6044 core/libs/tests/GuestKernelSys.cpp
PR 6936 core/libs/prx/libkernel/File/src/Open.cpp
PR 7201 core/libs/prx/libkernel/File/src/Open.cpp
core/libs/prx/libkernel_sys/Export.cpp

@LeandroLP23

Copy link
Copy Markdown
Contributor

Windows run. Radeon 860M (RDNA 3.5, driver 32.0.13058.8001), Windows 11 26300, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. Build: main c3591adf9 with #7623, #7612, #7611, #7603, #7579, #7563 and #7541 merged together (each merge clean, built once).

The build is clean and guest_kernel_sys passes 3 runs of 3.

AI-assisted

@babyhuey
babyhuey force-pushed the feat/libkernel_sys-fstatat branch from f4ea3ea to 15649b7 Compare October 19, 2026 01:27
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 19, 2026
@adriadam10 adriadam10 self-assigned this Oct 19, 2026
@adriadam10
adriadam10 merged commit 5f7aa55 into boykopovar:main Oct 20, 2026
11 of 12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Rechecked against current main: the StatNative refactor keeps the NotFoundError_nid_no_patch and Windows ELOOP changes, the error paths match openat/unlinkat/readlinkat, and the tests and technical debt entry are in order; merged.

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

Labels

docs libkernel prx unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants