feat(libc): implement guest fstatvfs volume statistics #3596

Merged
Lorkydey merged 3 commits from upstream-pr/3596 into main 2026-10-11 21:48:11 +00:00
Lorkydey commented 2026-10-11 13:59:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Lorkydey on 2026-10-11T13:59:30Z.


What

PS5MC 1.2 (PPSA99420, Kodi 22) imports fstatvfs from libSceLibcInternal, but main a11c8f7f does not export it. Its public release has an undefined dynamic function symbol at index 452, NID 6IM2up2+a-A, mapped to that library. The existing _fstatfs implementation from #2858 provides the kernel data; this PR adds the missing libc conversion and export.

Convert those real volume statistics into the 88-byte guest statvfs layout: retain 64-bit block and inode counts, distinguish I/O and fragment sizes, translate read-only/nosuid flags, and propagate backend errors without changing the output on failure. Extract the existing KernelStatfs definition unchanged into a shared header. Success preserves guest errno and the descriptor position; a null output returns EFAULT after descriptor validation.

Layout and conversion semantics follow FreeBSD 9.2's statvfs definition and libc conversion. The name limit comes from the existing kernel volume query. This inherits _fstatfs's platform coverage, including zero inode counts on Windows; it does not introduce invented inode values or implement the separate path-based statvfs export.

Tested

Windows 11 Pro 26100, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON.

  • On unchanged main, adding the runtime regression test fails to link with undefined reference to fstatvfs_nid_postfix.
  • Full build succeeds. All five targeted tests pass: guest_fstatvfs, guest_fstatvfs_conversion, guest_fstatfs, guest_utime, and guest_utime_forwarding (0.40 seconds total).
  • Runtime coverage: real file and guest directory volume statistics, capacity compared with the host, unchanged seek position, pipe/socket/invalid-descriptor errors, errno, null output, and buffer bounds.
  • Controlled backend coverage: values above 32 bits, signed counter conversion, different block sizes, every combination of the low four mount flags, exact guest field order, propagated errors, and untouched output on failure.
  • Patched libSceLibcInternal.prx exports 6IM2up2+a-A.
  • Conventions and whitespace checks pass. The repository overlap checker found no conflicting changes, same new files, or duplicate exports across 174 open PRs. All-state PR searches found no existing fstatvfs implementation; #2858 implements the distinct kernel _fstatfs backend.
  • tools/progress.py: libraries 2903/3383 (85.81%) -> 2904/3384 (85.82%). This adds one implemented function to the source counter.

Title evidence: public PS5MC 1.2 Kodi 22 release, archive SHA256 5a9eeff4a0024a341a4924b8d283fe65b4ff94d7f5dbea446c8a677c4db157b6, inspected without execution. PS5MC was not launched; the import audit does not establish this as its first startup failure. Linux and macOS runtime tests were not run locally.

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; 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
  • AI-assisted: yes (Codex)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4819597115 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3596). Originally posted by [Lorkydey](https://github.com/Lorkydey) on 2026-10-11T13:59:30Z. --- ### What PS5MC 1.2 (PPSA99420, Kodi 22) imports `fstatvfs` from `libSceLibcInternal`, but main `a11c8f7f` does not export it. Its public release has an undefined dynamic function symbol at index 452, NID `6IM2up2+a-A`, mapped to that library. The existing `_fstatfs` implementation from #2858 provides the kernel data; this PR adds the missing libc conversion and export. Convert those real volume statistics into the 88-byte guest `statvfs` layout: retain 64-bit block and inode counts, distinguish I/O and fragment sizes, translate read-only/nosuid flags, and propagate backend errors without changing the output on failure. Extract the existing `KernelStatfs` definition unchanged into a shared header. Success preserves guest errno and the descriptor position; a null output returns `EFAULT` after descriptor validation. Layout and conversion semantics follow FreeBSD 9.2's [statvfs definition](https://github.com/freebsd/freebsd-src/blob/releng/9.2/sys/sys/statvfs.h#L54-L69) and [libc conversion](https://github.com/freebsd/freebsd-src/blob/releng/9.2/lib/libc/gen/statvfs.c#L92-L120). The name limit comes from the existing kernel volume query. This inherits `_fstatfs`'s platform coverage, including zero inode counts on Windows; it does not introduce invented inode values or implement the separate path-based `statvfs` export. ### Tested Windows 11 Pro 26100, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON. - On unchanged main, adding the runtime regression test fails to link with `undefined reference to fstatvfs_nid_postfix`. - Full build succeeds. All five targeted tests pass: `guest_fstatvfs`, `guest_fstatvfs_conversion`, `guest_fstatfs`, `guest_utime`, and `guest_utime_forwarding` (0.40 seconds total). - Runtime coverage: real file and guest directory volume statistics, capacity compared with the host, unchanged seek position, pipe/socket/invalid-descriptor errors, errno, null output, and buffer bounds. - Controlled backend coverage: values above 32 bits, signed counter conversion, different block sizes, every combination of the low four mount flags, exact guest field order, propagated errors, and untouched output on failure. - Patched `libSceLibcInternal.prx` exports `6IM2up2+a-A`. - Conventions and whitespace checks pass. The repository overlap checker found no conflicting changes, same new files, or duplicate exports across 174 open PRs. All-state PR searches found no existing `fstatvfs` implementation; #2858 implements the distinct kernel `_fstatfs` backend. - `tools/progress.py`: libraries 2903/3383 (85.81%) -> 2904/3384 (85.82%). This adds one implemented function to the source counter. Title evidence: [public PS5MC 1.2 Kodi 22 release](https://github.com/VivaLaVent/PS5MC/releases/tag/1.2), archive SHA256 `5a9eeff4a0024a341a4924b8d283fe65b4ff94d7f5dbea446c8a677c4db157b6`, inspected without execution. PS5MC was not launched; the import audit does not establish this as its first startup failure. Linux and macOS runtime tests were not run locally. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [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] AI-assisted: yes (Codex)
github-actions[bot] commented 2026-10-11 13:59:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-11T13:59:52Z.


Progress report (951fd9a → c81ee92)

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

✅ 1 implemented
Library Name
libSceLibcInternal fstatvfs_nid_postfix
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6109800069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3596#issuecomment-6109800069). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-11T13:59:52Z. --- <!-- progress-report --> ### Progress report (951fd9a → c81ee92) ➖ **System libraries**: 85.62% (+0.0%, +1 implemented functions) <details> <summary>✅ 1 implemented</summary> | Library | Name | | - | - | | libSceLibcInternal | `fstatvfs_nid_postfix` | </details>
adriadam10 commented 2026-10-11 21:39:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T21:39:58Z.


Checked the statvfs layout and the statfs → statvfs conversion against FreeBSD 9.2 (statvfs.h, sfs2svfs): fields, flags, f_bsize/f_frsize and f_favail match. Build and the 119 scoped ctest tests pass on Linux, and the new tests fail to link without the change.

Added one commit on top (rebased on current main):

  • docs/dev/TechnicalDebt.md: a line under "Functional" for the deviations (f_namemax taken from statfs instead of fpathconf, negative counters wrap without EOVERFLOW, zero inode counts on Windows, EFAULT on a null output).

Merging once CI is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6114078451 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/3596#issuecomment-6114078451). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-11T21:39:58Z. --- Checked the `statvfs` layout and the `statfs` → `statvfs` conversion against FreeBSD 9.2 (`statvfs.h`, `sfs2svfs`): fields, flags, `f_bsize`/`f_frsize` and `f_favail` match. Build and the 119 scoped ctest tests pass on Linux, and the new tests fail to link without the change. Added one commit on top (rebased on current `main`): - `docs/dev/TechnicalDebt.md`: a line under "Functional" for the deviations (`f_namemax` taken from `statfs` instead of `fpathconf`, negative counters wrap without `EOVERFLOW`, zero inode counts on Windows, `EFAULT` on a null output). Merging once CI is green.
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!3596
No description provided.