fix(libSceSaveData.native): count PS5 save data in 64 KiB blocks, at most 16384 #7960
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7960"
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 Lindamea1 on 2026-10-19T16:06:28Z.
What
libSceSaveData.nativecounts save data in PS4 units.SAVE_DATA_BLOCK_BYTESis 32768 andSAVE_DATA_BLOCKS_MAXis 32768: the PS4's 32 KiB block and the top of its 96 to 32768-block range (shadPS4savedata.cpp). SharpEmu uses a 64 KiB block, and SharpEmu and KytyPS5 allow 48 to 16384 blocks per save, which at 64 KiB a block is 3 MiB to 1 GiB, the PS4's byte range:SaveDataExports.cssets 65536, 16384 and 48, and counts used blocks in 64 KiB. It rounds the save's total size once, while this module rounds each file.libSaveData.cppsets 48 and 16384, and itssceSaveDataMount3rejects a creating mount outside that range. It has no block size and reports all of a save's blocks as free, so the 64 KiB block comes from SharpEmu alone.On
main, thesceSaveDataDirNameSearchinfos andsceSaveDataGetMountInfotherefore count up to twice the 64 KiB blocks a save's files use. A save without a recorded size reports 32768 blocks, which is 2 GiB at 64 KiB a block. A scratch program run againstmain5eba12d6bcreates a save withsceSaveDataMount3(blocks48, mode0x21), writes a 1,000,000-byte file, unmounts and searches. The search returnsblocks=48 free=17, so 31 blocks are used. With 64 KiB blocks the file takes 16 and leaves 32 free.Titles read these counts as 64 KiB blocks:
blocks - free_blocksandfree_blocksback to bytes at 65536 bytes a block. For the save above, that gives 2,031,616 used and 1,114,112 free bytes onmain, and 1,048,576 and 2,097,152 with this change. What the title does with the two byte counts was not traced. It still shows only a flat grey screen (#7852), so no visible effect is known.blocksas 64 KiB each. #5173 read this out of the title with gdb: five saves at the 32768-block maximum summed to 10 GiB against a 9 GiB budget.This change:
SAVE_DATA_BLOCK_BYTESto 65536 andSAVE_DATA_BLOCKS_MAXto 16384. Each file is rounded up to 64 KiB blocks, and a save without a recorded size reports 16384.blocksabove 16384 is now kept as 16384 (the existing clamp was at 32768), as SharpEmu clamps it. A save already recorded above 16384 now reports 16384.sceSaveDataDirNameSearchdebt entry into its own entry forsceSaveDataDirNameSearch,sceSaveDataGetMountInfoandsceSaveDataMount3, which states the gaps first. Both entries stay under 1000 characters.Not measured on a console. The console's file system overhead is not counted. A
blocksabove 16384 is clamped to 16384 and a non-zero one below 48 is kept as given, where KytyPS5 rejects such a creating mount; what the console does is unknown.Interplay with #7780 (open): it builds
libSceSaveData, which PS4 titles import, from these sources. With both merged, that module would also count 64 KiB blocks up to 16384, while PS4 saves use 32 KiB blocks up to 32768 (shadPS4 above;SD_BLOCKS_MAXis 32768 in theSaveDataCore.hppthat #7780 removes). OnmainonlylibSceSaveData.nativeis built from these sources, so the values stay constants in the module. Whichever of the two merges second can give the PS4 target its own values, for example as compile definitions set in #7780'sSaveDataLibrary.cmake. #6977 (open) adds a PS4sceSaveDataMountto this module itself, and it passes the title'sblocks, counted in 32 KiB, tosceSaveDataMount3unchanged. With this change those would be read as 64 KiB blocks.Tested
Gentoo Linux, kernel 7.2.8, GCC 16.2.1, glibc 2.43, Ninja, Release,
BUILD_TESTING=ON, onmaind047690c6.guest_savedata_search(core/libs/tests/GuestSaveDataSearch.cpp) now checks:sceSaveDataGetMountInfo(was 94).MountInfohelper that the new checks share.Export.cppandSaveData.hppfrommain, the test fails withsearch info must report the save's blocks and free blocks. In a scratch copy of the test,Requirereports and continues. That copy shows each of the 5 changed or new assertions failing on themainsources and every other assertion passing.Export.cppfrommain, the test fails witha save must report the blocks it was created with, less those its files take. The mount-info and 64 KiB checks fail too.SaveData.hppfrommain, it fails at the unsized-save check, and the 16384 check fails too.blocks=48 free=32.tools/select_tests.pyas CI selects them: 219 passed, 0 failed, 0 skipped. They include the sixguest_savedata_*tests oflibSceSaveData.native, the foursavedata_memory_*tests,savedata_native_write_replacementandpatched_libraries.tools/check_compile.py --base upstream/main: 2 translation units compile.Export.cppandGuestSaveDataSearch.cppcompile without warnings withx86_64-w64-mingw32-g++16.2.0-fsyntax-only -Wall -Wextra, as onmain. This is a syntax check, not a Windows build or run.tools/check_conventions.py --base upstream/mainwith this title and body: all checks passed.tools/pr_overlap.py --branchreports no overlapping lines. It could not compare #6044, #6879 and #6977, which conflict withmain; merged with this branch, #6879 and #6977 conflict in the same files as they do withmain, and #7780 merges cleanly.Not run on Windows, macOS or a console.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T16:25:59Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/tests/GuestSaveDataSearch.cppcore/libs/prx/libSceSaveData.native/Export.cpp