Skip to content

feat(libkernel): implement lstat - #1624

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-lstat
Oct 9, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
babyhuey:feat/libkernel-lstat

Conversation

@babyhuey

@babyhuey babyhuey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

What

Implements lstat (DRGXpDDh8Ng) in libkernel. Part of #1578: PPSA99039 (EVO-PLAYER-PS5) imports it.

  • Paths go through PathError and ResolvePath_nid_no_patch like stat; a null sb fails with EFAULT.
  • Linux uses host lstat, so a symbolic link reports S_IFLNK and its own size, and a dangling link succeeds. Errors map through SceErrorFromErrno, so ENOENT and ENOTDIR reach the guest instead of the single ENOENT sceKernelStat returns.
  • Windows has no CRT lstat. Anything that is not a symbolic link is identical to stat; a symbolic link calls NotImplemented_nid_no_patch.
  • File::FillLinkStat sits next to FillFileStat in NativeStat.cpp.

Tested

Linux (Ubuntu 24.04, GCC 13, Release): guest_filesystem passes with --repeat until-fail:3. It now checks lstat on a file, a directory, a missing path, an empty path, null arguments, and (Linux only) a link, a dangling link and a path through a file (ENOTDIR). The test fails when host lstat is replaced by stat. check_conventions.py passes. Windows: the changed files compile with MinGW-w64 GCC 13 (-Wall -Wextra -fsyntax-only); not run on Windows. No title run.

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

@klosixgaming-arch klosixgaming-arch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Clean implementation of lstat following FreeBSD semantics with proper platform-specific handling - host lstat on Linux for correct symlink behavior, and NotImplemented_nid_no_patch for Windows symbolic links (since Windows has no CRT lstat). The test coverage is excellent - testing regular files, directories, missing/empty/null arguments, and on Linux specifically validating symlink vs stat differences (S_IFLNK mode bits, dangling symlinks succeeding with lstat but failing with stat, path-through-file ENOTDIR errors). Good addition to support EVO-PLAYER-PS5's import requirements.

@SleglJan SleglJan mentioned this pull request Oct 8, 2026
9 tasks done
@babyhuey

babyhuey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Fork CI while the upstream run waits for approval: Build run, all jobs green on 4b9eb4e (Linux 466/466, Windows 457/457, relinker on Linux, macOS and Windows). It builds the branch head, not the merge with main.

@MarcZX10

MarcZX10 commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

The overlap bot correctly found that #1795 also adds lstat_nid_postfix and the NativeStat path. The implementations are not equivalent: #1624 has Linux symlink/dangling-link coverage and explicitly rejects Windows symlink semantics as unimplemented, while #1795 currently falls back to stat on Windows. Since #1795’s lstat is separate from its socketpair change, please coordinate so only one reviewed lstat implementation remains; the socketpair change can proceed independently. This head is now 104 commits behind current main 0447793, so CONTRIBUTING requires a rebase and fresh checks before final review.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Progress report (54f28f2 → 903f50a)

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

✅ 1 implemented
Library Name
libkernel lstat_nid_postfix

@babyhuey
babyhuey force-pushed the feat/libkernel-lstat branch from 4b9eb4e to 81204de Compare October 8, 2026 21:19
@babyhuey

babyhuey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto main (81204de); guest_filesystem passes locally and fork CI is running on the new head. Agreed on keeping one lstat, thanks for raising it on #1795.

@MarcZX10

MarcZX10 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

The linked fork CI run 37845996551 completed successfully for head 81204de9 (Linux, Windows and all relinker jobs). This is useful evidence, but does not populate upstream PR checks. Current main is now 94b1eecb; this branch is 7 commits behind (merge base 364a56b). Please rebase before merge and refresh checks on the final head.

@babyhuey

babyhuey commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Titles that stop on lstat on current main. Linux, Ubuntu 24.04 container, GCC 13, Release, main d64134f (relinker and libs); titles from the homebrew catalog, relinked for Linux and run from the title folder.

Title main with this branch
PPSA68091 Ruffle Flash 1.2.0 app.elf: symbol lookup error: app.elf: undefined symbol: DRGXpDDh8Ng (lstat) next stop IuxnUuXk6Bg
PPSA99000 ProsperoStore 1.000.040 app.elf: symbol lookup error: app.elf: undefined symbol: DRGXpDDh8Ng (lstat) next stop +F7C-hdk7+E (sigemptyset)

The "with this branch" build also had my other open PRs merged; only this branch exports DRGXpDDh8Ng.

@babyhuey

babyhuey commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Same two titles on Windows. Windows 11, RTX 3080, WinLibs GCC 15.2.0 r7, Release, main f145139 (relinker and libs); titles relinked with --windows.

Title main with this branch
PPSA68091 Ruffle Flash 1.2.0 FAIL: unresolved ELF import DRGXpDDh8Ng from libkernel.prx (lstat) FAIL: unresolved ELF import IuxnUuXk6Bg from libkernel.prx
PPSA99000 ProsperoStore 1.000.040 FAIL: unresolved ELF import DRGXpDDh8Ng from libkernel.prx (lstat) FAIL: unresolved ELF import +F7C-hdk7+E from libkernel.prx (sigemptyset)

As on Linux, the second build also had my other open PRs merged; only this branch exports DRGXpDDh8Ng.

@popcoder565

popcoder565 commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

First Windows run, since the description says it was only compiled with MinGW. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. #1624, #1628, #1633 and #1634 merged together onto main b7218b3.

guest_filesystem passes, including this PR's lstat cases for a file, a directory, a missing name, an empty name and null pointers. The symlink cases are #ifndef _WIN32, so they didn't run here.

🤖 Addressed by Claude Code

@babyhuey
babyhuey force-pushed the feat/libkernel-lstat branch from 02918a3 to 903f50a Compare October 9, 2026 21:30
@adriadam10

Copy link
Copy Markdown
Collaborator

Checked on Linux (merged onto current main): build and guest_filesystem pass, and the test no longer links without the change. Error mapping (ENOENT/ENOTDIR/EFAULT), the link/dangling-link cases and the Windows throw on symlinks look right, and the third-party Windows and title runs in the thread agree. Merging.

@adriadam10
adriadam10 merged commit 72cf6c3 into boykopovar:main Oct 9, 2026
6 checks passed
@Amirtheshwaran Amirtheshwaran mentioned this pull request Oct 10, 2026
6 tasks done
@SleglJan SleglJan mentioned this pull request Oct 10, 2026
9 tasks done
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.

5 participants