Skip to content

feat(libc): query filesystem statistics by guest path - #3658

Closed
Lorkydey wants to merge 3 commits into
boykopovar:mainfrom
Lorkydey:feat/libc-statvfs
Closed

Lorkydey wants to merge 3 commits into
boykopovar:mainfrom
Lorkydey:feat/libc-statvfs

Conversation

@Lorkydey

@Lorkydey Lorkydey commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Continued in #4653. The replacement is rebased onto current main and includes the new EmuStore/PS5SX2 evidence and Linux/Windows validation. GitHub refused reopening this PR after the rebase.


What

EmuStore (PPSA97631) stops on the missing path-based statvfs import from libSceLibcInternal:

FAIL: unresolved ELF import ayTeobcoGj8 (statvfs) from libSceLibcInternal.prx

Nixitov's Windows validation reports that this PR resolves the import and the title proceeds to sysctlbyname_nid_postfix: unsupported name kern.sdk_version. That later stop is outside this change.

Rebased onto main 2a5eca11cd1bf583db39ce67034e8453842ac244, which already contains #3596. This PR adds only statvfs; it reuses the merged fstatvfs implementation and leaves its ABI conversion and tests unchanged. The diff contains four files and adds one implemented library function. There is no remaining dependency on an open PR.

Resolve the guest path, open a temporary metadata descriptor, and pass it to fstatvfs. Windows uses a zero-access CreateFileW handle; Linux uses O_PATH | O_CLOEXEC. This supports directories, files without read permission, and FIFOs without opening their contents. The Linux backend accepts filesystem sockets opened with O_PATH; ordinary socket descriptors retain their existing rejection. Temporary descriptors close with errno preserved.

The rebase also adapts path resolution errors to the current helper: unavailable mounts return ENOENT, and file/../... returns ENOTDIR instead of letting a filesystem exception abort the program.

Additional title evidence: babyhuey's PS5SX2 (PPSA99203) report reaches the same missing import on Linux and Windows, using main d592d54e with #3804, #4466, #4382, #4530, #3787 and #4426 for that title's earlier stops. The title stack is recorded there as test/verify-sx3 at 49c7676e. These title observations are attributed to those testers; I have not rerun either title on the rebased head.

Tested

Head: c052b7c720501f0b49527194baf625d8a4a50152.

  • Windows 11 Pro 26100, WinLibs MinGW-w64 GCC 15.2.0 r7, Ninja, Release, BUILD_TESTING=ON: six targeted tests pass, repeated three times each: guest_statvfs, guest_fstatvfs, guest_fstatvfs_conversion, guest_fstatfs, guest_utime and guest_utime_forwarding.
  • The new path-error test aborts with the previous statvfs implementation on current main; it passes after using ResolvePathError_nid_no_patch.
  • Coverage includes aliased files/directories, Unicode, volume capacity, guest output bounds, preserved errno, invalid paths, unavailable mounts, null output, unchanged contents and handle counts; Windows also checks an exclusively opened file. Linux additionally checks a file without read permission, a FIFO without a reader, filesystem sockets and valid/dangling symlinks.
  • Linux and Windows validation: fork CI on this exact source commit. Both jobs pass: the six tests succeed three times each, and the pre-fix path-error regression is reproduced on both systems.
  • Full local Windows build and the libs target both succeed.
  • Conventions, test registration and git diff --check pass. The repository overlap checker found no overlap with the other open PRs at the time of this update; all-state searches found no other path-based statvfs implementation.

Checklist

  • Based on current main; no other open PR implements the same function
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs added
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: PPSA97631 and PPSA99203; title stop logs linked above in feat(libc): query filesystem statistics by guest path #3658
  • AI-assisted: yes (Codex)

@github-actions

Copy link
Copy Markdown

Progress report (a11c8f7 → 1fc82ce)

📈 System libraries: 85.82% (+0.01%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceLibcInternal fstatvfs_nid_postfix
libSceLibcInternal statvfs_nid_postfix

@blawesom

Copy link
Copy Markdown
Contributor

Independent pre-review on Linux (full CI runs only happen on manual trigger, so recording one): CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release, BUILD_TESTING=ON.

  • Builds; tools/check_conventions.py --base origin/main passes.
  • Full suite: 835/835 passed (all tests including the Vulkan suites on AMD RX 9070 XT / RADV).

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Has PS5MC (PPSA99420) been run on main? With the log line where it stops at statvfs this can go in; otherwise I'll close it until a title reaches it.

@Lorkydey

Copy link
Copy Markdown
Contributor Author

@oneandonlydean No, I haven’t run PS5MC on main. The evidence is a static import audit, as noted in the PR description

it doesn’t establish that execution reaches statvfs.
I don’t have the requested runtime log so I understand closing this until a title is confirmed to hit it.

@oneandonlydean

Copy link
Copy Markdown
Collaborator

Closing as agreed above; reopen when a title reaches statvfs.

@babyhuey

babyhuey commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

@Lorkydey @oneandonlydean a title now reaches statvfs at runtime: PS5SX2 (PPSA99203). It is a ps5-payload-dev SDK title, so it relinks only with --trap-sdk-syscall-stubs (#3804), and it needs these open PRs for its earlier imports: #4466, #4382 (setitimer), #4530, #3787 (JIT shared memory) and #4426. With those stacked on main d592d54, it stops at statvfs on both systems:

  • Linux (Ubuntu 24.04, GCC 13): app.elf: symbol lookup error: app.elf: undefined symbol: ayTeobcoGj8 (statvfs)
  • Windows 11 (WinLibs GCC 15.2): FAIL: unresolved ELF import ayTeobcoGj8 (statvfs) from libSceLibcInternal.prx

The stack is on my fork as test/verify-sx3 (49c7676) if you want to reproduce it.

@Nixitov

Nixitov commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Verified on Windows 11, MinGW-w64 GCC 15.2.0 (WinLibs r7), Release: the branch builds (patched libc.prx).

  • EmuStore (PPSA97631): on main it stops at FAIL: unresolved ELF import ayTeobcoGj8 (statvfs) from libSceLibcInternal.prx; with this change statvfs resolves and the title loads fully, then stops at run time on sysctlbyname_nid_postfix: unsupported name kern.sdk_version (a separate, already-open change).

Note: #3596 adds volume statistics through fstatvfs; please confirm the two don't overlap before merging both.

AI-assisted: yes

@Lorkydey

Copy link
Copy Markdown
Contributor Author

@babyhuey @Nixitov @oneandonlydean

Thanks for the title reports, ive opened #4653 as the updated replacement for this PR, since GitHub wouldn't let me reopen it after rebasing.
It now reuses the already-merged #3596 without duplicating it. Linux and Windows validation passes, and I've included your EmuStore and PS5SX2 reports in the description.

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