diff --git a/src/core/libraries/save_data/savedata.cpp b/src/core/libraries/save_data/savedata.cpp index b7e63470..d3e585c0 100644 --- a/src/core/libraries/save_data/savedata.cpp +++ b/src/core/libraries/save_data/savedata.cpp @@ -331,22 +331,14 @@ int PS4_SYSV_ABI sceSaveDataLoadIcon() { return ORBIS_OK; } -int PS4_SYSV_ABI sceSaveDataMount() { - LOG_ERROR(Lib_SaveData, "(STUBBED) called"); - return ORBIS_OK; -} - -s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount, - OrbisSaveDataMountResult* mount_result) { - LOG_INFO(Lib_SaveData, "called user_id = {} dir_name = {} blocks = {} mount_mode = {}", - mount->user_id, mount->dir_name->data, mount->blocks, mount->mount_mode); +s32 saveDataMount(u32 user_id, std::string dir_name, u32 mount_mode, + OrbisSaveDataMountResult* mount_result) { auto* param_sfo = Common::Singleton::Instance(); std::string id(param_sfo->GetString("CONTENT_ID"), 7, 9); const auto& mount_dir = Common::FS::GetUserPath(Common::FS::PathType::SaveDataDir) / - std::to_string(mount->user_id) / "savedata" / id / - std::string(mount->dir_name->data); - switch (mount->mount_mode) { + std::to_string(user_id) / "savedata" / id / dir_name; + switch (mount_mode) { case ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY: case ORBIS_SAVE_DATA_MOUNT_MODE_RDWR: { if (!std::filesystem::exists(mount_dir)) { @@ -392,6 +384,28 @@ s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount, return ORBIS_OK; } +s32 PS4_SYSV_ABI sceSaveDataMount(const OrbisSaveDataMount* mount, + OrbisSaveDataMountResult* mount_result) { + if (mount == nullptr) { + return ORBIS_SAVE_DATA_ERROR_PARAMETER; + } + LOG_INFO(Lib_SaveData, "called: mount = {}, mode = {}, blocks = {}", mount->dir_name->data, + mount->mount_mode, mount->blocks); + return saveDataMount(mount->user_id, std::string(mount->dir_name->data), mount->mount_mode, + mount_result); +} + +s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount, + OrbisSaveDataMountResult* mount_result) { + if (mount == nullptr) { + return ORBIS_SAVE_DATA_ERROR_PARAMETER; + } + LOG_INFO(Lib_SaveData, "called: mount = {}, mode = {}, blocks = {}", mount->dir_name->data, + mount->mount_mode, mount->blocks); + return saveDataMount(mount->user_id, std::string(mount->dir_name->data), mount->mount_mode, + mount_result); +} + int PS4_SYSV_ABI sceSaveDataMount5() { LOG_ERROR(Lib_SaveData, "(STUBBED) called"); return ORBIS_OK; diff --git a/src/core/libraries/save_data/savedata.h b/src/core/libraries/save_data/savedata.h index a4541587..60f99cea 100644 --- a/src/core/libraries/save_data/savedata.h +++ b/src/core/libraries/save_data/savedata.h @@ -42,6 +42,30 @@ struct OrbisSaveDataMountResult { s32 unk1; }; +constexpr int ORBIS_SAVE_DATA_TITLE_ID_DATA_SIZE = 10; +typedef struct OrbisSaveDataTitleId { + char data[ORBIS_SAVE_DATA_TITLE_ID_DATA_SIZE]; + char padding[6]; + +} OrbisSaveDataTitleId; + +constexpr int ORBIS_SAVE_DATA_FINGERPRINT_DATA_SIZE = 65; +typedef struct OrbisSaveDataFingerprint { + char data[ORBIS_SAVE_DATA_FINGERPRINT_DATA_SIZE]; + char padding[15]; +} OrbisSaveDataFingerprint; + +typedef struct OrbisSaveDataMount { + s32 user_id; + s32 pad; + const OrbisSaveDataTitleId* titleId; + const OrbisSaveDataDirName* dir_name; + const OrbisSaveDataFingerprint* fingerprint; + u64 blocks; + u32 mount_mode; + u8 reserved[32]; +} OrbisSaveDataMount; + // savedataMount2 mountModes (ORed values) constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDONLY = 1; constexpr int ORBIS_SAVE_DATA_MOUNT_MODE_RDWR = 2; @@ -113,7 +137,8 @@ int PS4_SYSV_ABI sceSaveDataInitializeForCdlg(); int PS4_SYSV_ABI sceSaveDataIsDeletingUsbDb(); int PS4_SYSV_ABI sceSaveDataIsMounted(); int PS4_SYSV_ABI sceSaveDataLoadIcon(); -int PS4_SYSV_ABI sceSaveDataMount(); +int PS4_SYSV_ABI sceSaveDataMount(const OrbisSaveDataMount* mount, + OrbisSaveDataMountResult* mount_result); s32 PS4_SYSV_ABI sceSaveDataMount2(const OrbisSaveDataMount2* mount, OrbisSaveDataMountResult* mount_result); int PS4_SYSV_ABI sceSaveDataMount5();