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

Merged
Lorkydey merged 1 commit from upstream-pr/4653 into main 2026-10-12 21:08:17 +00:00
Lorkydey commented 2026-10-12 17:55:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-12T17:55:55Z.


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.

Replaces #3658, which was closed pending title evidence. GitHub refuses to reopen it after the branch was rebased; the new title reports above and below supply the missing evidence.

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 #3658
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4833119010 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4653). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-12T17:55:55Z. --- ### What EmuStore (PPSA97631) stops on the missing path-based `statvfs` import from `libSceLibcInternal`: ```text FAIL: unresolved ELF import ayTeobcoGj8 (statvfs) from libSceLibcInternal.prx ``` [Nixitov's Windows validation](https://github.com/boykopovar/AnyPS5/pull/3658#issuecomment-6128648351) 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. Replaces #3658, which was closed pending title evidence. GitHub refuses to reopen it after the branch was rebased; the new title reports above and below supply the missing evidence. 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](https://github.com/boykopovar/AnyPS5/pull/3658#issuecomment-6127388500) 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](https://github.com/Lorkydey/AnyPS5/actions/runs/38286746267). 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 - [x] Based on current `main`; no other open PR implements the same function - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs added - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: PPSA97631 and PPSA99203; title stop logs linked above in #3658 - [x] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-12 18:02:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-12T18:02:47Z.


Progress report (2a5eca1 → c052b7c)

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

✅ 1 implemented
Library Name
libSceLibcInternal statvfs_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6129793060 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4653#issuecomment-6129793060). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-12T18:02:47Z. --- <!-- progress-report --> ### Progress report (2a5eca1 → c052b7c) ➖ **System libraries**: 86.34% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceLibcInternal | `statvfs_nid_postfix` | </details>
xXPBSXx commented 2026-10-12 19:54:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-12T19:54:01Z.


Windows test: head c052b7c72 merged onto current main 1b92f7f5d (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest with the filter guest_statvfs: guest_statvfs passed (1 test(s), 0 failed); python tools/check_conventions.py --base upstream/main passed. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6131554198 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4653#issuecomment-6131554198). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-12T19:54:01Z. --- Windows test: head `c052b7c72` merged onto current `main` `1b92f7f5d` (clean merge, no conflicts). Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest with the filter `guest_statvfs`: guest_statvfs passed (1 test(s), 0 failed); `python tools/check_conventions.py --base upstream/main` passed. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
adriadam10 commented 2026-10-12 21:08:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-12T21:08:13Z.


Checked on Linux, merged onto current main: build and scoped ctest (151 tests) pass, guest_statvfs passes and the library no longer links without the change. Path resolution errors (ENOENT, ENOTDIR, EFAULT), buffer bounds and descriptor cleanup with errno preserved look right; Windows runs by @Nixitov and @xXPBSXx cover that side. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6132634390 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4653#issuecomment-6132634390). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-12T21:08:13Z. --- Checked on Linux, merged onto current main: build and scoped ctest (151 tests) pass, `guest_statvfs` passes and the library no longer links without the change. Path resolution errors (`ENOENT`, `ENOTDIR`, `EFAULT`), buffer bounds and descriptor cleanup with errno preserved look right; Windows runs by @Nixitov and @xXPBSXx cover that side. Merging.
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!4653
No description provided.