feat(libSceSaveData): implement sceSaveDataCheckBackupData, sceSaveDataRestoreBackupData and sceSaveDataUmountWithBackup #12748
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12748"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-29T07:28:21Z.
What
The three were parameterless declarations that threw through
NotImplemented_nid_no_patch. They now take shadPS4's signatures and do what its PS4 binding does, on this library's save store.sceSaveDataCheckBackupData, with its block layout;sceSaveDataRestoreBackupDataand itsRestore, with its block layout;sceSaveDataUmountWithBackup, which isUmountfollowed by a backup and aUMOUNT_BACKUPevent. fpPS4's version unmounts and posts the event.SAVE_DATA_ERROR_NOT_INITIALIZEDbefore initialization;PARAMETERfor a null block or directory name;BUSYwhile the save is mounted;NOT_FOUNDwhen there is no backup;paramfilled from the backup.INTERNALwhen the save directory is missing, the backup's metadata is incomplete or the wrong size, or a file call fails._sd_restore_tmp/<dir name>, checked complete and flushed. The live save then moves to_sd_restore_old/<dir name>and the copy into place, and a failed move puts back what had moved, so a failed restore leaves the save as it was.NOT_INITIALIZEDbefore initialization, andPARAMETERfor a null mount point;sceSaveDataGetEventResult;INTERNAL, as shadPS4's backup thread does, and the call still returns 0.libSceSaveData.native.md's debt entries:NOT_MOUNTED, assceSaveDataUmount2does here, where shadPS4 returnsNOT_FOUND;BACKUP_BUSYnever occurs and the event is queued at once, as in fpPS4;titleIdreturnsNOT_FOUND, because only the running title's saves are kept;icon. shadPS4 does the same when there's noicon0.png._sd_backup/<dir name>, outside the save, so the title's mount and its block count don't see them._sd_backup_tmp, flushed, and swapped in through_sd_backup_old, like shadPS4'ssce_backup_tmpandsce_backup_old. A failed swap puts the previous backup back.INTERNALwith nothing changed.sceSaveDataDeleteremoves a save's backup along with the save. In shadPS4 the backup lives inside the save directory that Delete removes.mount3,deleteSaveandconverteach had their own copy of the directory-name check. They and the two new functions now call one helper, with the same rules.MountSlotnow keeps the mounting user, for the event.PARAMETERfor aparambuffer that isn't zeroed, is a debt entry, since which bytes the console checks isn't known.sceSaveDataBackupdoesn't copy yet, so the check and the restore see only backups thatsceSaveDataUmountWithBackupmade (also in the debt entry). Making it use the same copy is a follow-up.Tested
guest_savedata_mount_status, 37 new checks:sceSaveDataInitialize3, all three calls returnNOT_INITIALIZED;PARAMETERfor a null block or directory name, and for a null mount point;NOT_FOUNDfor a save with no backup, andBUSYfor a mounted one, from both the check and the restore;sceSaveDataUmountWithBackupreturns 0 and unmounts.sceSaveDataGetEventResultthen gives type 1, error 0, user 7, titlePPSA00000and directorykept;paramwith the backed-up title, also when it is given the running title's ID;data.binis changed,added.binis added and the title is changed, the restore puts backdata.bin, removesadded.binand puts back the title;NOT_FOUND.main's library code with only the three signatures changed so it builds: the test aborts withsceSaveDataCheckBackupData not implemented.sceSaveDataDelete: only "deleting a save deletes its backup" fails.guest_savedata_*,savedata_*) ran 10 times: 130 passed, 0 skipped, 0 failed.main's code doesn't build the new cases, because its stubs take no parameters.check_test_registration.pypasses, and no comment lines are added.check_conventions.py: one warning, the debt-length check on the pending list inlibSceSaveData.native.md. That list is a single line and was already over the limit onmain. This change removes three names from it, so it gets shorter, from 6,140 to 5,870 characters.-fsyntax-only:Export.cppand the test show no new diagnostics.b17c475af5, six commits after oneandonlydean's review:26a50dd0fdvalidates the backup's metadata before the check and the restore read it;637b601bfbrestores through a staged copy and rolls back a failed swap;1744dbf5abputs the old backup back when the backup swap fails, and flushes before removing it;9429d8395bkeeps save and backup paths inside their roots;eff8683d05adds the coverage cases;b17c475af5says in the debt entries how a failed restore or a crash leaves the save.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.ctest -V, 2 runs) shows no case skipped on either runner, so the junction and reparse-point cases ran on Windows and the symlink cases on Linux.libSceSaveData.sprx(SDK 0x05050001), the shadPS4 structures and a zeroed 1,328-byteparam. It agrees with this PR on every row it covers:NOT_FOUNDwith no save or backup, for another title's id or another directory, and aftersceSaveDataDelete, so the delete takes the backup with it;BUSYwhile the save is mounted, beforeNOT_FOUND;NOT_MOUNTEDfromsceSaveDataUmountWithBackupfor a mount point that is no longer mounted;PARAMETERfor aparamfilled with 0xAA, also with a backup present, and 0 for a zeroed or null one. Which bytes it checks wasn't measured, sobb346f7cadrecords it as a debt entry, with the delete and other-title rows, and the code is unchanged. The events weren't measured, and this is a PS4, not a PS5.22291cddd8, a merge ofmain91a69952c1(run). Four of themainchanges it brings touch this PR's files: slopgobblercobbler's #12644, ionut27001's #11720, al3w0f205's #12220 and xXPBSXx's #12600.sceSaveDataBackup's directory name.GuestSaveDataMountStatus.cpp, #12644 adds its backup checks at the end ofCheckUnmountedCalls, where this PR adds its threeNOT_INITIALIZEDchecks. The merge keeps both: #12644's checks first, then this PR's.docs/dev/debt/libSceSaveData.native.md, #12644 adds an entry forsceSaveDataBackup's unterminated directory name where this PR adds its entries for the three backup calls. The merge keeps #12644's entry, then this PR's.check_conventions.py'sdebt-lengthwarning on line 19 ismain's pending-declarations entry: 6,140 characters onmain, 5,870 here after this PR removes the three names it implements.^guest_savedata, 7 tests.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.46c8ff27a6, a merge ofmain8c8b998620(run), which brings SnekPolylepis's #12699 (sceSaveDataAbort,sceSaveDataClearProgressand the mounted-save count).GuestSaveDataMountStatus.cppand one indocs/dev/debt/libSceSaveData.native.md, all with #12699. The merge keeps both sides:CheckMountCapacityAndLifecycle;main(), this PR's backup checks run before #12699's closingsceSaveDataTerminatechecks;sceSaveDataAbort,sceSaveDataClearProgressandsceSaveDataGetMountedSaveDataCount. 60 names remain.SaveDataErrorNotInitializedconstant this PR's test added, so that line is nowmain's. This PR's other added and removed lines are unchanged.^guest_savedata, 7 tests.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.842f75d7e0, a merge ofmain7fcab08f71, which brings JJenkx's #13324 (run).isMountedDirectoryanstd::error_codeparameter, and this PR's two new calls, incheckBackupDataandrestoreBackupData, no longer compiled onmain. The merge passes one, asmain's callers do, so Check and Restore now returnSAVE_DATA_ERROR_INTERNALon a host filesystem error instead of throwing, consistent with #13324.CheckBackupsnow writes param.json at the resolved/app0path, since #13324's test fixes the guest root in a subdirectory first.^guest_savedata_and^savedata_,guest_savedata_mount_statusamong them.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.9b9e850d90, oneandonlydean's merge ofmaind8b60b46ed, which brings DealPotato's #8285 (sceSaveDataMount2) and the host free-space checks inmount3.libSceSaveData.native/Export.cpp's include block, where #8285 adds<string_view>beside this PR's includes. Both are kept.mount3, which both sides change, merged on its own and composes:mainreads the free-space mode first and refuses a new save the host volume can't hold, and this PR'sparse_dir_nameand the slot'suser_idstay. #8285'smount2passesuser_idthrough to it.guest_savedata_*tests,main's and this PR's. Linux: 8 run, 8 pass, 0 skip, 0 fail. Windows: 8 run, 8 pass, 0 skip, 0 fail. The libc and libkernel suites run 208 and 309 tests on Linux and 235 and 330 on Windows, with 0 failed. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.23493d9ca3, oneandonlydean's merge ofmain24238c4cb1. The one conflict was the pending-declarations list indocs/dev/debt/libSceSaveData.native.md: MarcZX10's #10674 movessceSaveDataGetProgressout of it into its own entry, and the merge keeps that with this PR's removal of its three calls. This PR's diff overmainis unchanged. On GitHub's runners (run, on 5a7a8f34dc, a merge ofmain3c3b3cda73with the same resolution;main's later commits change only a cmake line and two debt files outside this PR), the^guest_savetests withguest_savedata_mount_statusran 10 times with no failure. Linux: 8 run, 8 pass, 0 skip, 0 fail. Windows: 8 run, 8 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (214 and 316) and on Windows (241 and 337). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.02af078a35, oneandonlydean's merge ofmainb28bb77217. The one conflicting file wasdocs/dev/debt/libSceSaveData.native.md. The merge keepsmain'ssceSaveDataGetProgressentry, which xecedemon's #15077 extends, and the unterminated-mount-point sentence that slopgobblercobbler's #12853 adds to the null-pointer entry, with this PR's removal of its three calls and its new entries. #12853 and slopgobblercobbler's #12846 changelibSceSaveData.native/Export.cpptoo, and those merged without conflicts.mainare identical to those in 3547c39f11, our merge ofmainf06d7fdcee, which ran ×10 on GitHub's runners (run): the^guest_savetests withguest_savedata_mount_status. Linux: 8 run, 8 pass, 0 skip, 0 fail. Windows: 8 run, 8 pass, 0 skip, 0 fail. Suites: libc and libkernel pass on Linux (217 and 318) and on Windows (244 and 339). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.02af078a35itself, #13551, which is stacked on this PR, ran its nineguest_savedata_*tests 10 times with no failure on both runners (run).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)mainkeeps both sets of removals and its new entry. Any order with fogydes's #15042, for merge order only: inconvertinlibSceSaveData.native/Export.cpp, #15042 checks its own copy of the directory name and this PR readsparam->dir_namethroughparse_dir_name. Whichever lands second runsparse_dir_nameon #15042's copy.