fix(savedata): leave the mount result untouched when sceSaveDataMount3 fails #4876

Merged
EagleBearerYS merged 2 commits from upstream-pr/4876 into main 2026-10-14 01:33:00 +00:00
EagleBearerYS commented 2026-10-13 01:21:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-13T01:21:29Z.


What

Animal Well (PPSA22520, content 01.000.011) saves its progress outside its save directory, and a save placed in the save directory is never loaded. sceSaveDataMount3 cleared the caller's result before its checks, and the title depends on the result surviving a failed mount:

  • Its "save exists" check mounts SAVEDATA (CREATE2), stats <mount point>/save and never unmounts.
  • The load and save routines then mount SAVEDATA again into the same global result. They ignore every error except NO_SPACE (0x809F000A) and use the result's mount point for sceSaveDataPrepare, open("<mount point>/save", O_RDWR | O_CREAT ...) and the final sceSaveDataUmount2.
  • On main, that second mount returns BUSY with the mount point cleared. The title then opens /save (the game folder) and calls sceSaveDataUmount2 with an empty mount point (NOT_MOUNTED), so the first mount is never released:
[SAVEDATA:native] mount3 user=268435456 dir=SAVEDATA mode=0x20 blocks=48 -> 0x00000000 point=/savedata0 status=0
[SAVEDATA:native] mount3 user=268435456 dir=SAVEDATA mode=0x20 blocks=48 -> 0x809f0003 point= status=0
[SAVEDATA:native] umount2 mode=0x0 point= -> 0x809f0004

The result is now cleared and written only when the mount succeeds, as shadPS4's saveDataMount does (it returns BUSY for an already mounted directory before writing mount_result). Every error return (BUSY, EXISTS, NOT_FOUND, MOUNT_FULL) leaves it as it was. The title ships with this save flow and saves on the console, so the console's sceSaveDataMount3 evidently leaves the mount point in place on BUSY as well. A technical debt entry records that this follows shadPS4 and the title, not a hardware run.

Tested

  • Windows 11, WinLibs GCC 15.2.0 r7, Release, on main 43e3a70f8: guest_savedata_mount_status. The new check mounts a save, mounts it again into the same result (BUSY, result unchanged), opens a missing save into it (NOT_FOUND, result unchanged), then unmounts through the kept mount point.
    • With main's Export.cpp the three new checks fail.
    • With the change, all 13 save data tests pass 5/5.
  • Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration, main 43e3a70f8): with main's Export.cpp the same three checks fail; with the change, 20/20 pass.
  • PPSA22520 on Windows 11 (RTX 3070 Laptop GPU), on main 43e3a70f8 with #4859 (the title needs it to boot), #4693 and #4410, with the save in _sd/SAVEDATA/save:
    • Without the change, Continue does not load it: the title creates an empty save in the game folder and shows the new-game slot select.
    • With the change, Continue loads it, and saving at the telephone rewrites _sd/SAVEDATA/save (mount3 ... -> 0x00000000 point=/savedata0, umount2 point=/savedata0 -> 0x00000000). Nothing is written to the game folder.
    • On main 495bf91a0, which now has #4859, with nothing else applied: without this change the trace shows mount3 ... mode=0x20 -> 0x809f0003 point= and umount2 mode=0x0 point= -> 0x809f0004, the title opens /save (creating an empty save in the game folder) and the slot select shows; with it, the title opens /savedata0/save, Continue loads the save, saving rewrites _sd/SAVEDATA/save, and every successful mount is unmounted.
  • python3 tools/check_conventions.py --base origin/main: passed.
  • Open PR #3950 also changes mount3 (at its end): Export.cpp merges cleanly with it.

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
  • Unblocks: PPSA22520 #966
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4836999937 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4876). Originally posted by [EagleBearerYS](https://github.com/EagleBearerYS) on 2026-10-13T01:21:29Z. --- ### What Animal Well (PPSA22520, content 01.000.011) saves its progress outside its save directory, and a save placed in the save directory is never loaded. `sceSaveDataMount3` cleared the caller's result before its checks, and the title depends on the result surviving a failed mount: - Its "save exists" check mounts `SAVEDATA` (`CREATE2`), `stat`s `<mount point>/save` and never unmounts. - The load and save routines then mount `SAVEDATA` again into the same global result. They ignore every error except NO_SPACE (`0x809F000A`) and use the result's mount point for `sceSaveDataPrepare`, `open("<mount point>/save", O_RDWR | O_CREAT ...)` and the final `sceSaveDataUmount2`. - On `main`, that second mount returns BUSY with the mount point cleared. The title then opens `/save` (the game folder) and calls `sceSaveDataUmount2` with an empty mount point (NOT_MOUNTED), so the first mount is never released: ``` [SAVEDATA:native] mount3 user=268435456 dir=SAVEDATA mode=0x20 blocks=48 -> 0x00000000 point=/savedata0 status=0 [SAVEDATA:native] mount3 user=268435456 dir=SAVEDATA mode=0x20 blocks=48 -> 0x809f0003 point= status=0 [SAVEDATA:native] umount2 mode=0x0 point= -> 0x809f0004 ``` The result is now cleared and written only when the mount succeeds, as shadPS4's `saveDataMount` does (it returns BUSY for an already mounted directory before writing `mount_result`). Every error return (BUSY, EXISTS, NOT_FOUND, MOUNT_FULL) leaves it as it was. The title ships with this save flow and saves on the console, so the console's `sceSaveDataMount3` evidently leaves the mount point in place on BUSY as well. A technical debt entry records that this follows shadPS4 and the title, not a hardware run. ### Tested - Windows 11, WinLibs GCC 15.2.0 r7, Release, on `main` 43e3a70f8: `guest_savedata_mount_status`. The new check mounts a save, mounts it again into the same result (BUSY, result unchanged), opens a missing save into it (NOT_FOUND, result unchanged), then unmounts through the kept mount point. - With `main`'s `Export.cpp` the three new checks fail. - With the change, all 13 save data tests pass 5/5. - Linux (WSL2 Ubuntu 24.04, GCC 13.3, CI configuration, `main` 43e3a70f8): with `main`'s `Export.cpp` the same three checks fail; with the change, 20/20 pass. - PPSA22520 on Windows 11 (RTX 3070 Laptop GPU), on `main` 43e3a70f8 with #4859 (the title needs it to boot), #4693 and #4410, with the save in `_sd/SAVEDATA/save`: - Without the change, Continue does not load it: the title creates an empty `save` in the game folder and shows the new-game slot select. - With the change, Continue loads it, and saving at the telephone rewrites `_sd/SAVEDATA/save` (`mount3 ... -> 0x00000000 point=/savedata0`, `umount2 point=/savedata0 -> 0x00000000`). Nothing is written to the game folder. - On `main` 495bf91a0, which now has #4859, with nothing else applied: without this change the trace shows `mount3 ... mode=0x20 -> 0x809f0003 point=` and `umount2 mode=0x0 point= -> 0x809f0004`, the title opens `/save` (creating an empty `save` in the game folder) and the slot select shows; with it, the title opens `/savedata0/save`, Continue loads the save, saving rewrites `_sd/SAVEDATA/save`, and every successful mount is unmounted. - `python3 tools/check_conventions.py --base origin/main`: passed. - Open PR #3950 also changes `mount3` (at its end): `Export.cpp` merges cleanly with it. ### 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](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] Unblocks: PPSA22520 #966 - [x] AI-assisted: yes
xXPBSXx commented 2026-10-13 11:51:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T11:51:45Z.


Windows test: head 4ccf88829 merged onto current main 5d50886ee, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, -j2: full build 0 errors; ctest for the tests this change adds or touches: guest_savedata_mount_status passed; python tools/check_conventions.py --base upstream/main passed for the combined tree. I did not run the new tests against main without the change.

AI-assisted (Claude Code).

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6144912258 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/4876#issuecomment-6144912258). Originally posted by [xXPBSXx](https://github.com/xXPBSXx) on 2026-10-13T11:51:45Z. --- Windows test: head `4ccf88829` merged onto current `main` `5d50886ee`, together with 9 other open pull requests in one build (the merges were conflict-free); a failure would have been bisected per PR. Windows 10, MinGW GCC (WinLibs), Ninja Release, `-j2`: full build 0 errors; ctest for the tests this change adds or touches: guest_savedata_mount_status passed; `python tools/check_conventions.py --base upstream/main` passed for the combined tree. I did not run the new tests against `main` without the change. AI-assisted (Claude Code).
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!4876
No description provided.