feat(savedata): add sceSaveDataMount2 #8285

Merged
DealPotato merged 7 commits from upstream-pr/8285 into main 2026-11-01 14:22:26 +00:00
DealPotato commented 2026-10-20 08:37:48 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by DealPotato on 2026-10-20T08:37:48Z.


What

Adds sceSaveDataMount2, the save-data mount PS4 titles built with SDK 2.00 and later call. Its SceSaveDataMount2 is SceSaveDataMount3 without the system blocks and the resource field (user ID, directory name, blocks, mount mode), so the function converts the parameters and mounts through sceSaveDataMount3.

Before that it answers the cases where a PS4 Pro (firmware 10.71) answered differently from Mount3, as @ntamas94 measured on this PR:

  • SAVE_DATA_ERROR_NOT_INITIALIZED before sceSaveDataInitialize3;
  • SAVE_DATA_ERROR_INVALID_LOGIN_USER for user IDs -1 and 0;
  • SAVE_DATA_ERROR_PARAMETER for mount mode 0, for a directory name with _, and for creating a save of fewer than 96 blocks. The block minimum applies to CREATE only, because CREATE2 was not measured.

A null mount or result is SAVE_DATA_ERROR_PARAMETER, as main's sceSaveDataMount answers it. Otherwise the result, the mount point and the error codes are Mount3's. A lowercase directory name is accepted, because a retail title mounts one (inFAMOUS Second Son mounts infamousssAuto0).

SaveDataMount2 in SceTypes.hpp has the PS4 layout (64 bytes; dir_name at 8, blocks at 16, mount_mode at 24), which the test asserts. The sceSaveDataMount2 entry in docs/dev/debt/libSceSaveData.native.md notes that these are PS4 rows, not measured on a PS5.

Tested

Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (MinGW-w64), Release, on this branch merged with main 5b8ba7b929:

  • ctest -R "savedata|save_data|guest_kernel_error|public_headers": 79 of 79 pass.
  • guest_savedata_ps4 covers these sceSaveDataMount2 cases:
    • NOT_INITIALIZED before initialization;
    • creating a missing save (status 1, a mount point, the directory made);
    • BUSY for a second mount, and unmounting with sceSaveDataUmount2;
    • opening an existing save (status 0), and CREATE2 with 0 blocks opening it;
    • NOT_FOUND for a missing save;
    • PARAMETER for a null mount, a null result, mount mode 0, fewer than 96 blocks on create, and an underscore in the name, with no directory made for a refused create;
    • a mixed-case name mounting;
    • INVALID_LOGIN_USER for user IDs -1 and 0.
  • core/libs/tests/test_public_headers.py --audit-only: passes.
  • tools/check_conventions.py: all checks pass.

inFAMOUS Second Son (CUSA00004, my own dump) calls it to open its saves. On a local stack of main with the open PS4 PRs, the title mounts its save, loads it and reaches the open world.

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 (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4933211457 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8285). Originally posted by [DealPotato](https://github.com/DealPotato) on 2026-10-20T08:37:48Z. --- ### What Adds `sceSaveDataMount2`, the save-data mount PS4 titles built with SDK 2.00 and later call. Its `SceSaveDataMount2` is `SceSaveDataMount3` without the system blocks and the resource field (user ID, directory name, blocks, mount mode), so the function converts the parameters and mounts through `sceSaveDataMount3`. Before that it answers the cases where a PS4 Pro (firmware 10.71) answered differently from Mount3, as @ntamas94 measured on this PR: - `SAVE_DATA_ERROR_NOT_INITIALIZED` before `sceSaveDataInitialize3`; - `SAVE_DATA_ERROR_INVALID_LOGIN_USER` for user IDs -1 and 0; - `SAVE_DATA_ERROR_PARAMETER` for mount mode 0, for a directory name with `_`, and for creating a save of fewer than 96 blocks. The block minimum applies to CREATE only, because CREATE2 was not measured. A null mount or result is `SAVE_DATA_ERROR_PARAMETER`, as main's `sceSaveDataMount` answers it. Otherwise the result, the mount point and the error codes are Mount3's. A lowercase directory name is accepted, because a retail title mounts one (inFAMOUS Second Son mounts `infamousssAuto0`). `SaveDataMount2` in `SceTypes.hpp` has the PS4 layout (64 bytes; `dir_name` at 8, `blocks` at 16, `mount_mode` at 24), which the test asserts. The `sceSaveDataMount2` entry in `docs/dev/debt/libSceSaveData.native.md` notes that these are PS4 rows, not measured on a PS5. ### Tested Windows 11 Pro 10.0.26300, WinLibs GCC 15.2.0 (MinGW-w64), Release, on this branch merged with `main` 5b8ba7b929: - `ctest -R "savedata|save_data|guest_kernel_error|public_headers"`: 79 of 79 pass. - `guest_savedata_ps4` covers these `sceSaveDataMount2` cases: - NOT_INITIALIZED before initialization; - creating a missing save (status 1, a mount point, the directory made); - BUSY for a second mount, and unmounting with `sceSaveDataUmount2`; - opening an existing save (status 0), and CREATE2 with 0 blocks opening it; - NOT_FOUND for a missing save; - PARAMETER for a null mount, a null result, mount mode 0, fewer than 96 blocks on create, and an underscore in the name, with no directory made for a refused create; - a mixed-case name mounting; - INVALID_LOGIN_USER for user IDs -1 and 0. - `core/libs/tests/test_public_headers.py --audit-only`: passes. - `tools/check_conventions.py`: all checks pass. inFAMOUS Second Son (CUSA00004, my own dump) calls it to open its saves. On a local stack of `main` with the open PS4 PRs, the title mounts its save, loads it and reaches the open world. ### 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 (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
harisibrar1 commented 2026-10-24 15:40:58 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by harisibrar1 on 2026-10-24T15:40:58Z.

Review: COMMENTED


Checked against main b607bfdc8b, #7780's file list at 797e2b97, and ntamas94's PS4 rows above:

  • The PR conflicts with main in core/libs/CMakeLists.txt (new guest_np_cpp_web_api_signed_out_tests next to the removed core test block) and core/libs/tests/GuestSaveDataPs4.cpp (#9433's TestSaveDataMemoryV1/TestMountPs4). Main also exports sceSaveDataUmount now, so after the #7780 hold the unmount-dependent PS4 rows could be compared too.
  • On the removed savedata_core_write_replacement registration: it comes from #7780. As far as I can tell, coverage of the remaining code is kept: the test file is unchanged on main, the native variant keeps the same assertions, and the removed variant only covered SaveDataCore.hpp, which is deleted. Every export from main's core libSceSaveData/libSceSaveDataDialog exists in the native sources plus this PR; the only thing no longer exercised is linking the libSceSaveData target itself.
  • mount2 only uses mount3, g_initializations and error constants already on main, so most of this diff (the CMake restructure, the core deletion, the pending declarations) is #7780's. It would be easier to review as just the Mount2 commit on top of #7780 once that settles.
  • ntamas94's follow-up shows the PS4 refuses survey_test and SURVEY_TEST for the underscore (0x809f0000). On this branch, mount3 only rejects /\: and ./.. (Export.cpp:623), so sceSaveDataMount2 with "survey_test" still returns 0 and creates the directory. Could Mount2 reject _, or could this go in debt?
  • The measured user ids -1 and 0 (0x809f0011 on PS4) aren't handled either; user_id is passed through unchecked.
  • The 96-block minimum was measured with mode 0x6 (CREATE), but mount2 applies it to CREATE2 as well (Export.cpp:674-675). With an existing save, mode 0x22 and blocks 0, this now returns PARAMETER where mount3 would open the save. Could the check be limited to CREATE until CREATE2 is measured, or noted in debt?
  • There's no sceSaveDataMount2 entry in docs/dev/debt/libSceSaveData.native.md. The three items above, and the fact that these checks are PS4 rows not measured on a PS5, would fit there.

Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638819874 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/8285#pullrequestreview-5638819874). Originally posted by [harisibrar1](https://github.com/harisibrar1) on 2026-10-24T15:40:58Z. **Review:** COMMENTED --- Checked against main b607bfdc8b, #7780's file list at 797e2b97, and ntamas94's PS4 rows above: - The PR conflicts with main in `core/libs/CMakeLists.txt` (new `guest_np_cpp_web_api_signed_out_tests` next to the removed core test block) and `core/libs/tests/GuestSaveDataPs4.cpp` (#9433's `TestSaveDataMemoryV1`/`TestMountPs4`). Main also exports `sceSaveDataUmount` now, so after the #7780 hold the unmount-dependent PS4 rows could be compared too. - On the removed `savedata_core_write_replacement` registration: it comes from #7780. As far as I can tell, coverage of the remaining code is kept: the test file is unchanged on main, the native variant keeps the same assertions, and the removed variant only covered `SaveDataCore.hpp`, which is deleted. Every export from main's core `libSceSaveData`/`libSceSaveDataDialog` exists in the native sources plus this PR; the only thing no longer exercised is linking the `libSceSaveData` target itself. - `mount2` only uses `mount3`, `g_initializations` and error constants already on main, so most of this diff (the CMake restructure, the core deletion, the pending declarations) is #7780's. It would be easier to review as just the Mount2 commit on top of #7780 once that settles. - ntamas94's follow-up shows the PS4 refuses `survey_test` and `SURVEY_TEST` for the underscore (0x809f0000). On this branch, mount3 only rejects `/\:` and `.`/`..` (Export.cpp:623), so `sceSaveDataMount2` with "survey_test" still returns 0 and creates the directory. Could Mount2 reject `_`, or could this go in debt? - The measured user ids -1 and 0 (0x809f0011 on PS4) aren't handled either; `user_id` is passed through unchecked. - The 96-block minimum was measured with mode 0x6 (CREATE), but `mount2` applies it to CREATE2 as well (Export.cpp:674-675). With an existing save, mode 0x22 and blocks 0, this now returns PARAMETER where mount3 would open the save. Could the check be limited to CREATE until CREATE2 is measured, or noted in debt? - There's no `sceSaveDataMount2` entry in `docs/dev/debt/libSceSaveData.native.md`. The three items above, and the fact that these checks are PS4 rows not measured on a PS5, would fit there. Reviewed with AI assistance (Claude Code); the checks above were run locally on my machine.
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!8285
No description provided.