feat(libSceLibcInternal): implement ten unversioned std::filesystem helpers #15665

Merged
HilalElusive merged 2 commits from upstream-pr/15665 into main 2026-11-07 16:37:53 +00:00
HilalElusive commented 2026-11-04 01:19:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by HilalElusive on 2026-11-04T01:19:53Z.


What

Implement ten unversioned std::filesystem helpers in libSceLibcInternal, replacing their numbered throwing placeholders (sceLibcInternalPending4_117 to _129) in Export.cpp. Their names and NIDs come from the PS5 3.20 export inventory; no module was read for them and no console was measured.

  • _Stat(const char*, perms*), _Lstat(const char*, perms*) and _File_size(const char*) call this library's existing overloads that take an error output, passing none.
  • _Last_write_time(const char*) calls the existing (path, seconds*, nanoseconds*) overload and returns -1 when it fails, else the seconds.
  • _Set_last_write_time, _Rename, _Resize, _Copy_file, _Statvfs and _Current_set2 call libc's matching std::__sce_v2::filesystem helpers, which follow the libc.prx bundled with PPSA03671 (docs/dev/debt/libc.md). This assumes both namespaces build the same Dinkumware sources, as libc's versioned _Open_dir, _Read_dir, _Close_dir and _Current_get already reuse the unversioned implementation. So _Statvfs returns ENOSYS with unknown space and _Current_set2 accepts only "/", as in that module.
    _Equivalent, _Current_set and the three-argument _Xfilesystem_error keep their placeholders: no source gives their behaviour, and #15486 is reworking the filesystem exception path. The ten inventory entries are removed from docs/dev/debt/libSceLibcInternal.md, and the remaining gap is recorded under Functional.

Overlap: no open pull request touches these ten exports or their placeholders. The new code is in its own UnversionedFilesystemCalls.cpp, so #15126's changes to Filesystem.cpp do not conflict. The declarations, the build block and the debt entry are placed where no other open pull request edits. Only #14212, which adds a blank line between every debt entry, conflicts with the new entry.

Tested

Ubuntu 24.04 x86-64, GCC 13.3.0, Release full configure with BUILD_TESTING=ON; no title.

  • New guest_libc_internal_unversioned_filesystem: types, permission bits, missing paths and a followed link through _Stat/_Lstat; file size and missing size; write times set and read back for positive, negative and sub-second microsecond values, and a missing file; rename, rename over a directory and of a missing file; growing and shrinking resize; copying a file larger than one 64 KiB block, a missing source and a directory target; _Statvfs returning ENOSYS and writing only three fields; _Current_set2 with "/" and another path. Five deliberate faults (seconds swapped for nanoseconds, _Rename sent to _Copy_file, a zero size, _Current_set2 accepting everything, the permission output dropped) each made it fail.
  • guest_libc_filesystem, guest_sce_v2_filesystem_calls, public_headers and all 65 public_headers_compile_* batches pass.
  • nm -D on libSceLibcInternal.prx lists the ten exports.
  • python3 tools/check_conventions.py --base upstream/main passes.
  • python3 tools/pr_overlap.py --branch feat/libc-internal-unversioned-filesystem (1827 open pull requests) reports no conflicting files and no shared exports. It could not compare seven pull requests that conflict with main (#5021, #13486, #13778, #13782, #14212, #14401, #14837), so I merged this branch with each of them and with every other open pull request touching these files using git merge-tree. Only #14212 conflicts with this branch's lines, as described above.

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
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5147184650 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15665). Originally posted by [HilalElusive](https://github.com/HilalElusive) on 2026-11-04T01:19:53Z. --- ### What Implement ten unversioned `std::filesystem` helpers in `libSceLibcInternal`, replacing their numbered throwing placeholders (`sceLibcInternalPending4_117` to `_129`) in `Export.cpp`. Their names and NIDs come from the PS5 3.20 export inventory; no module was read for them and no console was measured. - `_Stat(const char*, perms*)`, `_Lstat(const char*, perms*)` and `_File_size(const char*)` call this library's existing overloads that take an error output, passing none. - `_Last_write_time(const char*)` calls the existing `(path, seconds*, nanoseconds*)` overload and returns -1 when it fails, else the seconds. - `_Set_last_write_time`, `_Rename`, `_Resize`, `_Copy_file`, `_Statvfs` and `_Current_set2` call libc's matching `std::__sce_v2::filesystem` helpers, which follow the `libc.prx` bundled with PPSA03671 (`docs/dev/debt/libc.md`). This assumes both namespaces build the same Dinkumware sources, as libc's versioned `_Open_dir`, `_Read_dir`, `_Close_dir` and `_Current_get` already reuse the unversioned implementation. So `_Statvfs` returns `ENOSYS` with unknown space and `_Current_set2` accepts only `"/"`, as in that module. `_Equivalent`, `_Current_set` and the three-argument `_Xfilesystem_error` keep their placeholders: no source gives their behaviour, and #15486 is reworking the filesystem exception path. The ten inventory entries are removed from `docs/dev/debt/libSceLibcInternal.md`, and the remaining gap is recorded under Functional. Overlap: no open pull request touches these ten exports or their placeholders. The new code is in its own `UnversionedFilesystemCalls.cpp`, so #15126's changes to `Filesystem.cpp` do not conflict. The declarations, the build block and the debt entry are placed where no other open pull request edits. Only #14212, which adds a blank line between every debt entry, conflicts with the new entry. ### Tested Ubuntu 24.04 x86-64, GCC 13.3.0, Release full configure with `BUILD_TESTING=ON`; no title. - New `guest_libc_internal_unversioned_filesystem`: types, permission bits, missing paths and a followed link through `_Stat`/`_Lstat`; file size and missing size; write times set and read back for positive, negative and sub-second microsecond values, and a missing file; rename, rename over a directory and of a missing file; growing and shrinking resize; copying a file larger than one 64 KiB block, a missing source and a directory target; `_Statvfs` returning `ENOSYS` and writing only three fields; `_Current_set2` with `"/"` and another path. Five deliberate faults (seconds swapped for nanoseconds, `_Rename` sent to `_Copy_file`, a zero size, `_Current_set2` accepting everything, the permission output dropped) each made it fail. - `guest_libc_filesystem`, `guest_sce_v2_filesystem_calls`, `public_headers` and all 65 `public_headers_compile_*` batches pass. - `nm -D` on `libSceLibcInternal.prx` lists the ten exports. - `python3 tools/check_conventions.py --base upstream/main` passes. - `python3 tools/pr_overlap.py --branch feat/libc-internal-unversioned-filesystem` (1827 open pull requests) reports no conflicting files and no shared exports. It could not compare seven pull requests that conflict with `main` (#5021, #13486, #13778, #13782, #14212, #14401, #14837), so I merged this branch with each of them and with every other open pull request touching these files using `git merge-tree`. Only #14212 conflicts with this branch's lines, as described above. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
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!15665
No description provided.