feat(libc): implement devname and devname_r #14864

Merged
Jawschamp merged 1 commit from upstream-pr/14864 into main 2026-11-03 05:11:00 +00:00
Jawschamp commented 2026-11-01 21:13:21 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Jawschamp on 2026-11-01T21:13:21Z.


What

Implements devname and devname_r (libSceLibcInternal NIDs fqLrWSWcGHw and BIALMFTZ75I) in libc, following FreeBSD 11.4 lib/libc/gen/devname.c. Both returned the NID-literal placeholders libSceLibcInternalUnknown_*_nid_no_patch before; those are removed, as in 36ea3f125, and the two rows are removed from docs/dev/debt/libSceLibcInternal.md with its counts updated.

  • Non-device types and NODEV give #NODEV. Character devices give #C:0x<hex> and block devices #B:0x<hex>, written into the caller's buffer with strlcpy truncation.
  • devname formats into a static 64-byte buffer through devname_r.
  • kern.devname is never queried, so the formatted fallback is always returned. The 11.4 S_ISBLK(dev) check is kept as written. Both are documented in docs/dev/debt/libc.md with FreeBSD source links. Neither was measured on a PS5.
  • New guest test guest_device_name covers NODEV, non-device types, char and block formatting, truncation, the EOVERFLOW path and the static buffer.

Tested

Linux x86_64, GCC 14.2 (g++ extracted from Debian trixie packages), -DBUILD_TESTING=ON, full configure with all submodules. Hardware and titles: not tested.

  • Built libc, libSceLibcInternal and guest_device_name_tests. ctest -R guest_device_name passes (0.01 s). devname_nid_postfix and devname_r_nid_postfix are exported by libc.prx.
  • core/libs/tests/test_public_headers.py --audit-only passes (one declaration per export).
  • tools/check_conventions.py --base origin/main and tools/check_test_registration.py pass.
  • tools/pr_overlap.py --branch feat/libc-devname finds no PR with the same exports or new files. It reports textual overlap only in neighbouring lines of the debt docs, Api.hpp, CMakeLists.txt and the inventory files; the branches it could not compare were checked by hand, and none of them adds or changes devname, devname_r, BIALMFTZ75I or fqLrWSWcGHw.
  • Not run: the rest of the suite, Windows and the PS5 behaviour of kern.devname.

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:5111626667 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14864). Originally posted by [Jawschamp](https://github.com/Jawschamp) on 2026-11-01T21:13:21Z. --- ### What Implements `devname` and `devname_r` (libSceLibcInternal NIDs `fqLrWSWcGHw` and `BIALMFTZ75I`) in libc, following FreeBSD 11.4 `lib/libc/gen/devname.c`. Both returned the NID-literal placeholders `libSceLibcInternalUnknown_*_nid_no_patch` before; those are removed, as in 36ea3f125, and the two rows are removed from `docs/dev/debt/libSceLibcInternal.md` with its counts updated. - Non-device types and `NODEV` give `#NODEV`. Character devices give `#C:0x<hex>` and block devices `#B:0x<hex>`, written into the caller's buffer with `strlcpy` truncation. - `devname` formats into a static 64-byte buffer through `devname_r`. - `kern.devname` is never queried, so the formatted fallback is always returned. The 11.4 `S_ISBLK(dev)` check is kept as written. Both are documented in `docs/dev/debt/libc.md` with FreeBSD source links. Neither was measured on a PS5. - New guest test `guest_device_name` covers `NODEV`, non-device types, char and block formatting, truncation, the `EOVERFLOW` path and the static buffer. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Linux x86_64, GCC 14.2 (g++ extracted from Debian trixie packages), `-DBUILD_TESTING=ON`, full configure with all submodules. Hardware and titles: not tested. - Built `libc`, `libSceLibcInternal` and `guest_device_name_tests`. `ctest -R guest_device_name` passes (0.01 s). `devname_nid_postfix` and `devname_r_nid_postfix` are exported by `libc.prx`. - `core/libs/tests/test_public_headers.py --audit-only` passes (one declaration per export). - `tools/check_conventions.py --base origin/main` and `tools/check_test_registration.py` pass. - `tools/pr_overlap.py --branch feat/libc-devname` finds no PR with the same exports or new files. It reports textual overlap only in neighbouring lines of the debt docs, `Api.hpp`, `CMakeLists.txt` and the inventory files; the branches it could not compare were checked by hand, and none of them adds or changes `devname`, `devname_r`, `BIALMFTZ75I` or `fqLrWSWcGHw`. - Not run: the rest of the suite, Windows and the PS5 behaviour of `kern.devname`. ### 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
BunnyFl commented 2026-11-02 02:06:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by BunnyFl on 2026-11-02T02:06:13Z.

Review: APPROVED


Windows 11, WinLibs GCC 15.2.0 r7, Release. Head a4faa2f0b6 merged into upstream/main 93dbd0f82a:

  • guest_device_name passes. Without DeviceName.cpp the test doesn't link, as expected for new exports.
  • devname and devname_r hash to fqLrWSWcGHw and BIALMFTZ75I. Both are defined entries in the dynamic symbol table of firmware 13.42's libSceLibcInternal.sprx (objdump -T; behaviour not run).

Read against FreeBSD 11.4's devname.c:

  • %#jx prints a zero device without the 0x prefix, and the code and test have #C:0.
  • The S_ISBLK(dev) check on the device number rather than the type is kept and documented as the source has it. That's the right call for a faithful port.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5731406069 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/14864#pullrequestreview-5731406069). Originally posted by [BunnyFl](https://github.com/BunnyFl) on 2026-11-02T02:06:13Z. **Review:** APPROVED --- Windows 11, WinLibs GCC 15.2.0 r7, Release. Head a4faa2f0b6 merged into upstream/main 93dbd0f82a: - `guest_device_name` passes. Without `DeviceName.cpp` the test doesn't link, as expected for new exports. - `devname` and `devname_r` hash to `fqLrWSWcGHw` and `BIALMFTZ75I`. Both are defined entries in the dynamic symbol table of firmware 13.42's `libSceLibcInternal.sprx` (`objdump -T`; behaviour not run). Read against FreeBSD 11.4's `devname.c`: - `%#jx` prints a zero device without the `0x` prefix, and the code and test have `#C:0`. - The `S_ISBLK(dev)` check on the device number rather than the type is kept and documented as the source has it. That's the right call for a faithful port.
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!14864
No description provided.