feat(libSceUsbStorage): the no-device path of the USB storage service #8399

Merged
primesoul-web merged 2 commits from upstream-pr/8399 into main 2026-10-24 10:57:11 +00:00
primesoul-web commented 2026-10-20 12:16:55 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-10-20T12:16:55Z.


What

libSceUsbStorage was 0/21: every export threw NotImplemented_nid_no_patch. Nine of them now implement the no-device path, with prototypes and argument validation following the ABI restored on main (the firmware-database sweep of 2026-10-21, which matches shadPS4 — the same reference the library's debt file already cites for the RequestMapWSB prototype) and error codes following shadPS4's auto_mounter values; the device-info record follows SharpProspero:

  • Lifecycle: sceUsbStorageInit/sceUsbStorageTerm accept every call and keep no state, as shadPS4 does.
  • Device queries: sceUsbStorageGetDeviceList answers 0 with an empty list, sceUsbStorageIsExist (the restored three-argument bool form) succeeds and reports non-existence for every device id and directory, and sceUsbStorageGetDeviceInfo answers 0x80f40004 (DeviceNotFound) for every device id, after the null-pointer check.
  • Mapping: sceUsbStorageRequestMap and sceUsbStorageRequestMapWSB answer DeviceNotFound for every device id and leave their outputs untouched.
  • Getdents: sceUsbStorageGetdentsOpen answers DeviceNotFound (after the null checks) and sceUsbStorageGetdentsRead answers 0x80f40005 (NotSupported) with zero bytes for a descriptor that was never opened.

AnyPS5 has no USB mass-storage passthrough, so this is the no-attached-device state a title actually observes here; the model matches the one the merged Hmd2 (no headset) and Mbus (no device) libraries follow. A future passthrough follows shadPS4's virtual-device model at the pinned commit for the filled paths, including its packed dirent, but fills the 0x338-byte device-info record from SharpProspero's layout (recovered from the module's own sceUsbStorageGetDeviceInfo and checked in #6288 as "volume size at 0x0"), because shadPS4's record starts with a u32 device id at offset 0 where a title reads the volume size, as the debt entry states.

Twelve exports keep their markers, each for a reason the debt file records. The six register/unregister callbacks and sceUsbStorageRequestUnmap/sceUsbStorageGetdentsClose run their argument validation (a null callback, an event type outside 1 and 2, or a null directory is refused with 0x80f40002) and then throw: shadPS4 logs the callbacks as (STUBBED) and returns 0 without storing anything, its unmap keeps no state and its close succeeds only because erase ignores a missing key, and a success return without a reference is the pattern #6288 was closed for — the no-device libraries throw on this path (sceMoveClose, sceContentSearchCloseMetadata). sceUsbStorageClearFakeWriteProtection, sceUsbStorageSetFakeMapLockForDebug and sceUsbStorageSetFakeWriteProtection have no credible prototypes (names only in the PS5 3.20 export inventory), and sceUsbStorageGetMountPointOfShellCore has a known prototype but no reference says what a console without a mapped device answers. sceUsbStorageRequestMap's six parameters, the typed UsbStorageCallback and sceUsbStorageIsExist's bool form follow the restored ABI on main; sceUsbStorageGetDeviceList's int32_t* count also follows SharpProspero (whose earlier eight-parameter RequestMap reading carried the trailing reserved pair the restored ABI drops; shadPS4's RequestMap takes six and its count is u32*).

The library gets a CMakeLists.txt registering the new GuestUsbStorage test (the Hmd2 pattern); the library target builds as before.

Tested

Ubuntu (Linux x86-64), GCC, -std=c++20 -O2 -Wall -Wextra, direct library build of Export.cpp + GuestUsbStorage (the guest-test pattern of the other libraries; the platform CI relinker build runs on the PR). The author did not compile Windows; a community Windows build of the earlier revision passed (see the comments).

  • New guest_usb_storage walks: init/term (including re-init), the six callback validations with their InvalidArgument cases (null callback, event types 0/3/-1, null directory) followed by their marker throws, the no-device answers (GetDeviceList → empty with the array untouched, GetDeviceInfo → DeviceNotFound with the buffer untouched, IsExist → succeeds with exists cleared on every row), the map requests (outputs untouched by canary), RequestUnmap's null-directory refusal and marker, the getdents family (open → DeviceNotFound with outputs untouched, read of an unopened descriptor → NotSupported with zero bytes, close → marker), and the four other throwing markers. The callback the test registers is an APS5_VABI function now that the pointer type is restored.
  • Negative control: the same test binary against main's Export.cpp aborts at sceUsbStorageInit not implemented, so the checks cover the new behaviour, not just the signatures.
  • tools/check_conventions.py --base origin/main passes with the title and body below.
  • tools/progress.py: main 9be6ccf60 = 4405/8805 (50.03%); with this PR = 4414/8805 (50.13%), libSceUsbStorage 0/21 → 9/21; no regressions (compare_progress.py). Re-measured on the ABI-adoption head 4d98d9a2c against main d6eafa54d: 4834/11181 (43.23%) → 4843/11181 (43.31%), 0/21 → 9/21, no regressions — the count is unchanged by the signature adoption.

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:4935584655 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399). Originally posted by [primesoul-web](https://github.com/primesoul-web) on 2026-10-20T12:16:55Z. --- ### What `libSceUsbStorage` was 0/21: every export threw `NotImplemented_nid_no_patch`. Nine of them now implement the no-device path, with prototypes and argument validation following the ABI restored on `main` (the firmware-database sweep of 2026-10-21, which matches [shadPS4](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp) — the same reference the library's debt file already cites for the `RequestMapWSB` prototype) and error codes following shadPS4's auto_mounter values; the device-info record follows [SharpProspero](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs): - **Lifecycle**: `sceUsbStorageInit`/`sceUsbStorageTerm` accept every call and keep no state, as shadPS4 does. - **Device queries**: `sceUsbStorageGetDeviceList` answers 0 with an empty list, `sceUsbStorageIsExist` (the restored three-argument bool form) succeeds and reports non-existence for every device id and directory, and `sceUsbStorageGetDeviceInfo` answers `0x80f40004` (`DeviceNotFound`) for every device id, after the null-pointer check. - **Mapping**: `sceUsbStorageRequestMap` and `sceUsbStorageRequestMapWSB` answer `DeviceNotFound` for every device id and leave their outputs untouched. - **Getdents**: `sceUsbStorageGetdentsOpen` answers `DeviceNotFound` (after the null checks) and `sceUsbStorageGetdentsRead` answers `0x80f40005` (`NotSupported`) with zero bytes for a descriptor that was never opened. AnyPS5 has no USB mass-storage passthrough, so this is the no-attached-device state a title actually observes here; the model matches the one the merged Hmd2 (no headset) and Mbus (no device) libraries follow. A future passthrough follows shadPS4's virtual-device model at the pinned commit for the filled paths, including its packed dirent, but fills the 0x338-byte device-info record from SharpProspero's layout (recovered from the module's own `sceUsbStorageGetDeviceInfo` and checked in #6288 as "volume size at 0x0"), because shadPS4's record starts with a u32 device id at offset 0 where a title reads the volume size, as the debt entry states. Twelve exports keep their markers, each for a reason the debt file records. The six register/unregister callbacks and `sceUsbStorageRequestUnmap`/`sceUsbStorageGetdentsClose` run their argument validation (a null callback, an event type outside 1 and 2, or a null directory is refused with `0x80f40002`) and then throw: shadPS4 logs the callbacks as `(STUBBED)` and returns 0 without storing anything, its unmap keeps no state and its close succeeds only because `erase` ignores a missing key, and a success return without a reference is the pattern #6288 was closed for — the no-device libraries throw on this path (`sceMoveClose`, `sceContentSearchCloseMetadata`). `sceUsbStorageClearFakeWriteProtection`, `sceUsbStorageSetFakeMapLockForDebug` and `sceUsbStorageSetFakeWriteProtection` have no credible prototypes (names only in the PS5 3.20 export inventory), and `sceUsbStorageGetMountPointOfShellCore` has a known prototype but no reference says what a console without a mapped device answers. `sceUsbStorageRequestMap`'s six parameters, the typed `UsbStorageCallback` and `sceUsbStorageIsExist`'s bool form follow the restored ABI on `main`; `sceUsbStorageGetDeviceList`'s `int32_t*` count also follows SharpProspero (whose earlier eight-parameter `RequestMap` reading carried the trailing reserved pair the restored ABI drops; shadPS4's `RequestMap` takes six and its count is `u32*`). The library gets a `CMakeLists.txt` registering the new `GuestUsbStorage` test (the Hmd2 pattern); the library target builds as before. ### 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. --> Ubuntu (Linux x86-64), GCC, `-std=c++20 -O2 -Wall -Wextra`, direct library build of `Export.cpp` + `GuestUsbStorage` (the guest-test pattern of the other libraries; the platform CI relinker build runs on the PR). The author did not compile Windows; a community Windows build of the earlier revision passed (see the comments). - New `guest_usb_storage` walks: init/term (including re-init), the six callback validations with their `InvalidArgument` cases (null callback, event types 0/3/-1, null directory) followed by their marker throws, the no-device answers (`GetDeviceList` → empty with the array untouched, `GetDeviceInfo` → `DeviceNotFound` with the buffer untouched, `IsExist` → succeeds with `exists` cleared on every row), the map requests (outputs untouched by canary), `RequestUnmap`'s null-directory refusal and marker, the getdents family (open → `DeviceNotFound` with outputs untouched, read of an unopened descriptor → `NotSupported` with zero bytes, close → marker), and the four other throwing markers. The callback the test registers is an `APS5_VABI` function now that the pointer type is restored. - Negative control: the same test binary against main's `Export.cpp` aborts at `sceUsbStorageInit not implemented`, so the checks cover the new behaviour, not just the signatures. - `tools/check_conventions.py --base origin/main` passes with the title and body below. - `tools/progress.py`: main `9be6ccf60` = 4405/8805 (50.03%); with this PR = 4414/8805 (50.13%), libSceUsbStorage 0/21 → 9/21; no regressions (`compare_progress.py`). Re-measured on the ABI-adoption head `4d98d9a2c` against main `d6eafa54d`: 4834/11181 (43.23%) → 4843/11181 (43.31%), 0/21 → 9/21, no regressions — the count is unchanged by the signature adoption. ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->
github-actions[bot] commented 2026-10-20 12:17:44 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-20T12:17:44Z.


Progress report (d6eafa5 → 4d98d9a)

📈 System libraries: 43.31% (+0.08%, +9 implemented functions)

✅ 9 implemented
Library Name
libSceUsbStorage sceUsbStorageGetDeviceInfo
libSceUsbStorage sceUsbStorageGetDeviceList
libSceUsbStorage sceUsbStorageGetdentsOpen
libSceUsbStorage sceUsbStorageGetdentsRead
libSceUsbStorage sceUsbStorageInit
libSceUsbStorage sceUsbStorageIsExist
libSceUsbStorage sceUsbStorageRequestMap
libSceUsbStorage sceUsbStorageRequestMapWSB
libSceUsbStorage sceUsbStorageTerm
⚪ 2 behaviourally empty (constant return or throw)
Library Name
libSceUsbStorage sceUsbStorageInit
libSceUsbStorage sceUsbStorageTerm
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6290652657 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6290652657). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-20T12:17:44Z. --- <!-- progress-report --> ### Progress report (d6eafa5 → 4d98d9a) 📈 **System libraries**: 43.31% (+0.08%, +9 implemented functions) <details> <summary>✅ 9 implemented</summary> | Library | Name | | - | - | | libSceUsbStorage | `sceUsbStorageGetDeviceInfo` | | libSceUsbStorage | `sceUsbStorageGetDeviceList` | | libSceUsbStorage | `sceUsbStorageGetdentsOpen` | | libSceUsbStorage | `sceUsbStorageGetdentsRead` | | libSceUsbStorage | `sceUsbStorageInit` | | libSceUsbStorage | `sceUsbStorageIsExist` | | libSceUsbStorage | `sceUsbStorageRequestMap` | | libSceUsbStorage | `sceUsbStorageRequestMapWSB` | | libSceUsbStorage | `sceUsbStorageTerm` | </details> <details> <summary>⚪ 2 behaviourally empty (constant return or throw)</summary> | Library | Name | | - | - | | libSceUsbStorage | `sceUsbStorageInit` | | libSceUsbStorage | `sceUsbStorageTerm` | </details>
nikowolf123 commented 2026-10-20 20:40:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-20T20:40:39Z.


1. Callback register/unregister (Export.cpp#L19-L72)

All six calls check their arguments and then return 0 without recording anything. So sceUsbStorageUnregisterCallback(1, cb) returns 0 for a cb that was never registered, and returns 0 again on a second call.

#6288 had the same checks and the same return 0. It was closed with this comment: "Register/unregister callbacks, RequestMap, and the fake write-protection calls return success without doing anything. Unverified paths must throw (NotImplemented_nid_no_patch)" (comment). This PR fixes RequestMap, the fake calls, the signatures and the missing test from that comment, but not the callbacks.

The cited reference does not support the success path either: shadPS4 logs all six as (STUBBED) (usbstorage.cpp#L110, and L124, L135, L147, L159, L171). The debt file also lists them under Silent stubs while the checklist says Unblocks: none, and CONTRIBUTING.md allows a silent stub only when it unblocks a title.

I suggest keeping the checks and throwing after them until a title needs these calls. The test lines that expect 0 from these calls (43-44, 49-50, 56, 59, 62, 65) would then move to the throwing checks.

    if (eventType < UsbStorage::CallbackEventTypeFirst || eventType > UsbStorage::CallbackEventTypeLast) {
        return UsbStorage::InvalidArgument;
    }
    NotImplemented_nid_no_patch(__func__);
    return 0;

2. sceUsbStorageRequestUnmap and sceUsbStorageGetdentsClose (Export.cpp#L116, Export.cpp#L142)

In this model nothing can be mapped or opened. Even so, sceUsbStorageRequestUnmap(7, "/mnt/usb7") and sceUsbStorageGetdentsClose(1) return 0. Meanwhile sceUsbStorageGetdentsRead(1, ...) on the same never-opened descriptor returns 0x80f40005.

shadPS4 does not establish these answers:

  • Its unmap keeps no state and only logs (L281-L288).
  • Its close returns OK for an unknown descriptor only because erase ignores a missing key (L378-L383).

The no-device libraries already merged throw in this case. sceMoveClose throws for a handle that was never opened (libSceMove/Export.cpp#L71). sceContentSearchCloseMetadata throws because no metadata id is ever handed out (libSceContentSearch.md#L9).

I suggest throwing after the null check in both functions, dropping the two "answers 0" clauses from the debt entry at L16, and updating test lines 104-105 and 126-127.

std::int32_t APS5_VABI sceUsbStorageGetdentsClose(std::int32_t fd) {
    (void)fd;
    NotImplemented_nid_no_patch(__func__);
    return 0;
}

3. Sources in the debt file (libSceUsbStorage.md#L15)

L15 says the prototypes follow shadPS4 L176-L383, but two of them match SharpProspero and not shadPS4. sceUsbStorageRequestMap takes 8 arguments here, as in SharpProspero UsbStorage.cs#L235, while shadPS4's takes 6 (L276-L277). sceUsbStorageGetDeviceList takes std::int32_t* count, as in SharpProspero (L233), while shadPS4 has u32* count (L176).

L16 tells a future passthrough to follow shadPS4's 0x338-byte device-info record. That record has u32 device_id at offset 0 (L33-L35). SharpProspero recovered its layout from the module's sceUsbStorageGetDeviceInfo, and it has the u64 volume size at offset 0 (L34-L45, L100). #6288 was checked against that layout ("volume size at 0x0"). Filling the record the way shadPS4 does would put a device id where a title reads the volume size.

I suggest these changes to the entry:

  • Cite SharpProspero at 5dfdb4b0 for these two prototypes and for the record layout.
  • Note that shadPS4 puts device_id at offset 0.
  • Start each entry with what is unverified, as CONTRIBUTING.md asks ("An entry states the gap first").
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6300998729 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6300998729). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-20T20:40:39Z. --- **1. Callback register/unregister** ([Export.cpp#L19-L72](https://github.com/boykopovar/AnyPS5/blob/9e81ae3ff23f4563bfda7903b92fe8a554b1435d/core/libs/prx/libSceUsbStorage/Export.cpp#L19-L72)) All six calls check their arguments and then return 0 without recording anything. So `sceUsbStorageUnregisterCallback(1, cb)` returns 0 for a `cb` that was never registered, and returns 0 again on a second call. #6288 had the same checks and the same `return 0`. It was closed with this comment: "Register/unregister callbacks, `RequestMap`, and the fake write-protection calls return success without doing anything. Unverified paths must throw (`NotImplemented_nid_no_patch`)" ([comment](https://github.com/boykopovar/AnyPS5/pull/6288#issuecomment-6254288776)). This PR fixes `RequestMap`, the fake calls, the signatures and the missing test from that comment, but not the callbacks. The cited reference does not support the success path either: shadPS4 logs all six as `(STUBBED)` ([usbstorage.cpp#L110](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L110), and L124, L135, L147, L159, L171). The debt file also lists them under Silent stubs while the checklist says `Unblocks: none`, and [CONTRIBUTING.md](https://github.com/boykopovar/AnyPS5/blob/9a97ac784da5d40cc7b7d968898ffbf5b8b5377a/CONTRIBUTING.md#L8) allows a silent stub only when it unblocks a title. I suggest keeping the checks and throwing after them until a title needs these calls. The [test lines](https://github.com/boykopovar/AnyPS5/blob/9e81ae3ff23f4563bfda7903b92fe8a554b1435d/core/libs/tests/GuestUsbStorage.cpp#L43) that expect 0 from these calls (43-44, 49-50, 56, 59, 62, 65) would then move to the throwing checks. ```cpp if (eventType < UsbStorage::CallbackEventTypeFirst || eventType > UsbStorage::CallbackEventTypeLast) { return UsbStorage::InvalidArgument; } NotImplemented_nid_no_patch(__func__); return 0; ``` **2. `sceUsbStorageRequestUnmap` and `sceUsbStorageGetdentsClose`** ([Export.cpp#L116](https://github.com/boykopovar/AnyPS5/blob/9e81ae3ff23f4563bfda7903b92fe8a554b1435d/core/libs/prx/libSceUsbStorage/Export.cpp#L116), [Export.cpp#L142](https://github.com/boykopovar/AnyPS5/blob/9e81ae3ff23f4563bfda7903b92fe8a554b1435d/core/libs/prx/libSceUsbStorage/Export.cpp#L142)) In this model nothing can be mapped or opened. Even so, `sceUsbStorageRequestUnmap(7, "/mnt/usb7")` and `sceUsbStorageGetdentsClose(1)` return 0. Meanwhile `sceUsbStorageGetdentsRead(1, ...)` on the same never-opened descriptor returns `0x80f40005`. shadPS4 does not establish these answers: - Its unmap keeps no state and only logs ([L281-L288](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L281-L288)). - Its close returns OK for an unknown descriptor only because `erase` ignores a missing key ([L378-L383](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L378-L383)). The no-device libraries already merged throw in this case. `sceMoveClose` throws for a handle that was never opened ([libSceMove/Export.cpp#L71](https://github.com/boykopovar/AnyPS5/blob/9a97ac784da5d40cc7b7d968898ffbf5b8b5377a/core/libs/prx/libSceMove/Export.cpp#L71)). `sceContentSearchCloseMetadata` throws because no metadata id is ever handed out ([libSceContentSearch.md#L9](https://github.com/boykopovar/AnyPS5/blob/9a97ac784da5d40cc7b7d968898ffbf5b8b5377a/docs/dev/debt/libSceContentSearch.md#L9)). I suggest throwing after the null check in both functions, dropping the two "answers 0" clauses from the debt entry at L16, and updating test lines 104-105 and 126-127. ```cpp std::int32_t APS5_VABI sceUsbStorageGetdentsClose(std::int32_t fd) { (void)fd; NotImplemented_nid_no_patch(__func__); return 0; } ``` **3. Sources in the debt file** ([libSceUsbStorage.md#L15](https://github.com/boykopovar/AnyPS5/blob/9e81ae3ff23f4563bfda7903b92fe8a554b1435d/docs/dev/debt/libSceUsbStorage.md#L15)) L15 says the prototypes follow shadPS4 L176-L383, but two of them match SharpProspero and not shadPS4. `sceUsbStorageRequestMap` takes 8 arguments here, as in [SharpProspero UsbStorage.cs#L235](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs#L235), while shadPS4's takes 6 ([L276-L277](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L276-L277)). `sceUsbStorageGetDeviceList` takes `std::int32_t* count`, as in SharpProspero ([L233](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs#L233)), while shadPS4 has `u32* count` ([L176](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L176)). L16 tells a future passthrough to follow shadPS4's 0x338-byte device-info record. That record has `u32 device_id` at offset 0 ([L33-L35](https://github.com/shadps4-emu/shadPS4/blob/f68923fe807f657348e6719ce658bcbd0a2b1c72/src/core/libraries/usbd/usbstorage.cpp#L33-L35)). SharpProspero recovered its layout from the module's `sceUsbStorageGetDeviceInfo`, and it has the u64 volume size at offset 0 ([L34-L45](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs#L34-L45), [L100](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs#L100)). #6288 was checked against that layout ("volume size at 0x0"). Filling the record the way shadPS4 does would put a device id where a title reads the volume size. I suggest these changes to the entry: - Cite SharpProspero at `5dfdb4b0` for these two prototypes and for the record layout. - Note that shadPS4 puts `device_id` at offset 0. - Start each entry with what is unverified, as [CONTRIBUTING.md](https://github.com/boykopovar/AnyPS5/blob/9a97ac784da5d40cc7b7d968898ffbf5b8b5377a/CONTRIBUTING.md#L73) asks ("An entry states the gap first").
ycbuzi commented 2026-10-21 07:35:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-21T07:35:22Z.


Windows run of 9e81ae3ff2 merged onto main b77bd58806 (e6b1b41e3c), the build the description lists as not done. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceUsbStorage and guest_usb_storage_tests with no errors or warnings; ctest --repeat until-fail:2 on guest_usb_storage: passes on both repeats. Not run: the negative control against main's library, a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310654402 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6310654402). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-21T07:35:22Z. --- Windows run of 9e81ae3ff2 merged onto `main` b77bd58806 (e6b1b41e3c), the build the description lists as not done. Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceUsbStorage` and `guest_usb_storage_tests` with no errors or warnings; `ctest --repeat until-fail:2` on `guest_usb_storage`: passes on both repeats. Not run: the negative control against `main`'s library, a title.
primesoul-web commented 2026-10-21 07:44:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-10-21T07:44:45Z.


All three points are adopted - thank you for the #6288 archaeology and the SharpProspero cross-check; both changed the PR for the better.

1. Callbacks. Your pattern is in verbatim: the six register/unregister exports keep their argument checks (the 0x80f40002 refusals) and throw NotImplemented_nid_no_patch past them, exactly as #6288's closure comment requires. The test lines you listed (43-44, 49-50, 56, 59, 62, 65) moved to throwing checks, and the exports drop out of the implemented count - the PR is now +9 (0/21 -> 9/21), not +17. The debt entry states the gap first: what a successful registration stores is unverified, shadPS4 logs all six as (STUBBED) and returns 0 without storing anything, and that success-without-a-reference pattern is what #6288 was closed for.

2. RequestUnmap and GetdentsClose. Both now throw after their argument validation, the two "answers 0" clauses are gone from the debt entry, and test lines 104-105 / 126-127 expect the markers. The entry records your reasoning: shadPS4's unmap only logs without state, its close succeeds only because erase ignores a missing key, and the no-device libraries throw on this path (sceMoveClose, sceContentSearchCloseMetadata).

3. Sources. The debt entry now cites SharpProspero @ 5dfdb4b0 for sceUsbStorageRequestMap's eight parameters and sceUsbStorageGetDeviceList's int32_t* count, and for the 0x338-byte device-info record - recovered from the module's own sceUsbStorageGetDeviceInfo and checked against #6288's "volume size at 0x0" - with the note that shadPS4's record starts with a u32 device id at offset 0, where a title reads the volume size. The remaining prototypes keep the shadPS4 citation, and every entry now states the gap first per CONTRIBUTING.md.

The branch is rebased onto current main 9be6ccf60 and squashed to a single commit (head b3bca1bc9). Re-measured on that base: main 4405/8805 (50.03%) -> with this PR 4414/8805 (50.13%), libSceUsbStorage 0/21 -> 9/21, no regressions. The guest test passes with the new expectations and still aborts on main's Export.cpp at the first marker.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310807347 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6310807347). Originally posted by [primesoul-web](https://github.com/primesoul-web) on 2026-10-21T07:44:45Z. --- All three points are adopted - thank you for the #6288 archaeology and the SharpProspero cross-check; both changed the PR for the better. **1. Callbacks.** Your pattern is in verbatim: the six register/unregister exports keep their argument checks (the `0x80f40002` refusals) and throw `NotImplemented_nid_no_patch` past them, exactly as #6288's closure comment requires. The test lines you listed (43-44, 49-50, 56, 59, 62, 65) moved to throwing checks, and the exports drop out of the implemented count - the PR is now +9 (0/21 -> 9/21), not +17. The debt entry states the gap first: what a successful registration stores is unverified, shadPS4 logs all six as `(STUBBED)` and returns 0 without storing anything, and that success-without-a-reference pattern is what #6288 was closed for. **2. `RequestUnmap` and `GetdentsClose`.** Both now throw after their argument validation, the two "answers 0" clauses are gone from the debt entry, and test lines 104-105 / 126-127 expect the markers. The entry records your reasoning: shadPS4's unmap only logs without state, its close succeeds only because `erase` ignores a missing key, and the no-device libraries throw on this path (`sceMoveClose`, `sceContentSearchCloseMetadata`). **3. Sources.** The debt entry now cites [SharpProspero @ 5dfdb4b0](https://github.com/SvenGDK/SharpProspero/blob/5dfdb4b0b166e83dc9ae275001afb695f12c7174/src/SharpProspero/Platform/UsbStorage.cs) for `sceUsbStorageRequestMap`'s eight parameters and `sceUsbStorageGetDeviceList`'s `int32_t*` count, and for the 0x338-byte device-info record - recovered from the module's own `sceUsbStorageGetDeviceInfo` and checked against #6288's "volume size at 0x0" - with the note that shadPS4's record starts with a u32 device id at offset 0, where a title reads the volume size. The remaining prototypes keep the shadPS4 citation, and every entry now states the gap first per CONTRIBUTING.md. The branch is rebased onto current `main` `9be6ccf60` and squashed to a single commit (head b3bca1bc9). Re-measured on that base: `main` 4405/8805 (50.03%) -> with this PR 4414/8805 (50.13%), libSceUsbStorage 0/21 -> 9/21, no regressions. The guest test passes with the new expectations and still aborts on `main`'s `Export.cpp` at the first marker.
primesoul-web commented 2026-10-21 07:47:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-10-21T07:47:16Z.


Thank you for the Windows run - that closes the "Windows was not compiled" line in the description for the revision you built: libSceUsbStorage and guest_usb_storage_tests built clean on MinGW-w64 GCC 15.2.0 and passed ctest --repeat until-fail:2, merged onto main b77bd58806.

One note for anyone re-running it: the head moved shortly after your run (b3bca1bc9, rebased onto current main 9be6ccf60) to adopt nikowolf123's review above - the six register/unregister callbacks, sceUsbStorageRequestUnmap and sceUsbStorageGetdentsClose now throw their markers past their argument validation instead of returning 0, and the test expectations changed with them (the throwing checks are text matches against the marker message, so they are host-independent; the callback pointer is passed as void* and never called, so no APS5_VABI involvement). Your build covers everything that did not change; a re-run against b3bca1bc9 would cover the reworked expectations too, but nothing in the change is Windows-sensitive.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6310849642 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6310849642). Originally posted by [primesoul-web](https://github.com/primesoul-web) on 2026-10-21T07:47:16Z. --- Thank you for the Windows run - that closes the "Windows was not compiled" line in the description for the revision you built: `libSceUsbStorage` and `guest_usb_storage_tests` built clean on MinGW-w64 GCC 15.2.0 and passed `ctest --repeat until-fail:2`, merged onto `main` b77bd58806. One note for anyone re-running it: the head moved shortly after your run (b3bca1bc9, rebased onto current `main` `9be6ccf60`) to adopt nikowolf123's review above - the six register/unregister callbacks, `sceUsbStorageRequestUnmap` and `sceUsbStorageGetdentsClose` now throw their markers past their argument validation instead of returning 0, and the test expectations changed with them (the throwing checks are text matches against the marker message, so they are host-independent; the callback pointer is passed as `void*` and never called, so no `APS5_VABI` involvement). Your build covers everything that did not change; a re-run against b3bca1bc9 would cover the reworked expectations too, but nothing in the change is Windows-sensitive.
primesoul-web commented 2026-10-21 15:20:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-10-21T15:20:48Z.


On the overlap the bot lists: #9137 retypes nine of this library's exports (the six register/unregister callbacks, GetDeviceInfo, IsExist, RequestMap) but keeps them as markers — no behavioral overlap with the no-device path here. Where its ABI signatures differ from the ones this PR built on, we take the sweep's when it lands: IsExist to the three-argument bool form, RequestMap to the six-argument form (the PR's eight parameters came from SharpProspero @ 5dfdb4b0 and the declarations already on main; the sweep and shadPS4 both say six), the callbacks to the typed UsbStorageCallback. Coordination note posted on the sweep: comment.

No Depends on on either side — there is no build-on dependency, and the branch is clean against current main cecb540a6 with all checks green on b3bca1bc9.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6319589716 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6319589716). Originally posted by [primesoul-web](https://github.com/primesoul-web) on 2026-10-21T15:20:48Z. --- On the overlap the bot lists: **#9137** retypes nine of this library's exports (the six register/unregister callbacks, `GetDeviceInfo`, `IsExist`, `RequestMap`) but keeps them as markers — no behavioral overlap with the no-device path here. Where its ABI signatures differ from the ones this PR built on, we take the sweep's when it lands: `IsExist` to the three-argument `bool` form, `RequestMap` to the six-argument form (the PR's eight parameters came from SharpProspero @ 5dfdb4b0 and the declarations already on `main`; the sweep and shadPS4 both say six), the callbacks to the typed `UsbStorageCallback`. Coordination note posted on the sweep: [comment](https://github.com/boykopovar/AnyPS5/pull/9137#issuecomment-6319588918). No `Depends on` on either side — there is no build-on dependency, and the branch is clean against current `main` `cecb540a6` with all checks green on `b3bca1bc9`.
primesoul-web commented 2026-10-22 07:49:50 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by primesoul-web on 2026-10-22T07:49:50Z.


The ABI sweep reached this library on main (fix(usbstorage): restore mapping callbacks and system service aliases), and head 4d98d9a2c adopts its signatures over the no-device path — exactly the adoption the coordination note on the sweep and the overlap reply above promised: the register/unregister family takes the typed UsbStorageCallback, sceUsbStorageGetDeviceInfo takes the forward-declared UsbStorageDeviceInfo*, sceUsbStorageIsExist takes the three-argument bool form (with no device attached it succeeds and reports non-existence — *exists = 0, return true — for every device id and directory), and sceUsbStorageRequestMap takes the sweep's six parameters, the trailing reserved pair SharpProspero's earlier reading carried being dropped.

The argument validation and the no-device answers are unchanged: the six callbacks still refuse a null callback, an event type outside 1 and 2, or a null directory with 0x80f40002 and then throw their markers, the map and getdents requests still answer 0x80f40004, and nothing is stored. The guest test passes an APS5_VABI callback now that the pointer is typed (the #8009 lesson), pins the exists out-parameter on all three IsExist rows, and the negative control still aborts on main's marker Export.cpp at sceUsbStorageInit. The debt entry's prototype bullet now cites the restored ABI (with SharpProspero kept for GetDeviceList's int32_t* count and the reserved-pair history).

Re-measured against main d6eafa54d: 4834/11181 (43.23%) -> 4843/11181 (43.31%), libSceUsbStorage 0/21 -> 9/21, +9, no regressions — the count is unchanged by the signature adoption. git merge-tree against main is clean; conventions all green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6335625380 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6335625380). Originally posted by [primesoul-web](https://github.com/primesoul-web) on 2026-10-22T07:49:50Z. --- The ABI sweep reached this library on `main` (`fix(usbstorage): restore mapping callbacks and system service aliases`), and head 4d98d9a2c adopts its signatures over the no-device path — exactly the adoption the coordination note on the sweep and the overlap reply above promised: the register/unregister family takes the typed `UsbStorageCallback`, `sceUsbStorageGetDeviceInfo` takes the forward-declared `UsbStorageDeviceInfo*`, `sceUsbStorageIsExist` takes the three-argument bool form (with no device attached it succeeds and reports non-existence — `*exists = 0`, return true — for every device id and directory), and `sceUsbStorageRequestMap` takes the sweep's six parameters, the trailing reserved pair SharpProspero's earlier reading carried being dropped. The argument validation and the no-device answers are unchanged: the six callbacks still refuse a null callback, an event type outside 1 and 2, or a null directory with `0x80f40002` and then throw their markers, the map and getdents requests still answer `0x80f40004`, and nothing is stored. The guest test passes an `APS5_VABI` callback now that the pointer is typed (the #8009 lesson), pins the `exists` out-parameter on all three `IsExist` rows, and the negative control still aborts on `main`'s marker `Export.cpp` at `sceUsbStorageInit`. The debt entry's prototype bullet now cites the restored ABI (with SharpProspero kept for `GetDeviceList`'s `int32_t*` count and the reserved-pair history). Re-measured against `main` d6eafa54d: 4834/11181 (43.23%) -> 4843/11181 (43.31%), libSceUsbStorage 0/21 -> 9/21, +9, no regressions — the count is unchanged by the signature adoption. `git merge-tree` against `main` is clean; conventions all green.
ycbuzi commented 2026-10-22 08:21:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ycbuzi on 2026-10-22T08:21:59Z.


Windows run of 4d98d9a2cd, the signature-adoption update (it already contains main d6eafa54d0). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, BUILD_TESTING=ON.

Built libSceUsbStorage and guest_usb_storage_tests with no errors or warnings. ctest --repeat until-fail:2 on guest_usb_storage: passes on both repeats. The negative control, which my earlier run left out: with core/libs/prx/libSceUsbStorage/Export.cpp taken from main and the rest of this head, the same test aborts with sceUsbStorageInit not implemented (exit code 0xc0000409). Not run: a title.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6336202133 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8399#issuecomment-6336202133). Originally posted by [ycbuzi](https://github.com/ycbuzi) on 2026-10-22T08:21:59Z. --- Windows run of 4d98d9a2cd, the signature-adoption update (it already contains `main` d6eafa54d0). Windows 11 Home 10.0.26200, MinGW-w64 GCC 15.2.0 (ucrt-posix-seh r7), Release, `BUILD_TESTING=ON`. Built `libSceUsbStorage` and `guest_usb_storage_tests` with no errors or warnings. `ctest --repeat until-fail:2` on `guest_usb_storage`: passes on both repeats. The negative control, which my earlier run left out: with `core/libs/prx/libSceUsbStorage/Export.cpp` taken from `main` and the rest of this head, the same test aborts with `sceUsbStorageInit not implemented` (exit code `0xc0000409`). Not run: a title.
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!8399
No description provided.