diff options
| author | 2024-02-23 11:34:06 -0500 | |
|---|---|---|
| committer | 2024-02-23 11:34:06 -0500 | |
| commit | 0da6704fc2e45958ee2bf884128ce0ff5897ac1a (patch) | |
| tree | 436e6adbf8dba2fdea6985b3e9b8cc24975d382e /src | |
| parent | Merge pull request #13121 from german77/clean-shortcut (diff) | |
| parent | Address review comments (diff) | |
| download | yuzu-0da6704fc2e45958ee2bf884128ce0ff5897ac1a.tar.gz yuzu-0da6704fc2e45958ee2bf884128ce0ff5897ac1a.tar.xz yuzu-0da6704fc2e45958ee2bf884128ce0ff5897ac1a.zip | |
Merge pull request #13073 from FearlessTobi/fsp-srv-ipc
fsp: Migrate remaining interfaces to cmif serialization
Diffstat (limited to 'src')
17 files changed, 715 insertions, 643 deletions
diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 1226219ad..5d484a85e 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp | |||
| @@ -668,7 +668,7 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_initializeEmptyUserDirectory(JNIEnv* | |||
| 668 | ASSERT(user_id); | 668 | ASSERT(user_id); |
| 669 | 669 | ||
| 670 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 670 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 671 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, 1, | 671 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, 1, |
| 672 | user_id->AsU128(), 0); | 672 | user_id->AsU128(), 0); |
| 673 | 673 | ||
| 674 | const auto full_path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); | 674 | const auto full_path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); |
| @@ -836,8 +836,8 @@ jstring Java_org_yuzu_yuzu_1emu_NativeLibrary_getSavePath(JNIEnv* env, jobject j | |||
| 836 | FileSys::OpenMode::Read); | 836 | FileSys::OpenMode::Read); |
| 837 | 837 | ||
| 838 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 838 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 839 | {}, vfsNandDir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::SaveData, | 839 | {}, vfsNandDir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, program_id, |
| 840 | program_id, user_id->AsU128(), 0); | 840 | user_id->AsU128(), 0); |
| 841 | return Common::Android::ToJString(env, user_save_data_path); | 841 | return Common::Android::ToJString(env, user_save_data_path); |
| 842 | } | 842 | } |
| 843 | 843 | ||
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index a7b760fa2..65bbf4818 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -58,6 +58,7 @@ add_library(core STATIC | |||
| 58 | file_sys/fs_operate_range.h | 58 | file_sys/fs_operate_range.h |
| 59 | file_sys/fs_path.h | 59 | file_sys/fs_path.h |
| 60 | file_sys/fs_path_utility.h | 60 | file_sys/fs_path_utility.h |
| 61 | file_sys/fs_save_data_types.h | ||
| 61 | file_sys/fs_string_util.h | 62 | file_sys/fs_string_util.h |
| 62 | file_sys/fsa/fs_i_directory.h | 63 | file_sys/fsa/fs_i_directory.h |
| 63 | file_sys/fsa/fs_i_file.h | 64 | file_sys/fsa/fs_i_file.h |
| @@ -599,6 +600,10 @@ add_library(core STATIC | |||
| 599 | hle/service/filesystem/fsp/fs_i_file.h | 600 | hle/service/filesystem/fsp/fs_i_file.h |
| 600 | hle/service/filesystem/fsp/fs_i_filesystem.cpp | 601 | hle/service/filesystem/fsp/fs_i_filesystem.cpp |
| 601 | hle/service/filesystem/fsp/fs_i_filesystem.h | 602 | hle/service/filesystem/fsp/fs_i_filesystem.h |
| 603 | hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp | ||
| 604 | hle/service/filesystem/fsp/fs_i_multi_commit_manager.h | ||
| 605 | hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp | ||
| 606 | hle/service/filesystem/fsp/fs_i_save_data_info_reader.h | ||
| 602 | hle/service/filesystem/fsp/fs_i_storage.cpp | 607 | hle/service/filesystem/fsp/fs_i_storage.cpp |
| 603 | hle/service/filesystem/fsp/fs_i_storage.h | 608 | hle/service/filesystem/fsp/fs_i_storage.h |
| 604 | hle/service/filesystem/fsp/fsp_ldr.cpp | 609 | hle/service/filesystem/fsp/fsp_ldr.cpp |
| @@ -607,7 +612,7 @@ add_library(core STATIC | |||
| 607 | hle/service/filesystem/fsp/fsp_pr.h | 612 | hle/service/filesystem/fsp/fsp_pr.h |
| 608 | hle/service/filesystem/fsp/fsp_srv.cpp | 613 | hle/service/filesystem/fsp/fsp_srv.cpp |
| 609 | hle/service/filesystem/fsp/fsp_srv.h | 614 | hle/service/filesystem/fsp/fsp_srv.h |
| 610 | hle/service/filesystem/fsp/fsp_util.h | 615 | hle/service/filesystem/fsp/fsp_types.h |
| 611 | hle/service/filesystem/romfs_controller.cpp | 616 | hle/service/filesystem/romfs_controller.cpp |
| 612 | hle/service/filesystem/romfs_controller.h | 617 | hle/service/filesystem/romfs_controller.h |
| 613 | hle/service/filesystem/save_data_controller.cpp | 618 | hle/service/filesystem/save_data_controller.cpp |
diff --git a/src/core/file_sys/fs_save_data_types.h b/src/core/file_sys/fs_save_data_types.h new file mode 100644 index 000000000..86a83d217 --- /dev/null +++ b/src/core/file_sys/fs_save_data_types.h | |||
| @@ -0,0 +1,175 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <array> | ||
| 7 | #include <fmt/format.h> | ||
| 8 | #include "common/common_funcs.h" | ||
| 9 | #include "common/common_types.h" | ||
| 10 | |||
| 11 | namespace FileSys { | ||
| 12 | |||
| 13 | using SaveDataId = u64; | ||
| 14 | using SystemSaveDataId = u64; | ||
| 15 | using SystemBcatSaveDataId = SystemSaveDataId; | ||
| 16 | using ProgramId = u64; | ||
| 17 | |||
| 18 | enum class SaveDataSpaceId : u8 { | ||
| 19 | System = 0, | ||
| 20 | User = 1, | ||
| 21 | SdSystem = 2, | ||
| 22 | Temporary = 3, | ||
| 23 | SdUser = 4, | ||
| 24 | |||
| 25 | ProperSystem = 100, | ||
| 26 | SafeMode = 101, | ||
| 27 | }; | ||
| 28 | |||
| 29 | enum class SaveDataType : u8 { | ||
| 30 | System = 0, | ||
| 31 | Account = 1, | ||
| 32 | Bcat = 2, | ||
| 33 | Device = 3, | ||
| 34 | Temporary = 4, | ||
| 35 | Cache = 5, | ||
| 36 | SystemBcat = 6, | ||
| 37 | }; | ||
| 38 | |||
| 39 | enum class SaveDataRank : u8 { | ||
| 40 | Primary = 0, | ||
| 41 | Secondary = 1, | ||
| 42 | }; | ||
| 43 | |||
| 44 | struct SaveDataSize { | ||
| 45 | u64 normal; | ||
| 46 | u64 journal; | ||
| 47 | }; | ||
| 48 | static_assert(sizeof(SaveDataSize) == 0x10, "SaveDataSize has invalid size."); | ||
| 49 | |||
| 50 | using UserId = u128; | ||
| 51 | static_assert(std::is_trivially_copyable_v<UserId>, "Data type must be trivially copyable."); | ||
| 52 | static_assert(sizeof(UserId) == 0x10, "UserId has invalid size."); | ||
| 53 | |||
| 54 | constexpr inline SystemSaveDataId InvalidSystemSaveDataId = 0; | ||
| 55 | constexpr inline UserId InvalidUserId = {}; | ||
| 56 | |||
| 57 | enum class SaveDataFlags : u32 { | ||
| 58 | None = (0 << 0), | ||
| 59 | KeepAfterResettingSystemSaveData = (1 << 0), | ||
| 60 | KeepAfterRefurbishment = (1 << 1), | ||
| 61 | KeepAfterResettingSystemSaveDataWithoutUserSaveData = (1 << 2), | ||
| 62 | NeedsSecureDelete = (1 << 3), | ||
| 63 | }; | ||
| 64 | |||
| 65 | enum class SaveDataMetaType : u8 { | ||
| 66 | None = 0, | ||
| 67 | Thumbnail = 1, | ||
| 68 | ExtensionContext = 2, | ||
| 69 | }; | ||
| 70 | |||
| 71 | struct SaveDataMetaInfo { | ||
| 72 | u32 size; | ||
| 73 | SaveDataMetaType type; | ||
| 74 | INSERT_PADDING_BYTES(0xB); | ||
| 75 | }; | ||
| 76 | static_assert(std::is_trivially_copyable_v<SaveDataMetaInfo>, | ||
| 77 | "Data type must be trivially copyable."); | ||
| 78 | static_assert(sizeof(SaveDataMetaInfo) == 0x10, "SaveDataMetaInfo has invalid size."); | ||
| 79 | |||
| 80 | struct SaveDataCreationInfo { | ||
| 81 | s64 size; | ||
| 82 | s64 journal_size; | ||
| 83 | s64 block_size; | ||
| 84 | u64 owner_id; | ||
| 85 | u32 flags; | ||
| 86 | SaveDataSpaceId space_id; | ||
| 87 | bool pseudo; | ||
| 88 | INSERT_PADDING_BYTES(0x1A); | ||
| 89 | }; | ||
| 90 | static_assert(std::is_trivially_copyable_v<SaveDataCreationInfo>, | ||
| 91 | "Data type must be trivially copyable."); | ||
| 92 | static_assert(sizeof(SaveDataCreationInfo) == 0x40, "SaveDataCreationInfo has invalid size."); | ||
| 93 | |||
| 94 | struct SaveDataAttribute { | ||
| 95 | ProgramId program_id; | ||
| 96 | UserId user_id; | ||
| 97 | SystemSaveDataId system_save_data_id; | ||
| 98 | SaveDataType type; | ||
| 99 | SaveDataRank rank; | ||
| 100 | u16 index; | ||
| 101 | INSERT_PADDING_BYTES(0x1C); | ||
| 102 | |||
| 103 | static constexpr SaveDataAttribute Make(ProgramId program_id, SaveDataType type, UserId user_id, | ||
| 104 | SystemSaveDataId system_save_data_id, u16 index, | ||
| 105 | SaveDataRank rank) { | ||
| 106 | return { | ||
| 107 | .program_id = program_id, | ||
| 108 | .user_id = user_id, | ||
| 109 | .system_save_data_id = system_save_data_id, | ||
| 110 | .type = type, | ||
| 111 | .rank = rank, | ||
| 112 | .index = index, | ||
| 113 | }; | ||
| 114 | } | ||
| 115 | |||
| 116 | static constexpr SaveDataAttribute Make(ProgramId program_id, SaveDataType type, UserId user_id, | ||
| 117 | SystemSaveDataId system_save_data_id, u16 index) { | ||
| 118 | return Make(program_id, type, user_id, system_save_data_id, index, SaveDataRank::Primary); | ||
| 119 | } | ||
| 120 | |||
| 121 | static constexpr SaveDataAttribute Make(ProgramId program_id, SaveDataType type, UserId user_id, | ||
| 122 | SystemSaveDataId system_save_data_id) { | ||
| 123 | return Make(program_id, type, user_id, system_save_data_id, 0, SaveDataRank::Primary); | ||
| 124 | } | ||
| 125 | |||
| 126 | std::string DebugInfo() const { | ||
| 127 | return fmt::format( | ||
| 128 | "[title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}, type={:02X}, " | ||
| 129 | "rank={}, index={}]", | ||
| 130 | program_id, user_id[1], user_id[0], system_save_data_id, static_cast<u8>(type), | ||
| 131 | static_cast<u8>(rank), index); | ||
| 132 | } | ||
| 133 | }; | ||
| 134 | static_assert(sizeof(SaveDataAttribute) == 0x40); | ||
| 135 | static_assert(std::is_trivially_destructible<SaveDataAttribute>::value); | ||
| 136 | |||
| 137 | constexpr inline bool operator<(const SaveDataAttribute& lhs, const SaveDataAttribute& rhs) { | ||
| 138 | return std::tie(lhs.program_id, lhs.user_id, lhs.system_save_data_id, lhs.index, lhs.rank) < | ||
| 139 | std::tie(rhs.program_id, rhs.user_id, rhs.system_save_data_id, rhs.index, rhs.rank); | ||
| 140 | } | ||
| 141 | |||
| 142 | constexpr inline bool operator==(const SaveDataAttribute& lhs, const SaveDataAttribute& rhs) { | ||
| 143 | return std::tie(lhs.program_id, lhs.user_id, lhs.system_save_data_id, lhs.type, lhs.rank, | ||
| 144 | lhs.index) == std::tie(rhs.program_id, rhs.user_id, rhs.system_save_data_id, | ||
| 145 | rhs.type, rhs.rank, rhs.index); | ||
| 146 | } | ||
| 147 | |||
| 148 | constexpr inline bool operator!=(const SaveDataAttribute& lhs, const SaveDataAttribute& rhs) { | ||
| 149 | return !(lhs == rhs); | ||
| 150 | } | ||
| 151 | |||
| 152 | struct SaveDataExtraData { | ||
| 153 | SaveDataAttribute attr; | ||
| 154 | u64 owner_id; | ||
| 155 | s64 timestamp; | ||
| 156 | u32 flags; | ||
| 157 | INSERT_PADDING_BYTES(4); | ||
| 158 | s64 available_size; | ||
| 159 | s64 journal_size; | ||
| 160 | s64 commit_id; | ||
| 161 | INSERT_PADDING_BYTES(0x190); | ||
| 162 | }; | ||
| 163 | static_assert(sizeof(SaveDataExtraData) == 0x200, "SaveDataExtraData has invalid size."); | ||
| 164 | static_assert(std::is_trivially_copyable_v<SaveDataExtraData>, | ||
| 165 | "Data type must be trivially copyable."); | ||
| 166 | |||
| 167 | struct HashSalt { | ||
| 168 | static constexpr size_t Size = 32; | ||
| 169 | |||
| 170 | std::array<u8, Size> value; | ||
| 171 | }; | ||
| 172 | static_assert(std::is_trivially_copyable_v<HashSalt>, "Data type must be trivially copyable."); | ||
| 173 | static_assert(sizeof(HashSalt) == HashSalt::Size); | ||
| 174 | |||
| 175 | } // namespace FileSys | ||
diff --git a/src/core/file_sys/savedata_factory.cpp b/src/core/file_sys/savedata_factory.cpp index cbf411a20..106922e04 100644 --- a/src/core/file_sys/savedata_factory.cpp +++ b/src/core/file_sys/savedata_factory.cpp | |||
| @@ -14,48 +14,11 @@ namespace FileSys { | |||
| 14 | 14 | ||
| 15 | namespace { | 15 | namespace { |
| 16 | 16 | ||
| 17 | void PrintSaveDataAttributeWarnings(SaveDataAttribute meta) { | ||
| 18 | if (meta.type == SaveDataType::SystemSaveData || meta.type == SaveDataType::SaveData) { | ||
| 19 | if (meta.zero_1 != 0) { | ||
| 20 | LOG_WARNING(Service_FS, | ||
| 21 | "Possibly incorrect SaveDataAttribute, type is " | ||
| 22 | "SystemSaveData||SaveData but offset 0x28 is non-zero ({:016X}).", | ||
| 23 | meta.zero_1); | ||
| 24 | } | ||
| 25 | if (meta.zero_2 != 0) { | ||
| 26 | LOG_WARNING(Service_FS, | ||
| 27 | "Possibly incorrect SaveDataAttribute, type is " | ||
| 28 | "SystemSaveData||SaveData but offset 0x30 is non-zero ({:016X}).", | ||
| 29 | meta.zero_2); | ||
| 30 | } | ||
| 31 | if (meta.zero_3 != 0) { | ||
| 32 | LOG_WARNING(Service_FS, | ||
| 33 | "Possibly incorrect SaveDataAttribute, type is " | ||
| 34 | "SystemSaveData||SaveData but offset 0x38 is non-zero ({:016X}).", | ||
| 35 | meta.zero_3); | ||
| 36 | } | ||
| 37 | } | ||
| 38 | |||
| 39 | if (meta.type == SaveDataType::SystemSaveData && meta.title_id != 0) { | ||
| 40 | LOG_WARNING(Service_FS, | ||
| 41 | "Possibly incorrect SaveDataAttribute, type is SystemSaveData but title_id is " | ||
| 42 | "non-zero ({:016X}).", | ||
| 43 | meta.title_id); | ||
| 44 | } | ||
| 45 | |||
| 46 | if (meta.type == SaveDataType::DeviceSaveData && meta.user_id != u128{0, 0}) { | ||
| 47 | LOG_WARNING(Service_FS, | ||
| 48 | "Possibly incorrect SaveDataAttribute, type is DeviceSaveData but user_id is " | ||
| 49 | "non-zero ({:016X}{:016X})", | ||
| 50 | meta.user_id[1], meta.user_id[0]); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
| 54 | bool ShouldSaveDataBeAutomaticallyCreated(SaveDataSpaceId space, const SaveDataAttribute& attr) { | 17 | bool ShouldSaveDataBeAutomaticallyCreated(SaveDataSpaceId space, const SaveDataAttribute& attr) { |
| 55 | return attr.type == SaveDataType::CacheStorage || attr.type == SaveDataType::TemporaryStorage || | 18 | return attr.type == SaveDataType::Cache || attr.type == SaveDataType::Temporary || |
| 56 | (space == SaveDataSpaceId::NandUser && ///< Normal Save Data -- Current Title & User | 19 | (space == SaveDataSpaceId::User && ///< Normal Save Data -- Current Title & User |
| 57 | (attr.type == SaveDataType::SaveData || attr.type == SaveDataType::DeviceSaveData) && | 20 | (attr.type == SaveDataType::Account || attr.type == SaveDataType::Device) && |
| 58 | attr.title_id == 0 && attr.save_id == 0); | 21 | attr.program_id == 0 && attr.system_save_data_id == 0); |
| 59 | } | 22 | } |
| 60 | 23 | ||
| 61 | std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u64 title_id, | 24 | std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u64 title_id, |
| @@ -63,7 +26,7 @@ std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u | |||
| 63 | // Only detect nand user saves. | 26 | // Only detect nand user saves. |
| 64 | const auto space_id_path = [space_id]() -> std::string_view { | 27 | const auto space_id_path = [space_id]() -> std::string_view { |
| 65 | switch (space_id) { | 28 | switch (space_id) { |
| 66 | case SaveDataSpaceId::NandUser: | 29 | case SaveDataSpaceId::User: |
| 67 | return "/user/save"; | 30 | return "/user/save"; |
| 68 | default: | 31 | default: |
| 69 | return ""; | 32 | return ""; |
| @@ -79,9 +42,9 @@ std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u | |||
| 79 | 42 | ||
| 80 | // Only detect account/device saves from the future location. | 43 | // Only detect account/device saves from the future location. |
| 81 | switch (type) { | 44 | switch (type) { |
| 82 | case SaveDataType::SaveData: | 45 | case SaveDataType::Account: |
| 83 | return fmt::format("{}/account/{}/{:016X}/0", space_id_path, uuid.RawString(), title_id); | 46 | return fmt::format("{}/account/{}/{:016X}/0", space_id_path, uuid.RawString(), title_id); |
| 84 | case SaveDataType::DeviceSaveData: | 47 | case SaveDataType::Device: |
| 85 | return fmt::format("{}/device/{:016X}/0", space_id_path, title_id); | 48 | return fmt::format("{}/device/{:016X}/0", space_id_path, title_id); |
| 86 | default: | 49 | default: |
| 87 | return ""; | 50 | return ""; |
| @@ -90,13 +53,6 @@ std::string GetFutureSaveDataPath(SaveDataSpaceId space_id, SaveDataType type, u | |||
| 90 | 53 | ||
| 91 | } // Anonymous namespace | 54 | } // Anonymous namespace |
| 92 | 55 | ||
| 93 | std::string SaveDataAttribute::DebugInfo() const { | ||
| 94 | return fmt::format("[title_id={:016X}, user_id={:016X}{:016X}, save_id={:016X}, type={:02X}, " | ||
| 95 | "rank={}, index={}]", | ||
| 96 | title_id, user_id[1], user_id[0], save_id, static_cast<u8>(type), | ||
| 97 | static_cast<u8>(rank), index); | ||
| 98 | } | ||
| 99 | |||
| 100 | SaveDataFactory::SaveDataFactory(Core::System& system_, ProgramId program_id_, | 56 | SaveDataFactory::SaveDataFactory(Core::System& system_, ProgramId program_id_, |
| 101 | VirtualDir save_directory_) | 57 | VirtualDir save_directory_) |
| 102 | : system{system_}, program_id{program_id_}, dir{std::move(save_directory_)} { | 58 | : system{system_}, program_id{program_id_}, dir{std::move(save_directory_)} { |
| @@ -108,18 +64,16 @@ SaveDataFactory::SaveDataFactory(Core::System& system_, ProgramId program_id_, | |||
| 108 | SaveDataFactory::~SaveDataFactory() = default; | 64 | SaveDataFactory::~SaveDataFactory() = default; |
| 109 | 65 | ||
| 110 | VirtualDir SaveDataFactory::Create(SaveDataSpaceId space, const SaveDataAttribute& meta) const { | 66 | VirtualDir SaveDataFactory::Create(SaveDataSpaceId space, const SaveDataAttribute& meta) const { |
| 111 | PrintSaveDataAttributeWarnings(meta); | 67 | const auto save_directory = GetFullPath(program_id, dir, space, meta.type, meta.program_id, |
| 112 | 68 | meta.user_id, meta.system_save_data_id); | |
| 113 | const auto save_directory = | ||
| 114 | GetFullPath(program_id, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id); | ||
| 115 | 69 | ||
| 116 | return dir->CreateDirectoryRelative(save_directory); | 70 | return dir->CreateDirectoryRelative(save_directory); |
| 117 | } | 71 | } |
| 118 | 72 | ||
| 119 | VirtualDir SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataAttribute& meta) const { | 73 | VirtualDir SaveDataFactory::Open(SaveDataSpaceId space, const SaveDataAttribute& meta) const { |
| 120 | 74 | ||
| 121 | const auto save_directory = | 75 | const auto save_directory = GetFullPath(program_id, dir, space, meta.type, meta.program_id, |
| 122 | GetFullPath(program_id, dir, space, meta.type, meta.title_id, meta.user_id, meta.save_id); | 76 | meta.user_id, meta.system_save_data_id); |
| 123 | 77 | ||
| 124 | auto out = dir->GetDirectoryRelative(save_directory); | 78 | auto out = dir->GetDirectoryRelative(save_directory); |
| 125 | 79 | ||
| @@ -136,11 +90,11 @@ VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) con | |||
| 136 | 90 | ||
| 137 | std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) { | 91 | std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) { |
| 138 | switch (space) { | 92 | switch (space) { |
| 139 | case SaveDataSpaceId::NandSystem: | 93 | case SaveDataSpaceId::System: |
| 140 | return "/system/"; | 94 | return "/system/"; |
| 141 | case SaveDataSpaceId::NandUser: | 95 | case SaveDataSpaceId::User: |
| 142 | return "/user/"; | 96 | return "/user/"; |
| 143 | case SaveDataSpaceId::TemporaryStorage: | 97 | case SaveDataSpaceId::Temporary: |
| 144 | return "/temp/"; | 98 | return "/temp/"; |
| 145 | default: | 99 | default: |
| 146 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); | 100 | ASSERT_MSG(false, "Unrecognized SaveDataSpaceId: {:02X}", static_cast<u8>(space)); |
| @@ -153,7 +107,7 @@ std::string SaveDataFactory::GetFullPath(ProgramId program_id, VirtualDir dir, | |||
| 153 | u128 user_id, u64 save_id) { | 107 | u128 user_id, u64 save_id) { |
| 154 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should | 108 | // According to switchbrew, if a save is of type SaveData and the title id field is 0, it should |
| 155 | // be interpreted as the title id of the current process. | 109 | // be interpreted as the title id of the current process. |
| 156 | if (type == SaveDataType::SaveData || type == SaveDataType::DeviceSaveData) { | 110 | if (type == SaveDataType::Account || type == SaveDataType::Device) { |
| 157 | if (title_id == 0) { | 111 | if (title_id == 0) { |
| 158 | title_id = program_id; | 112 | title_id = program_id; |
| 159 | } | 113 | } |
| @@ -173,16 +127,16 @@ std::string SaveDataFactory::GetFullPath(ProgramId program_id, VirtualDir dir, | |||
| 173 | std::string out = GetSaveDataSpaceIdPath(space); | 127 | std::string out = GetSaveDataSpaceIdPath(space); |
| 174 | 128 | ||
| 175 | switch (type) { | 129 | switch (type) { |
| 176 | case SaveDataType::SystemSaveData: | 130 | case SaveDataType::System: |
| 177 | return fmt::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]); | 131 | return fmt::format("{}save/{:016X}/{:016X}{:016X}", out, save_id, user_id[1], user_id[0]); |
| 178 | case SaveDataType::SaveData: | 132 | case SaveDataType::Account: |
| 179 | case SaveDataType::DeviceSaveData: | 133 | case SaveDataType::Device: |
| 180 | return fmt::format("{}save/{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], | 134 | return fmt::format("{}save/{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], |
| 181 | title_id); | 135 | title_id); |
| 182 | case SaveDataType::TemporaryStorage: | 136 | case SaveDataType::Temporary: |
| 183 | return fmt::format("{}{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], | 137 | return fmt::format("{}{:016X}/{:016X}{:016X}/{:016X}", out, 0, user_id[1], user_id[0], |
| 184 | title_id); | 138 | title_id); |
| 185 | case SaveDataType::CacheStorage: | 139 | case SaveDataType::Cache: |
| 186 | return fmt::format("{}save/cache/{:016X}", out, title_id); | 140 | return fmt::format("{}save/cache/{:016X}", out, title_id); |
| 187 | default: | 141 | default: |
| 188 | ASSERT_MSG(false, "Unrecognized SaveDataType: {:02X}", static_cast<u8>(type)); | 142 | ASSERT_MSG(false, "Unrecognized SaveDataType: {:02X}", static_cast<u8>(type)); |
| @@ -202,7 +156,7 @@ std::string SaveDataFactory::GetUserGameSaveDataRoot(u128 user_id, bool future) | |||
| 202 | SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id, | 156 | SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id, |
| 203 | u128 user_id) const { | 157 | u128 user_id) const { |
| 204 | const auto path = | 158 | const auto path = |
| 205 | GetFullPath(program_id, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); | 159 | GetFullPath(program_id, dir, SaveDataSpaceId::User, type, title_id, user_id, 0); |
| 206 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); | 160 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); |
| 207 | 161 | ||
| 208 | const auto size_file = relative_dir->GetFile(GetSaveDataSizeFileName()); | 162 | const auto size_file = relative_dir->GetFile(GetSaveDataSizeFileName()); |
| @@ -221,7 +175,7 @@ SaveDataSize SaveDataFactory::ReadSaveDataSize(SaveDataType type, u64 title_id, | |||
| 221 | void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id, | 175 | void SaveDataFactory::WriteSaveDataSize(SaveDataType type, u64 title_id, u128 user_id, |
| 222 | SaveDataSize new_value) const { | 176 | SaveDataSize new_value) const { |
| 223 | const auto path = | 177 | const auto path = |
| 224 | GetFullPath(program_id, dir, SaveDataSpaceId::NandUser, type, title_id, user_id, 0); | 178 | GetFullPath(program_id, dir, SaveDataSpaceId::User, type, title_id, user_id, 0); |
| 225 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); | 179 | const auto relative_dir = GetOrCreateDirectoryRelative(dir, path); |
| 226 | 180 | ||
| 227 | const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName()); | 181 | const auto size_file = relative_dir->CreateFile(GetSaveDataSizeFileName()); |
diff --git a/src/core/file_sys/savedata_factory.h b/src/core/file_sys/savedata_factory.h index 5ab7e4d32..15dd4ec7d 100644 --- a/src/core/file_sys/savedata_factory.h +++ b/src/core/file_sys/savedata_factory.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <string> | 7 | #include <string> |
| 8 | #include "common/common_funcs.h" | 8 | #include "common/common_funcs.h" |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | #include "core/file_sys/fs_save_data_types.h" | ||
| 10 | #include "core/file_sys/vfs/vfs.h" | 11 | #include "core/file_sys/vfs/vfs.h" |
| 11 | #include "core/hle/result.h" | 12 | #include "core/hle/result.h" |
| 12 | 13 | ||
| @@ -16,73 +17,6 @@ class System; | |||
| 16 | 17 | ||
| 17 | namespace FileSys { | 18 | namespace FileSys { |
| 18 | 19 | ||
| 19 | enum class SaveDataSpaceId : u8 { | ||
| 20 | NandSystem = 0, | ||
| 21 | NandUser = 1, | ||
| 22 | SdCardSystem = 2, | ||
| 23 | TemporaryStorage = 3, | ||
| 24 | SdCardUser = 4, | ||
| 25 | ProperSystem = 100, | ||
| 26 | SafeMode = 101, | ||
| 27 | }; | ||
| 28 | |||
| 29 | enum class SaveDataType : u8 { | ||
| 30 | SystemSaveData = 0, | ||
| 31 | SaveData = 1, | ||
| 32 | BcatDeliveryCacheStorage = 2, | ||
| 33 | DeviceSaveData = 3, | ||
| 34 | TemporaryStorage = 4, | ||
| 35 | CacheStorage = 5, | ||
| 36 | SystemBcat = 6, | ||
| 37 | }; | ||
| 38 | |||
| 39 | enum class SaveDataRank : u8 { | ||
| 40 | Primary = 0, | ||
| 41 | Secondary = 1, | ||
| 42 | }; | ||
| 43 | |||
| 44 | enum class SaveDataFlags : u32 { | ||
| 45 | None = (0 << 0), | ||
| 46 | KeepAfterResettingSystemSaveData = (1 << 0), | ||
| 47 | KeepAfterRefurbishment = (1 << 1), | ||
| 48 | KeepAfterResettingSystemSaveDataWithoutUserSaveData = (1 << 2), | ||
| 49 | NeedsSecureDelete = (1 << 3), | ||
| 50 | }; | ||
| 51 | |||
| 52 | struct SaveDataAttribute { | ||
| 53 | u64 title_id; | ||
| 54 | u128 user_id; | ||
| 55 | u64 save_id; | ||
| 56 | SaveDataType type; | ||
| 57 | SaveDataRank rank; | ||
| 58 | u16 index; | ||
| 59 | INSERT_PADDING_BYTES_NOINIT(4); | ||
| 60 | u64 zero_1; | ||
| 61 | u64 zero_2; | ||
| 62 | u64 zero_3; | ||
| 63 | |||
| 64 | std::string DebugInfo() const; | ||
| 65 | }; | ||
| 66 | static_assert(sizeof(SaveDataAttribute) == 0x40, "SaveDataAttribute has incorrect size."); | ||
| 67 | |||
| 68 | struct SaveDataExtraData { | ||
| 69 | SaveDataAttribute attr; | ||
| 70 | u64 owner_id; | ||
| 71 | s64 timestamp; | ||
| 72 | SaveDataFlags flags; | ||
| 73 | INSERT_PADDING_BYTES_NOINIT(4); | ||
| 74 | s64 available_size; | ||
| 75 | s64 journal_size; | ||
| 76 | s64 commit_id; | ||
| 77 | std::array<u8, 0x190> unused; | ||
| 78 | }; | ||
| 79 | static_assert(sizeof(SaveDataExtraData) == 0x200, "SaveDataExtraData has incorrect size."); | ||
| 80 | |||
| 81 | struct SaveDataSize { | ||
| 82 | u64 normal; | ||
| 83 | u64 journal; | ||
| 84 | }; | ||
| 85 | |||
| 86 | constexpr const char* GetSaveDataSizeFileName() { | 20 | constexpr const char* GetSaveDataSizeFileName() { |
| 87 | return ".yuzu_save_size"; | 21 | return ".yuzu_save_size"; |
| 88 | } | 22 | } |
diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp index cb53b07e0..bfccb6b09 100644 --- a/src/core/hle/service/am/service/application_functions.cpp +++ b/src/core/hle/service/am/service/application_functions.cpp | |||
| @@ -123,13 +123,13 @@ Result IApplicationFunctions::EnsureSaveData(Out<u64> out_size, Common::UUID use | |||
| 123 | LOG_INFO(Service_AM, "called, uid={}", user_id.FormattedString()); | 123 | LOG_INFO(Service_AM, "called, uid={}", user_id.FormattedString()); |
| 124 | 124 | ||
| 125 | FileSys::SaveDataAttribute attribute{}; | 125 | FileSys::SaveDataAttribute attribute{}; |
| 126 | attribute.title_id = m_applet->program_id; | 126 | attribute.program_id = m_applet->program_id; |
| 127 | attribute.user_id = user_id.AsU128(); | 127 | attribute.user_id = user_id.AsU128(); |
| 128 | attribute.type = FileSys::SaveDataType::SaveData; | 128 | attribute.type = FileSys::SaveDataType::Account; |
| 129 | 129 | ||
| 130 | FileSys::VirtualDir save_data{}; | 130 | FileSys::VirtualDir save_data{}; |
| 131 | R_TRY(system.GetFileSystemController().OpenSaveDataController()->CreateSaveData( | 131 | R_TRY(system.GetFileSystemController().OpenSaveDataController()->CreateSaveData( |
| 132 | &save_data, FileSys::SaveDataSpaceId::NandUser, attribute)); | 132 | &save_data, FileSys::SaveDataSpaceId::User, attribute)); |
| 133 | 133 | ||
| 134 | *out_size = 0; | 134 | *out_size = 0; |
| 135 | R_SUCCEED(); | 135 | R_SUCCEED(); |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h index 113369203..dd069f36f 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_filesystem.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "core/file_sys/vfs/vfs.h" | 9 | #include "core/file_sys/vfs/vfs.h" |
| 10 | #include "core/hle/service/cmif_types.h" | 10 | #include "core/hle/service/cmif_types.h" |
| 11 | #include "core/hle/service/filesystem/filesystem.h" | 11 | #include "core/hle/service/filesystem/filesystem.h" |
| 12 | #include "core/hle/service/filesystem/fsp/fsp_util.h" | 12 | #include "core/hle/service/filesystem/fsp/fsp_types.h" |
| 13 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 14 | 14 | ||
| 15 | namespace FileSys::Sf { | 15 | namespace FileSys::Sf { |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp new file mode 100644 index 000000000..626328234 --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.cpp | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/filesystem/fsp/fs_i_filesystem.h" | ||
| 6 | #include "core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h" | ||
| 7 | |||
| 8 | namespace Service::FileSystem { | ||
| 9 | |||
| 10 | IMultiCommitManager::IMultiCommitManager(Core::System& system_) | ||
| 11 | : ServiceFramework{system_, "IMultiCommitManager"} { | ||
| 12 | static const FunctionInfo functions[] = { | ||
| 13 | {1, D<&IMultiCommitManager::Add>, "Add"}, | ||
| 14 | {2, D<&IMultiCommitManager::Commit>, "Commit"}, | ||
| 15 | }; | ||
| 16 | RegisterHandlers(functions); | ||
| 17 | } | ||
| 18 | |||
| 19 | IMultiCommitManager::~IMultiCommitManager() = default; | ||
| 20 | |||
| 21 | Result IMultiCommitManager::Add(std::shared_ptr<IFileSystem> filesystem) { | ||
| 22 | LOG_WARNING(Service_FS, "(STUBBED) called"); | ||
| 23 | |||
| 24 | R_SUCCEED(); | ||
| 25 | } | ||
| 26 | |||
| 27 | Result IMultiCommitManager::Commit() { | ||
| 28 | LOG_WARNING(Service_FS, "(STUBBED) called"); | ||
| 29 | |||
| 30 | R_SUCCEED(); | ||
| 31 | } | ||
| 32 | |||
| 33 | } // namespace Service::FileSystem | ||
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h new file mode 100644 index 000000000..8ebf7c7d9 --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "core/file_sys/vfs/vfs.h" | ||
| 7 | #include "core/hle/service/service.h" | ||
| 8 | |||
| 9 | namespace Service::FileSystem { | ||
| 10 | |||
| 11 | class IMultiCommitManager final : public ServiceFramework<IMultiCommitManager> { | ||
| 12 | public: | ||
| 13 | explicit IMultiCommitManager(Core::System& system_); | ||
| 14 | ~IMultiCommitManager() override; | ||
| 15 | |||
| 16 | private: | ||
| 17 | Result Add(std::shared_ptr<IFileSystem> filesystem); | ||
| 18 | Result Commit(); | ||
| 19 | |||
| 20 | FileSys::VirtualFile backend; | ||
| 21 | }; | ||
| 22 | |||
| 23 | } // namespace Service::FileSystem | ||
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp new file mode 100644 index 000000000..ff823586b --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.cpp | |||
| @@ -0,0 +1,161 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/hex_util.h" | ||
| 5 | #include "core/file_sys/savedata_factory.h" | ||
| 6 | #include "core/hle/service/cmif_serialization.h" | ||
| 7 | #include "core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h" | ||
| 8 | #include "core/hle/service/filesystem/save_data_controller.h" | ||
| 9 | |||
| 10 | namespace Service::FileSystem { | ||
| 11 | |||
| 12 | ISaveDataInfoReader::ISaveDataInfoReader(Core::System& system_, | ||
| 13 | std::shared_ptr<SaveDataController> save_data_controller_, | ||
| 14 | FileSys::SaveDataSpaceId space) | ||
| 15 | : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ | ||
| 16 | save_data_controller_} { | ||
| 17 | static const FunctionInfo functions[] = { | ||
| 18 | {0, D<&ISaveDataInfoReader::ReadSaveDataInfo>, "ReadSaveDataInfo"}, | ||
| 19 | }; | ||
| 20 | RegisterHandlers(functions); | ||
| 21 | |||
| 22 | FindAllSaves(space); | ||
| 23 | } | ||
| 24 | |||
| 25 | ISaveDataInfoReader::~ISaveDataInfoReader() = default; | ||
| 26 | |||
| 27 | static u64 stoull_be(std::string_view str) { | ||
| 28 | if (str.size() != 16) { | ||
| 29 | return 0; | ||
| 30 | } | ||
| 31 | |||
| 32 | const auto bytes = Common::HexStringToArray<0x8>(str); | ||
| 33 | u64 out{}; | ||
| 34 | std::memcpy(&out, bytes.data(), sizeof(u64)); | ||
| 35 | |||
| 36 | return Common::swap64(out); | ||
| 37 | } | ||
| 38 | |||
| 39 | Result ISaveDataInfoReader::ReadSaveDataInfo( | ||
| 40 | Out<u64> out_count, OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries) { | ||
| 41 | LOG_DEBUG(Service_FS, "called"); | ||
| 42 | |||
| 43 | // Calculate how many entries we can fit in the output buffer | ||
| 44 | const u64 count_entries = out_entries.size(); | ||
| 45 | |||
| 46 | // Cap at total number of entries. | ||
| 47 | const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index); | ||
| 48 | |||
| 49 | // Determine data start and end | ||
| 50 | const auto* begin = reinterpret_cast<u8*>(info.data() + next_entry_index); | ||
| 51 | const auto* end = reinterpret_cast<u8*>(info.data() + next_entry_index + actual_entries); | ||
| 52 | const auto range_size = static_cast<std::size_t>(std::distance(begin, end)); | ||
| 53 | |||
| 54 | next_entry_index += actual_entries; | ||
| 55 | |||
| 56 | // Write the data to memory | ||
| 57 | std::memcpy(out_entries.data(), begin, range_size); | ||
| 58 | *out_count = actual_entries; | ||
| 59 | |||
| 60 | R_SUCCEED(); | ||
| 61 | } | ||
| 62 | |||
| 63 | void ISaveDataInfoReader::FindAllSaves(FileSys::SaveDataSpaceId space) { | ||
| 64 | FileSys::VirtualDir save_root{}; | ||
| 65 | const auto result = save_data_controller->OpenSaveDataSpace(&save_root, space); | ||
| 66 | |||
| 67 | if (result != ResultSuccess || save_root == nullptr) { | ||
| 68 | LOG_ERROR(Service_FS, "The save root for the space_id={:02X} was invalid!", space); | ||
| 69 | return; | ||
| 70 | } | ||
| 71 | |||
| 72 | for (const auto& type : save_root->GetSubdirectories()) { | ||
| 73 | if (type->GetName() == "save") { | ||
| 74 | FindNormalSaves(space, type); | ||
| 75 | } else if (space == FileSys::SaveDataSpaceId::Temporary) { | ||
| 76 | FindTemporaryStorageSaves(space, type); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | void ISaveDataInfoReader::FindNormalSaves(FileSys::SaveDataSpaceId space, | ||
| 82 | const FileSys::VirtualDir& type) { | ||
| 83 | for (const auto& save_id : type->GetSubdirectories()) { | ||
| 84 | for (const auto& user_id : save_id->GetSubdirectories()) { | ||
| 85 | // Skip non user id subdirectories | ||
| 86 | if (user_id->GetName().size() != 0x20) { | ||
| 87 | continue; | ||
| 88 | } | ||
| 89 | |||
| 90 | const auto save_id_numeric = stoull_be(save_id->GetName()); | ||
| 91 | auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 92 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 93 | |||
| 94 | if (save_id_numeric != 0) { | ||
| 95 | // System Save Data | ||
| 96 | info.emplace_back(SaveDataInfo{ | ||
| 97 | 0, | ||
| 98 | space, | ||
| 99 | FileSys::SaveDataType::System, | ||
| 100 | {}, | ||
| 101 | user_id_numeric, | ||
| 102 | save_id_numeric, | ||
| 103 | 0, | ||
| 104 | user_id->GetSize(), | ||
| 105 | {}, | ||
| 106 | {}, | ||
| 107 | }); | ||
| 108 | |||
| 109 | continue; | ||
| 110 | } | ||
| 111 | |||
| 112 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 113 | const auto device = std::all_of(user_id_numeric.begin(), user_id_numeric.end(), | ||
| 114 | [](u8 val) { return val == 0; }); | ||
| 115 | info.emplace_back(SaveDataInfo{ | ||
| 116 | 0, | ||
| 117 | space, | ||
| 118 | device ? FileSys::SaveDataType::Device : FileSys::SaveDataType::Account, | ||
| 119 | {}, | ||
| 120 | user_id_numeric, | ||
| 121 | save_id_numeric, | ||
| 122 | stoull_be(title_id->GetName()), | ||
| 123 | title_id->GetSize(), | ||
| 124 | {}, | ||
| 125 | {}, | ||
| 126 | }); | ||
| 127 | } | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | void ISaveDataInfoReader::FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, | ||
| 133 | const FileSys::VirtualDir& type) { | ||
| 134 | for (const auto& user_id : type->GetSubdirectories()) { | ||
| 135 | // Skip non user id subdirectories | ||
| 136 | if (user_id->GetName().size() != 0x20) { | ||
| 137 | continue; | ||
| 138 | } | ||
| 139 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 140 | if (!title_id->GetFiles().empty() || !title_id->GetSubdirectories().empty()) { | ||
| 141 | auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 142 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 143 | |||
| 144 | info.emplace_back(SaveDataInfo{ | ||
| 145 | 0, | ||
| 146 | space, | ||
| 147 | FileSys::SaveDataType::Temporary, | ||
| 148 | {}, | ||
| 149 | user_id_numeric, | ||
| 150 | stoull_be(type->GetName()), | ||
| 151 | stoull_be(title_id->GetName()), | ||
| 152 | title_id->GetSize(), | ||
| 153 | {}, | ||
| 154 | {}, | ||
| 155 | }); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 161 | } // namespace Service::FileSystem | ||
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h new file mode 100644 index 000000000..e45ad852b --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <vector> | ||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 9 | #include "core/hle/service/service.h" | ||
| 10 | |||
| 11 | namespace Service::FileSystem { | ||
| 12 | |||
| 13 | class SaveDataController; | ||
| 14 | |||
| 15 | class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { | ||
| 16 | public: | ||
| 17 | explicit ISaveDataInfoReader(Core::System& system_, | ||
| 18 | std::shared_ptr<SaveDataController> save_data_controller_, | ||
| 19 | FileSys::SaveDataSpaceId space); | ||
| 20 | ~ISaveDataInfoReader() override; | ||
| 21 | |||
| 22 | struct SaveDataInfo { | ||
| 23 | u64_le save_id_unknown; | ||
| 24 | FileSys::SaveDataSpaceId space; | ||
| 25 | FileSys::SaveDataType type; | ||
| 26 | INSERT_PADDING_BYTES(0x6); | ||
| 27 | std::array<u8, 0x10> user_id; | ||
| 28 | u64_le save_id; | ||
| 29 | u64_le title_id; | ||
| 30 | u64_le save_image_size; | ||
| 31 | u16_le index; | ||
| 32 | FileSys::SaveDataRank rank; | ||
| 33 | INSERT_PADDING_BYTES(0x25); | ||
| 34 | }; | ||
| 35 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); | ||
| 36 | |||
| 37 | Result ReadSaveDataInfo(Out<u64> out_count, | ||
| 38 | OutArray<SaveDataInfo, BufferAttr_HipcMapAlias> out_entries); | ||
| 39 | |||
| 40 | private: | ||
| 41 | void FindAllSaves(FileSys::SaveDataSpaceId space); | ||
| 42 | void FindNormalSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 43 | void FindTemporaryStorageSaves(FileSys::SaveDataSpaceId space, const FileSys::VirtualDir& type); | ||
| 44 | |||
| 45 | std::shared_ptr<SaveDataController> save_data_controller; | ||
| 46 | std::vector<SaveDataInfo> info; | ||
| 47 | u64 next_entry_index = 0; | ||
| 48 | }; | ||
| 49 | |||
| 50 | } // namespace Service::FileSystem | ||
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp b/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp index 98223c1f9..213f19808 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp +++ b/src/core/hle/service/filesystem/fsp/fs_i_storage.cpp | |||
| @@ -2,61 +2,44 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/file_sys/errors.h" | 4 | #include "core/file_sys/errors.h" |
| 5 | #include "core/hle/service/cmif_serialization.h" | ||
| 5 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" | 6 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" |
| 6 | #include "core/hle/service/ipc_helpers.h" | ||
| 7 | 7 | ||
| 8 | namespace Service::FileSystem { | 8 | namespace Service::FileSystem { |
| 9 | 9 | ||
| 10 | IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_) | 10 | IStorage::IStorage(Core::System& system_, FileSys::VirtualFile backend_) |
| 11 | : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { | 11 | : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { |
| 12 | static const FunctionInfo functions[] = { | 12 | static const FunctionInfo functions[] = { |
| 13 | {0, &IStorage::Read, "Read"}, | 13 | {0, D<&IStorage::Read>, "Read"}, |
| 14 | {1, nullptr, "Write"}, | 14 | {1, nullptr, "Write"}, |
| 15 | {2, nullptr, "Flush"}, | 15 | {2, nullptr, "Flush"}, |
| 16 | {3, nullptr, "SetSize"}, | 16 | {3, nullptr, "SetSize"}, |
| 17 | {4, &IStorage::GetSize, "GetSize"}, | 17 | {4, D<&IStorage::GetSize>, "GetSize"}, |
| 18 | {5, nullptr, "OperateRange"}, | 18 | {5, nullptr, "OperateRange"}, |
| 19 | }; | 19 | }; |
| 20 | RegisterHandlers(functions); | 20 | RegisterHandlers(functions); |
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | void IStorage::Read(HLERequestContext& ctx) { | 23 | Result IStorage::Read( |
| 24 | IPC::RequestParser rp{ctx}; | 24 | OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes, |
| 25 | const s64 offset = rp.Pop<s64>(); | 25 | s64 offset, s64 length) { |
| 26 | const s64 length = rp.Pop<s64>(); | ||
| 27 | |||
| 28 | LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length); | 26 | LOG_DEBUG(Service_FS, "called, offset=0x{:X}, length={}", offset, length); |
| 29 | 27 | ||
| 30 | // Error checking | 28 | R_UNLESS(length >= 0, FileSys::ResultInvalidSize); |
| 31 | if (length < 0) { | 29 | R_UNLESS(offset >= 0, FileSys::ResultInvalidOffset); |
| 32 | LOG_ERROR(Service_FS, "Length is less than 0, length={}", length); | ||
| 33 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 34 | rb.Push(FileSys::ResultInvalidSize); | ||
| 35 | return; | ||
| 36 | } | ||
| 37 | if (offset < 0) { | ||
| 38 | LOG_ERROR(Service_FS, "Offset is less than 0, offset={}", offset); | ||
| 39 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 40 | rb.Push(FileSys::ResultInvalidOffset); | ||
| 41 | return; | ||
| 42 | } | ||
| 43 | 30 | ||
| 44 | // Read the data from the Storage backend | 31 | // Read the data from the Storage backend |
| 45 | std::vector<u8> output = backend->ReadBytes(length, offset); | 32 | backend->Read(out_bytes.data(), length, offset); |
| 46 | // Write the data to memory | ||
| 47 | ctx.WriteBuffer(output); | ||
| 48 | 33 | ||
| 49 | IPC::ResponseBuilder rb{ctx, 2}; | 34 | R_SUCCEED(); |
| 50 | rb.Push(ResultSuccess); | ||
| 51 | } | 35 | } |
| 52 | 36 | ||
| 53 | void IStorage::GetSize(HLERequestContext& ctx) { | 37 | Result IStorage::GetSize(Out<u64> out_size) { |
| 54 | const u64 size = backend->GetSize(); | 38 | *out_size = backend->GetSize(); |
| 55 | LOG_DEBUG(Service_FS, "called, size={}", size); | 39 | |
| 40 | LOG_DEBUG(Service_FS, "called, size={}", *out_size); | ||
| 56 | 41 | ||
| 57 | IPC::ResponseBuilder rb{ctx, 4}; | 42 | R_SUCCEED(); |
| 58 | rb.Push(ResultSuccess); | ||
| 59 | rb.Push<u64>(size); | ||
| 60 | } | 43 | } |
| 61 | 44 | ||
| 62 | } // namespace Service::FileSystem | 45 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp/fs_i_storage.h b/src/core/hle/service/filesystem/fsp/fs_i_storage.h index cb5bebcc9..74d879386 100644 --- a/src/core/hle/service/filesystem/fsp/fs_i_storage.h +++ b/src/core/hle/service/filesystem/fsp/fs_i_storage.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include "core/file_sys/vfs/vfs.h" | 6 | #include "core/file_sys/vfs/vfs.h" |
| 7 | #include "core/hle/service/cmif_types.h" | ||
| 7 | #include "core/hle/service/filesystem/filesystem.h" | 8 | #include "core/hle/service/filesystem/filesystem.h" |
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| @@ -16,8 +17,10 @@ public: | |||
| 16 | private: | 17 | private: |
| 17 | FileSys::VirtualFile backend; | 18 | FileSys::VirtualFile backend; |
| 18 | 19 | ||
| 19 | void Read(HLERequestContext& ctx); | 20 | Result Read( |
| 20 | void GetSize(HLERequestContext& ctx); | 21 | OutBuffer<BufferAttr_HipcMapAlias | BufferAttr_HipcMapTransferAllowsNonSecure> out_bytes, |
| 22 | s64 offset, s64 length); | ||
| 23 | Result GetSize(Out<u64> out_size); | ||
| 21 | }; | 24 | }; |
| 22 | 25 | ||
| 23 | } // namespace Service::FileSystem | 26 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp index 2d49f30c8..fc67a4713 100644 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.cpp | |||
| @@ -27,8 +27,11 @@ | |||
| 27 | #include "core/file_sys/system_archive/system_archive.h" | 27 | #include "core/file_sys/system_archive/system_archive.h" |
| 28 | #include "core/file_sys/vfs/vfs.h" | 28 | #include "core/file_sys/vfs/vfs.h" |
| 29 | #include "core/hle/result.h" | 29 | #include "core/hle/result.h" |
| 30 | #include "core/hle/service/cmif_serialization.h" | ||
| 30 | #include "core/hle/service/filesystem/filesystem.h" | 31 | #include "core/hle/service/filesystem/filesystem.h" |
| 31 | #include "core/hle/service/filesystem/fsp/fs_i_filesystem.h" | 32 | #include "core/hle/service/filesystem/fsp/fs_i_filesystem.h" |
| 33 | #include "core/hle/service/filesystem/fsp/fs_i_multi_commit_manager.h" | ||
| 34 | #include "core/hle/service/filesystem/fsp/fs_i_save_data_info_reader.h" | ||
| 32 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" | 35 | #include "core/hle/service/filesystem/fsp/fs_i_storage.h" |
| 33 | #include "core/hle/service/filesystem/fsp/fsp_srv.h" | 36 | #include "core/hle/service/filesystem/fsp/fsp_srv.h" |
| 34 | #include "core/hle/service/filesystem/romfs_controller.h" | 37 | #include "core/hle/service/filesystem/romfs_controller.h" |
| @@ -39,182 +42,6 @@ | |||
| 39 | #include "core/reporter.h" | 42 | #include "core/reporter.h" |
| 40 | 43 | ||
| 41 | namespace Service::FileSystem { | 44 | namespace Service::FileSystem { |
| 42 | enum class FileSystemProxyType : u8 { | ||
| 43 | Code = 0, | ||
| 44 | Rom = 1, | ||
| 45 | Logo = 2, | ||
| 46 | Control = 3, | ||
| 47 | Manual = 4, | ||
| 48 | Meta = 5, | ||
| 49 | Data = 6, | ||
| 50 | Package = 7, | ||
| 51 | RegisteredUpdate = 8, | ||
| 52 | }; | ||
| 53 | |||
| 54 | class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { | ||
| 55 | public: | ||
| 56 | explicit ISaveDataInfoReader(Core::System& system_, | ||
| 57 | std::shared_ptr<SaveDataController> save_data_controller_, | ||
| 58 | FileSys::SaveDataSpaceId space) | ||
| 59 | : ServiceFramework{system_, "ISaveDataInfoReader"}, save_data_controller{ | ||
| 60 | save_data_controller_} { | ||
| 61 | static const FunctionInfo functions[] = { | ||
| 62 | {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, | ||
| 63 | }; | ||
| 64 | RegisterHandlers(functions); | ||
| 65 | |||
| 66 | FindAllSaves(space); | ||
| 67 | } | ||
| 68 | |||
| 69 | void ReadSaveDataInfo(HLERequestContext& ctx) { | ||
| 70 | LOG_DEBUG(Service_FS, "called"); | ||
| 71 | |||
| 72 | // Calculate how many entries we can fit in the output buffer | ||
| 73 | const u64 count_entries = ctx.GetWriteBufferNumElements<SaveDataInfo>(); | ||
| 74 | |||
| 75 | // Cap at total number of entries. | ||
| 76 | const u64 actual_entries = std::min(count_entries, info.size() - next_entry_index); | ||
| 77 | |||
| 78 | // Determine data start and end | ||
| 79 | const auto* begin = reinterpret_cast<u8*>(info.data() + next_entry_index); | ||
| 80 | const auto* end = reinterpret_cast<u8*>(info.data() + next_entry_index + actual_entries); | ||
| 81 | const auto range_size = static_cast<std::size_t>(std::distance(begin, end)); | ||
| 82 | |||
| 83 | next_entry_index += actual_entries; | ||
| 84 | |||
| 85 | // Write the data to memory | ||
| 86 | ctx.WriteBuffer(begin, range_size); | ||
| 87 | |||
| 88 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 89 | rb.Push(ResultSuccess); | ||
| 90 | rb.Push<u64>(actual_entries); | ||
| 91 | } | ||
| 92 | |||
| 93 | private: | ||
| 94 | static u64 stoull_be(std::string_view str) { | ||
| 95 | if (str.size() != 16) | ||
| 96 | return 0; | ||
| 97 | |||
| 98 | const auto bytes = Common::HexStringToArray<0x8>(str); | ||
| 99 | u64 out{}; | ||
| 100 | std::memcpy(&out, bytes.data(), sizeof(u64)); | ||
| 101 | |||
| 102 | return Common::swap64(out); | ||
| 103 | } | ||
| 104 | |||
| 105 | void FindAllSaves(FileSys::SaveDataSpaceId space) { | ||
| 106 | FileSys::VirtualDir save_root{}; | ||
| 107 | const auto result = save_data_controller->OpenSaveDataSpace(&save_root, space); | ||
| 108 | |||
| 109 | if (result != ResultSuccess || save_root == nullptr) { | ||
| 110 | LOG_ERROR(Service_FS, "The save root for the space_id={:02X} was invalid!", space); | ||
| 111 | return; | ||
| 112 | } | ||
| 113 | |||
| 114 | for (const auto& type : save_root->GetSubdirectories()) { | ||
| 115 | if (type->GetName() == "save") { | ||
| 116 | for (const auto& save_id : type->GetSubdirectories()) { | ||
| 117 | for (const auto& user_id : save_id->GetSubdirectories()) { | ||
| 118 | // Skip non user id subdirectories | ||
| 119 | if (user_id->GetName().size() != 0x20) { | ||
| 120 | continue; | ||
| 121 | } | ||
| 122 | |||
| 123 | const auto save_id_numeric = stoull_be(save_id->GetName()); | ||
| 124 | auto user_id_numeric = Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 125 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 126 | |||
| 127 | if (save_id_numeric != 0) { | ||
| 128 | // System Save Data | ||
| 129 | info.emplace_back(SaveDataInfo{ | ||
| 130 | 0, | ||
| 131 | space, | ||
| 132 | FileSys::SaveDataType::SystemSaveData, | ||
| 133 | {}, | ||
| 134 | user_id_numeric, | ||
| 135 | save_id_numeric, | ||
| 136 | 0, | ||
| 137 | user_id->GetSize(), | ||
| 138 | {}, | ||
| 139 | {}, | ||
| 140 | }); | ||
| 141 | |||
| 142 | continue; | ||
| 143 | } | ||
| 144 | |||
| 145 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 146 | const auto device = | ||
| 147 | std::all_of(user_id_numeric.begin(), user_id_numeric.end(), | ||
| 148 | [](u8 val) { return val == 0; }); | ||
| 149 | info.emplace_back(SaveDataInfo{ | ||
| 150 | 0, | ||
| 151 | space, | ||
| 152 | device ? FileSys::SaveDataType::DeviceSaveData | ||
| 153 | : FileSys::SaveDataType::SaveData, | ||
| 154 | {}, | ||
| 155 | user_id_numeric, | ||
| 156 | save_id_numeric, | ||
| 157 | stoull_be(title_id->GetName()), | ||
| 158 | title_id->GetSize(), | ||
| 159 | {}, | ||
| 160 | {}, | ||
| 161 | }); | ||
| 162 | } | ||
| 163 | } | ||
| 164 | } | ||
| 165 | } else if (space == FileSys::SaveDataSpaceId::TemporaryStorage) { | ||
| 166 | // Temporary Storage | ||
| 167 | for (const auto& user_id : type->GetSubdirectories()) { | ||
| 168 | // Skip non user id subdirectories | ||
| 169 | if (user_id->GetName().size() != 0x20) { | ||
| 170 | continue; | ||
| 171 | } | ||
| 172 | for (const auto& title_id : user_id->GetSubdirectories()) { | ||
| 173 | if (!title_id->GetFiles().empty() || | ||
| 174 | !title_id->GetSubdirectories().empty()) { | ||
| 175 | auto user_id_numeric = | ||
| 176 | Common::HexStringToArray<0x10>(user_id->GetName()); | ||
| 177 | std::reverse(user_id_numeric.begin(), user_id_numeric.end()); | ||
| 178 | |||
| 179 | info.emplace_back(SaveDataInfo{ | ||
| 180 | 0, | ||
| 181 | space, | ||
| 182 | FileSys::SaveDataType::TemporaryStorage, | ||
| 183 | {}, | ||
| 184 | user_id_numeric, | ||
| 185 | stoull_be(type->GetName()), | ||
| 186 | stoull_be(title_id->GetName()), | ||
| 187 | title_id->GetSize(), | ||
| 188 | {}, | ||
| 189 | {}, | ||
| 190 | }); | ||
| 191 | } | ||
| 192 | } | ||
| 193 | } | ||
| 194 | } | ||
| 195 | } | ||
| 196 | } | ||
| 197 | |||
| 198 | struct SaveDataInfo { | ||
| 199 | u64_le save_id_unknown; | ||
| 200 | FileSys::SaveDataSpaceId space; | ||
| 201 | FileSys::SaveDataType type; | ||
| 202 | INSERT_PADDING_BYTES(0x6); | ||
| 203 | std::array<u8, 0x10> user_id; | ||
| 204 | u64_le save_id; | ||
| 205 | u64_le title_id; | ||
| 206 | u64_le save_image_size; | ||
| 207 | u16_le index; | ||
| 208 | FileSys::SaveDataRank rank; | ||
| 209 | INSERT_PADDING_BYTES(0x25); | ||
| 210 | }; | ||
| 211 | static_assert(sizeof(SaveDataInfo) == 0x60, "SaveDataInfo has incorrect size."); | ||
| 212 | |||
| 213 | ProcessId process_id = 0; | ||
| 214 | std::shared_ptr<SaveDataController> save_data_controller; | ||
| 215 | std::vector<SaveDataInfo> info; | ||
| 216 | u64 next_entry_index = 0; | ||
| 217 | }; | ||
| 218 | 45 | ||
| 219 | FSP_SRV::FSP_SRV(Core::System& system_) | 46 | FSP_SRV::FSP_SRV(Core::System& system_) |
| 220 | : ServiceFramework{system_, "fsp-srv"}, fsc{system.GetFileSystemController()}, | 47 | : ServiceFramework{system_, "fsp-srv"}, fsc{system.GetFileSystemController()}, |
| @@ -222,20 +49,20 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 222 | // clang-format off | 49 | // clang-format off |
| 223 | static const FunctionInfo functions[] = { | 50 | static const FunctionInfo functions[] = { |
| 224 | {0, nullptr, "OpenFileSystem"}, | 51 | {0, nullptr, "OpenFileSystem"}, |
| 225 | {1, &FSP_SRV::SetCurrentProcess, "SetCurrentProcess"}, | 52 | {1, D<&FSP_SRV::SetCurrentProcess>, "SetCurrentProcess"}, |
| 226 | {2, nullptr, "OpenDataFileSystemByCurrentProcess"}, | 53 | {2, nullptr, "OpenDataFileSystemByCurrentProcess"}, |
| 227 | {7, &FSP_SRV::OpenFileSystemWithPatch, "OpenFileSystemWithPatch"}, | 54 | {7, D<&FSP_SRV::OpenFileSystemWithPatch>, "OpenFileSystemWithPatch"}, |
| 228 | {8, nullptr, "OpenFileSystemWithId"}, | 55 | {8, nullptr, "OpenFileSystemWithId"}, |
| 229 | {9, nullptr, "OpenDataFileSystemByApplicationId"}, | 56 | {9, nullptr, "OpenDataFileSystemByApplicationId"}, |
| 230 | {11, nullptr, "OpenBisFileSystem"}, | 57 | {11, nullptr, "OpenBisFileSystem"}, |
| 231 | {12, nullptr, "OpenBisStorage"}, | 58 | {12, nullptr, "OpenBisStorage"}, |
| 232 | {13, nullptr, "InvalidateBisCache"}, | 59 | {13, nullptr, "InvalidateBisCache"}, |
| 233 | {17, nullptr, "OpenHostFileSystem"}, | 60 | {17, nullptr, "OpenHostFileSystem"}, |
| 234 | {18, &FSP_SRV::OpenSdCardFileSystem, "OpenSdCardFileSystem"}, | 61 | {18, D<&FSP_SRV::OpenSdCardFileSystem>, "OpenSdCardFileSystem"}, |
| 235 | {19, nullptr, "FormatSdCardFileSystem"}, | 62 | {19, nullptr, "FormatSdCardFileSystem"}, |
| 236 | {21, nullptr, "DeleteSaveDataFileSystem"}, | 63 | {21, nullptr, "DeleteSaveDataFileSystem"}, |
| 237 | {22, &FSP_SRV::CreateSaveDataFileSystem, "CreateSaveDataFileSystem"}, | 64 | {22, D<&FSP_SRV::CreateSaveDataFileSystem>, "CreateSaveDataFileSystem"}, |
| 238 | {23, &FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId, "CreateSaveDataFileSystemBySystemSaveDataId"}, | 65 | {23, D<&FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId>, "CreateSaveDataFileSystemBySystemSaveDataId"}, |
| 239 | {24, nullptr, "RegisterSaveDataFileSystemAtomicDeletion"}, | 66 | {24, nullptr, "RegisterSaveDataFileSystemAtomicDeletion"}, |
| 240 | {25, nullptr, "DeleteSaveDataFileSystemBySaveDataSpaceId"}, | 67 | {25, nullptr, "DeleteSaveDataFileSystemBySaveDataSpaceId"}, |
| 241 | {26, nullptr, "FormatSdCardDryRun"}, | 68 | {26, nullptr, "FormatSdCardDryRun"}, |
| @@ -245,26 +72,26 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 245 | {31, nullptr, "OpenGameCardFileSystem"}, | 72 | {31, nullptr, "OpenGameCardFileSystem"}, |
| 246 | {32, nullptr, "ExtendSaveDataFileSystem"}, | 73 | {32, nullptr, "ExtendSaveDataFileSystem"}, |
| 247 | {33, nullptr, "DeleteCacheStorage"}, | 74 | {33, nullptr, "DeleteCacheStorage"}, |
| 248 | {34, &FSP_SRV::GetCacheStorageSize, "GetCacheStorageSize"}, | 75 | {34, D<&FSP_SRV::GetCacheStorageSize>, "GetCacheStorageSize"}, |
| 249 | {35, nullptr, "CreateSaveDataFileSystemByHashSalt"}, | 76 | {35, nullptr, "CreateSaveDataFileSystemByHashSalt"}, |
| 250 | {36, nullptr, "OpenHostFileSystemWithOption"}, | 77 | {36, nullptr, "OpenHostFileSystemWithOption"}, |
| 251 | {51, &FSP_SRV::OpenSaveDataFileSystem, "OpenSaveDataFileSystem"}, | 78 | {51, D<&FSP_SRV::OpenSaveDataFileSystem>, "OpenSaveDataFileSystem"}, |
| 252 | {52, &FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId, "OpenSaveDataFileSystemBySystemSaveDataId"}, | 79 | {52, D<&FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId>, "OpenSaveDataFileSystemBySystemSaveDataId"}, |
| 253 | {53, &FSP_SRV::OpenReadOnlySaveDataFileSystem, "OpenReadOnlySaveDataFileSystem"}, | 80 | {53, D<&FSP_SRV::OpenReadOnlySaveDataFileSystem>, "OpenReadOnlySaveDataFileSystem"}, |
| 254 | {57, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataSpaceId"}, | 81 | {57, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataSpaceId"}, |
| 255 | {58, nullptr, "ReadSaveDataFileSystemExtraData"}, | 82 | {58, nullptr, "ReadSaveDataFileSystemExtraData"}, |
| 256 | {59, nullptr, "WriteSaveDataFileSystemExtraData"}, | 83 | {59, nullptr, "WriteSaveDataFileSystemExtraData"}, |
| 257 | {60, nullptr, "OpenSaveDataInfoReader"}, | 84 | {60, nullptr, "OpenSaveDataInfoReader"}, |
| 258 | {61, &FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId, "OpenSaveDataInfoReaderBySaveDataSpaceId"}, | 85 | {61, D<&FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId>, "OpenSaveDataInfoReaderBySaveDataSpaceId"}, |
| 259 | {62, &FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage, "OpenSaveDataInfoReaderOnlyCacheStorage"}, | 86 | {62, D<&FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage>, "OpenSaveDataInfoReaderOnlyCacheStorage"}, |
| 260 | {64, nullptr, "OpenSaveDataInternalStorageFileSystem"}, | 87 | {64, nullptr, "OpenSaveDataInternalStorageFileSystem"}, |
| 261 | {65, nullptr, "UpdateSaveDataMacForDebug"}, | 88 | {65, nullptr, "UpdateSaveDataMacForDebug"}, |
| 262 | {66, nullptr, "WriteSaveDataFileSystemExtraData2"}, | 89 | {66, nullptr, "WriteSaveDataFileSystemExtraData2"}, |
| 263 | {67, nullptr, "FindSaveDataWithFilter"}, | 90 | {67, nullptr, "FindSaveDataWithFilter"}, |
| 264 | {68, nullptr, "OpenSaveDataInfoReaderBySaveDataFilter"}, | 91 | {68, nullptr, "OpenSaveDataInfoReaderBySaveDataFilter"}, |
| 265 | {69, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataAttribute"}, | 92 | {69, nullptr, "ReadSaveDataFileSystemExtraDataBySaveDataAttribute"}, |
| 266 | {70, &FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute, "WriteSaveDataFileSystemExtraDataBySaveDataAttribute"}, | 93 | {70, D<&FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute>, "WriteSaveDataFileSystemExtraDataBySaveDataAttribute"}, |
| 267 | {71, &FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute, "ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute"}, | 94 | {71, D<&FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute>, "ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute"}, |
| 268 | {80, nullptr, "OpenSaveDataMetaFile"}, | 95 | {80, nullptr, "OpenSaveDataMetaFile"}, |
| 269 | {81, nullptr, "OpenSaveDataTransferManager"}, | 96 | {81, nullptr, "OpenSaveDataTransferManager"}, |
| 270 | {82, nullptr, "OpenSaveDataTransferManagerVersion2"}, | 97 | {82, nullptr, "OpenSaveDataTransferManagerVersion2"}, |
| @@ -279,12 +106,12 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 279 | {110, nullptr, "OpenContentStorageFileSystem"}, | 106 | {110, nullptr, "OpenContentStorageFileSystem"}, |
| 280 | {120, nullptr, "OpenCloudBackupWorkStorageFileSystem"}, | 107 | {120, nullptr, "OpenCloudBackupWorkStorageFileSystem"}, |
| 281 | {130, nullptr, "OpenCustomStorageFileSystem"}, | 108 | {130, nullptr, "OpenCustomStorageFileSystem"}, |
| 282 | {200, &FSP_SRV::OpenDataStorageByCurrentProcess, "OpenDataStorageByCurrentProcess"}, | 109 | {200, D<&FSP_SRV::OpenDataStorageByCurrentProcess>, "OpenDataStorageByCurrentProcess"}, |
| 283 | {201, nullptr, "OpenDataStorageByProgramId"}, | 110 | {201, nullptr, "OpenDataStorageByProgramId"}, |
| 284 | {202, &FSP_SRV::OpenDataStorageByDataId, "OpenDataStorageByDataId"}, | 111 | {202, D<&FSP_SRV::OpenDataStorageByDataId>, "OpenDataStorageByDataId"}, |
| 285 | {203, &FSP_SRV::OpenPatchDataStorageByCurrentProcess, "OpenPatchDataStorageByCurrentProcess"}, | 112 | {203, D<&FSP_SRV::OpenPatchDataStorageByCurrentProcess>, "OpenPatchDataStorageByCurrentProcess"}, |
| 286 | {204, nullptr, "OpenDataFileSystemByProgramIndex"}, | 113 | {204, nullptr, "OpenDataFileSystemByProgramIndex"}, |
| 287 | {205, &FSP_SRV::OpenDataStorageWithProgramIndex, "OpenDataStorageWithProgramIndex"}, | 114 | {205, D<&FSP_SRV::OpenDataStorageWithProgramIndex>, "OpenDataStorageWithProgramIndex"}, |
| 288 | {206, nullptr, "OpenDataStorageByPath"}, | 115 | {206, nullptr, "OpenDataStorageByPath"}, |
| 289 | {400, nullptr, "OpenDeviceOperator"}, | 116 | {400, nullptr, "OpenDeviceOperator"}, |
| 290 | {500, nullptr, "OpenSdCardDetectionEventNotifier"}, | 117 | {500, nullptr, "OpenSdCardDetectionEventNotifier"}, |
| @@ -324,25 +151,25 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 324 | {1000, nullptr, "SetBisRootForHost"}, | 151 | {1000, nullptr, "SetBisRootForHost"}, |
| 325 | {1001, nullptr, "SetSaveDataSize"}, | 152 | {1001, nullptr, "SetSaveDataSize"}, |
| 326 | {1002, nullptr, "SetSaveDataRootPath"}, | 153 | {1002, nullptr, "SetSaveDataRootPath"}, |
| 327 | {1003, &FSP_SRV::DisableAutoSaveDataCreation, "DisableAutoSaveDataCreation"}, | 154 | {1003, D<&FSP_SRV::DisableAutoSaveDataCreation>, "DisableAutoSaveDataCreation"}, |
| 328 | {1004, &FSP_SRV::SetGlobalAccessLogMode, "SetGlobalAccessLogMode"}, | 155 | {1004, D<&FSP_SRV::SetGlobalAccessLogMode>, "SetGlobalAccessLogMode"}, |
| 329 | {1005, &FSP_SRV::GetGlobalAccessLogMode, "GetGlobalAccessLogMode"}, | 156 | {1005, D<&FSP_SRV::GetGlobalAccessLogMode>, "GetGlobalAccessLogMode"}, |
| 330 | {1006, &FSP_SRV::OutputAccessLogToSdCard, "OutputAccessLogToSdCard"}, | 157 | {1006, D<&FSP_SRV::OutputAccessLogToSdCard>, "OutputAccessLogToSdCard"}, |
| 331 | {1007, nullptr, "RegisterUpdatePartition"}, | 158 | {1007, nullptr, "RegisterUpdatePartition"}, |
| 332 | {1008, nullptr, "OpenRegisteredUpdatePartition"}, | 159 | {1008, nullptr, "OpenRegisteredUpdatePartition"}, |
| 333 | {1009, nullptr, "GetAndClearMemoryReportInfo"}, | 160 | {1009, nullptr, "GetAndClearMemoryReportInfo"}, |
| 334 | {1010, nullptr, "SetDataStorageRedirectTarget"}, | 161 | {1010, nullptr, "SetDataStorageRedirectTarget"}, |
| 335 | {1011, &FSP_SRV::GetProgramIndexForAccessLog, "GetProgramIndexForAccessLog"}, | 162 | {1011, D<&FSP_SRV::GetProgramIndexForAccessLog>, "GetProgramIndexForAccessLog"}, |
| 336 | {1012, nullptr, "GetFsStackUsage"}, | 163 | {1012, nullptr, "GetFsStackUsage"}, |
| 337 | {1013, nullptr, "UnsetSaveDataRootPath"}, | 164 | {1013, nullptr, "UnsetSaveDataRootPath"}, |
| 338 | {1014, nullptr, "OutputMultiProgramTagAccessLog"}, | 165 | {1014, nullptr, "OutputMultiProgramTagAccessLog"}, |
| 339 | {1016, &FSP_SRV::FlushAccessLogOnSdCard, "FlushAccessLogOnSdCard"}, | 166 | {1016, D<&FSP_SRV::FlushAccessLogOnSdCard>, "FlushAccessLogOnSdCard"}, |
| 340 | {1017, nullptr, "OutputApplicationInfoAccessLog"}, | 167 | {1017, nullptr, "OutputApplicationInfoAccessLog"}, |
| 341 | {1018, nullptr, "SetDebugOption"}, | 168 | {1018, nullptr, "SetDebugOption"}, |
| 342 | {1019, nullptr, "UnsetDebugOption"}, | 169 | {1019, nullptr, "UnsetDebugOption"}, |
| 343 | {1100, nullptr, "OverrideSaveDataTransferTokenSignVerificationKey"}, | 170 | {1100, nullptr, "OverrideSaveDataTransferTokenSignVerificationKey"}, |
| 344 | {1110, nullptr, "CorruptSaveDataFileSystemBySaveDataSpaceId2"}, | 171 | {1110, nullptr, "CorruptSaveDataFileSystemBySaveDataSpaceId2"}, |
| 345 | {1200, &FSP_SRV::OpenMultiCommitManager, "OpenMultiCommitManager"}, | 172 | {1200, D<&FSP_SRV::OpenMultiCommitManager>, "OpenMultiCommitManager"}, |
| 346 | {1300, nullptr, "OpenBisWiper"}, | 173 | {1300, nullptr, "OpenBisWiper"}, |
| 347 | }; | 174 | }; |
| 348 | // clang-format on | 175 | // clang-format on |
| @@ -355,234 +182,177 @@ FSP_SRV::FSP_SRV(Core::System& system_) | |||
| 355 | 182 | ||
| 356 | FSP_SRV::~FSP_SRV() = default; | 183 | FSP_SRV::~FSP_SRV() = default; |
| 357 | 184 | ||
| 358 | void FSP_SRV::SetCurrentProcess(HLERequestContext& ctx) { | 185 | Result FSP_SRV::SetCurrentProcess(ClientProcessId pid) { |
| 359 | current_process_id = ctx.GetPID(); | 186 | current_process_id = *pid; |
| 360 | 187 | ||
| 361 | LOG_DEBUG(Service_FS, "called. current_process_id=0x{:016X}", current_process_id); | 188 | LOG_DEBUG(Service_FS, "called. current_process_id=0x{:016X}", current_process_id); |
| 362 | 189 | ||
| 363 | const auto res = | 190 | R_RETURN( |
| 364 | fsc.OpenProcess(&program_id, &save_data_controller, &romfs_controller, current_process_id); | 191 | fsc.OpenProcess(&program_id, &save_data_controller, &romfs_controller, current_process_id)); |
| 365 | |||
| 366 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 367 | rb.Push(res); | ||
| 368 | } | 192 | } |
| 369 | 193 | ||
| 370 | void FSP_SRV::OpenFileSystemWithPatch(HLERequestContext& ctx) { | 194 | Result FSP_SRV::OpenFileSystemWithPatch(OutInterface<IFileSystem> out_interface, |
| 371 | IPC::RequestParser rp{ctx}; | 195 | FileSystemProxyType type, u64 open_program_id) { |
| 372 | 196 | LOG_ERROR(Service_FS, "(STUBBED) called with type={}, program_id={:016X}", type, | |
| 373 | struct InputParameters { | 197 | open_program_id); |
| 374 | FileSystemProxyType type; | ||
| 375 | u64 program_id; | ||
| 376 | }; | ||
| 377 | static_assert(sizeof(InputParameters) == 0x10, "InputParameters has wrong size"); | ||
| 378 | |||
| 379 | const auto params = rp.PopRaw<InputParameters>(); | ||
| 380 | LOG_ERROR(Service_FS, "(STUBBED) called with type={}, program_id={:016X}", params.type, | ||
| 381 | params.program_id); | ||
| 382 | 198 | ||
| 383 | // FIXME: many issues with this | 199 | // FIXME: many issues with this |
| 384 | ASSERT(params.type == FileSystemProxyType::Manual); | 200 | ASSERT(type == FileSystemProxyType::Manual); |
| 385 | const auto manual_romfs = romfs_controller->OpenPatchedRomFS( | 201 | const auto manual_romfs = romfs_controller->OpenPatchedRomFS( |
| 386 | params.program_id, FileSys::ContentRecordType::HtmlDocument); | 202 | open_program_id, FileSys::ContentRecordType::HtmlDocument); |
| 387 | 203 | ||
| 388 | ASSERT(manual_romfs != nullptr); | 204 | ASSERT(manual_romfs != nullptr); |
| 389 | 205 | ||
| 390 | const auto extracted_romfs = FileSys::ExtractRomFS(manual_romfs); | 206 | const auto extracted_romfs = FileSys::ExtractRomFS(manual_romfs); |
| 391 | ASSERT(extracted_romfs != nullptr); | 207 | ASSERT(extracted_romfs != nullptr); |
| 392 | 208 | ||
| 393 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 209 | *out_interface = std::make_shared<IFileSystem>( |
| 394 | rb.Push(ResultSuccess); | 210 | system, extracted_romfs, SizeGetter::FromStorageId(fsc, FileSys::StorageId::NandUser)); |
| 395 | rb.PushIpcInterface<IFileSystem>(system, extracted_romfs, | 211 | |
| 396 | SizeGetter::FromStorageId(fsc, FileSys::StorageId::NandUser)); | 212 | R_SUCCEED(); |
| 397 | } | 213 | } |
| 398 | 214 | ||
| 399 | void FSP_SRV::OpenSdCardFileSystem(HLERequestContext& ctx) { | 215 | Result FSP_SRV::OpenSdCardFileSystem(OutInterface<IFileSystem> out_interface) { |
| 400 | LOG_DEBUG(Service_FS, "called"); | 216 | LOG_DEBUG(Service_FS, "called"); |
| 401 | 217 | ||
| 402 | FileSys::VirtualDir sdmc_dir{}; | 218 | FileSys::VirtualDir sdmc_dir{}; |
| 403 | fsc.OpenSDMC(&sdmc_dir); | 219 | fsc.OpenSDMC(&sdmc_dir); |
| 404 | 220 | ||
| 405 | auto filesystem = std::make_shared<IFileSystem>( | 221 | *out_interface = std::make_shared<IFileSystem>( |
| 406 | system, sdmc_dir, SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard)); | 222 | system, sdmc_dir, SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard)); |
| 407 | 223 | ||
| 408 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 224 | R_SUCCEED(); |
| 409 | rb.Push(ResultSuccess); | ||
| 410 | rb.PushIpcInterface<IFileSystem>(std::move(filesystem)); | ||
| 411 | } | 225 | } |
| 412 | 226 | ||
| 413 | void FSP_SRV::CreateSaveDataFileSystem(HLERequestContext& ctx) { | 227 | Result FSP_SRV::CreateSaveDataFileSystem(FileSys::SaveDataCreationInfo save_create_struct, |
| 414 | IPC::RequestParser rp{ctx}; | 228 | FileSys::SaveDataAttribute save_struct, u128 uid) { |
| 415 | |||
| 416 | auto save_struct = rp.PopRaw<FileSys::SaveDataAttribute>(); | ||
| 417 | [[maybe_unused]] auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>(); | ||
| 418 | u128 uid = rp.PopRaw<u128>(); | ||
| 419 | |||
| 420 | LOG_DEBUG(Service_FS, "called save_struct = {}, uid = {:016X}{:016X}", save_struct.DebugInfo(), | 229 | LOG_DEBUG(Service_FS, "called save_struct = {}, uid = {:016X}{:016X}", save_struct.DebugInfo(), |
| 421 | uid[1], uid[0]); | 230 | uid[1], uid[0]); |
| 422 | 231 | ||
| 423 | FileSys::VirtualDir save_data_dir{}; | 232 | FileSys::VirtualDir save_data_dir{}; |
| 424 | save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandUser, | 233 | R_RETURN(save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::User, |
| 425 | save_struct); | 234 | save_struct)); |
| 426 | |||
| 427 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 428 | rb.Push(ResultSuccess); | ||
| 429 | } | 235 | } |
| 430 | 236 | ||
| 431 | void FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx) { | 237 | Result FSP_SRV::CreateSaveDataFileSystemBySystemSaveDataId( |
| 432 | IPC::RequestParser rp{ctx}; | 238 | FileSys::SaveDataCreationInfo save_create_struct, FileSys::SaveDataAttribute save_struct) { |
| 433 | |||
| 434 | auto save_struct = rp.PopRaw<FileSys::SaveDataAttribute>(); | ||
| 435 | [[maybe_unused]] auto save_create_struct = rp.PopRaw<std::array<u8, 0x40>>(); | ||
| 436 | |||
| 437 | LOG_DEBUG(Service_FS, "called save_struct = {}", save_struct.DebugInfo()); | 239 | LOG_DEBUG(Service_FS, "called save_struct = {}", save_struct.DebugInfo()); |
| 438 | 240 | ||
| 439 | FileSys::VirtualDir save_data_dir{}; | 241 | FileSys::VirtualDir save_data_dir{}; |
| 440 | save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::NandSystem, | 242 | R_RETURN(save_data_controller->CreateSaveData(&save_data_dir, FileSys::SaveDataSpaceId::System, |
| 441 | save_struct); | 243 | save_struct)); |
| 442 | |||
| 443 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 444 | rb.Push(ResultSuccess); | ||
| 445 | } | 244 | } |
| 446 | 245 | ||
| 447 | void FSP_SRV::OpenSaveDataFileSystem(HLERequestContext& ctx) { | 246 | Result FSP_SRV::OpenSaveDataFileSystem(OutInterface<IFileSystem> out_interface, |
| 448 | IPC::RequestParser rp{ctx}; | 247 | FileSys::SaveDataSpaceId space_id, |
| 449 | 248 | FileSys::SaveDataAttribute attribute) { | |
| 450 | struct Parameters { | ||
| 451 | FileSys::SaveDataSpaceId space_id; | ||
| 452 | FileSys::SaveDataAttribute attribute; | ||
| 453 | }; | ||
| 454 | |||
| 455 | const auto parameters = rp.PopRaw<Parameters>(); | ||
| 456 | |||
| 457 | LOG_INFO(Service_FS, "called."); | 249 | LOG_INFO(Service_FS, "called."); |
| 458 | 250 | ||
| 459 | FileSys::VirtualDir dir{}; | 251 | FileSys::VirtualDir dir{}; |
| 460 | auto result = | 252 | R_TRY(save_data_controller->OpenSaveData(&dir, space_id, attribute)); |
| 461 | save_data_controller->OpenSaveData(&dir, parameters.space_id, parameters.attribute); | ||
| 462 | if (result != ResultSuccess) { | ||
| 463 | IPC::ResponseBuilder rb{ctx, 2, 0, 0}; | ||
| 464 | rb.Push(FileSys::ResultTargetNotFound); | ||
| 465 | return; | ||
| 466 | } | ||
| 467 | 253 | ||
| 468 | FileSys::StorageId id{}; | 254 | FileSys::StorageId id{}; |
| 469 | switch (parameters.space_id) { | 255 | switch (space_id) { |
| 470 | case FileSys::SaveDataSpaceId::NandUser: | 256 | case FileSys::SaveDataSpaceId::User: |
| 471 | id = FileSys::StorageId::NandUser; | 257 | id = FileSys::StorageId::NandUser; |
| 472 | break; | 258 | break; |
| 473 | case FileSys::SaveDataSpaceId::SdCardSystem: | 259 | case FileSys::SaveDataSpaceId::SdSystem: |
| 474 | case FileSys::SaveDataSpaceId::SdCardUser: | 260 | case FileSys::SaveDataSpaceId::SdUser: |
| 475 | id = FileSys::StorageId::SdCard; | 261 | id = FileSys::StorageId::SdCard; |
| 476 | break; | 262 | break; |
| 477 | case FileSys::SaveDataSpaceId::NandSystem: | 263 | case FileSys::SaveDataSpaceId::System: |
| 478 | id = FileSys::StorageId::NandSystem; | 264 | id = FileSys::StorageId::NandSystem; |
| 479 | break; | 265 | break; |
| 480 | case FileSys::SaveDataSpaceId::TemporaryStorage: | 266 | case FileSys::SaveDataSpaceId::Temporary: |
| 481 | case FileSys::SaveDataSpaceId::ProperSystem: | 267 | case FileSys::SaveDataSpaceId::ProperSystem: |
| 482 | case FileSys::SaveDataSpaceId::SafeMode: | 268 | case FileSys::SaveDataSpaceId::SafeMode: |
| 483 | ASSERT(false); | 269 | ASSERT(false); |
| 484 | } | 270 | } |
| 485 | 271 | ||
| 486 | auto filesystem = | 272 | *out_interface = |
| 487 | std::make_shared<IFileSystem>(system, std::move(dir), SizeGetter::FromStorageId(fsc, id)); | 273 | std::make_shared<IFileSystem>(system, std::move(dir), SizeGetter::FromStorageId(fsc, id)); |
| 488 | 274 | ||
| 489 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 275 | R_SUCCEED(); |
| 490 | rb.Push(ResultSuccess); | ||
| 491 | rb.PushIpcInterface<IFileSystem>(std::move(filesystem)); | ||
| 492 | } | 276 | } |
| 493 | 277 | ||
| 494 | void FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx) { | 278 | Result FSP_SRV::OpenSaveDataFileSystemBySystemSaveDataId(OutInterface<IFileSystem> out_interface, |
| 279 | FileSys::SaveDataSpaceId space_id, | ||
| 280 | FileSys::SaveDataAttribute attribute) { | ||
| 495 | LOG_WARNING(Service_FS, "(STUBBED) called, delegating to 51 OpenSaveDataFilesystem"); | 281 | LOG_WARNING(Service_FS, "(STUBBED) called, delegating to 51 OpenSaveDataFilesystem"); |
| 496 | OpenSaveDataFileSystem(ctx); | 282 | R_RETURN(OpenSaveDataFileSystem(out_interface, space_id, attribute)); |
| 497 | } | 283 | } |
| 498 | 284 | ||
| 499 | void FSP_SRV::OpenReadOnlySaveDataFileSystem(HLERequestContext& ctx) { | 285 | Result FSP_SRV::OpenReadOnlySaveDataFileSystem(OutInterface<IFileSystem> out_interface, |
| 286 | FileSys::SaveDataSpaceId space_id, | ||
| 287 | FileSys::SaveDataAttribute attribute) { | ||
| 500 | LOG_WARNING(Service_FS, "(STUBBED) called, delegating to 51 OpenSaveDataFilesystem"); | 288 | LOG_WARNING(Service_FS, "(STUBBED) called, delegating to 51 OpenSaveDataFilesystem"); |
| 501 | OpenSaveDataFileSystem(ctx); | 289 | R_RETURN(OpenSaveDataFileSystem(out_interface, space_id, attribute)); |
| 502 | } | 290 | } |
| 503 | 291 | ||
| 504 | void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(HLERequestContext& ctx) { | 292 | Result FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId( |
| 505 | IPC::RequestParser rp{ctx}; | 293 | OutInterface<ISaveDataInfoReader> out_interface, FileSys::SaveDataSpaceId space) { |
| 506 | const auto space = rp.PopRaw<FileSys::SaveDataSpaceId>(); | ||
| 507 | LOG_INFO(Service_FS, "called, space={}", space); | 294 | LOG_INFO(Service_FS, "called, space={}", space); |
| 508 | 295 | ||
| 509 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 296 | *out_interface = std::make_shared<ISaveDataInfoReader>(system, save_data_controller, space); |
| 510 | rb.Push(ResultSuccess); | 297 | |
| 511 | rb.PushIpcInterface<ISaveDataInfoReader>( | 298 | R_SUCCEED(); |
| 512 | std::make_shared<ISaveDataInfoReader>(system, save_data_controller, space)); | ||
| 513 | } | 299 | } |
| 514 | 300 | ||
| 515 | void FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage(HLERequestContext& ctx) { | 301 | Result FSP_SRV::OpenSaveDataInfoReaderOnlyCacheStorage( |
| 302 | OutInterface<ISaveDataInfoReader> out_interface) { | ||
| 516 | LOG_WARNING(Service_FS, "(STUBBED) called"); | 303 | LOG_WARNING(Service_FS, "(STUBBED) called"); |
| 517 | 304 | ||
| 518 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 305 | *out_interface = std::make_shared<ISaveDataInfoReader>(system, save_data_controller, |
| 519 | rb.Push(ResultSuccess); | 306 | FileSys::SaveDataSpaceId::Temporary); |
| 520 | rb.PushIpcInterface<ISaveDataInfoReader>(system, save_data_controller, | 307 | |
| 521 | FileSys::SaveDataSpaceId::TemporaryStorage); | 308 | R_SUCCEED(); |
| 522 | } | 309 | } |
| 523 | 310 | ||
| 524 | void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(HLERequestContext& ctx) { | 311 | Result FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute() { |
| 525 | LOG_WARNING(Service_FS, "(STUBBED) called."); | 312 | LOG_WARNING(Service_FS, "(STUBBED) called."); |
| 526 | 313 | ||
| 527 | IPC::ResponseBuilder rb{ctx, 2}; | 314 | R_SUCCEED(); |
| 528 | rb.Push(ResultSuccess); | ||
| 529 | } | 315 | } |
| 530 | 316 | ||
| 531 | void FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(HLERequestContext& ctx) { | 317 | Result FSP_SRV::ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( |
| 532 | IPC::RequestParser rp{ctx}; | 318 | FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute, |
| 533 | 319 | InBuffer<BufferAttr_HipcMapAlias> mask_buffer, OutBuffer<BufferAttr_HipcMapAlias> out_buffer) { | |
| 534 | struct Parameters { | ||
| 535 | FileSys::SaveDataSpaceId space_id; | ||
| 536 | FileSys::SaveDataAttribute attribute; | ||
| 537 | }; | ||
| 538 | |||
| 539 | const auto parameters = rp.PopRaw<Parameters>(); | ||
| 540 | // Stub this to None for now, backend needs an impl to read/write the SaveDataExtraData | 320 | // Stub this to None for now, backend needs an impl to read/write the SaveDataExtraData |
| 541 | constexpr auto flags = static_cast<u32>(FileSys::SaveDataFlags::None); | 321 | // In an earlier version of the code, this was returned as an out argument, but this is not |
| 322 | // correct | ||
| 323 | [[maybe_unused]] constexpr auto flags = static_cast<u32>(FileSys::SaveDataFlags::None); | ||
| 542 | 324 | ||
| 543 | LOG_WARNING(Service_FS, | 325 | LOG_WARNING(Service_FS, |
| 544 | "(STUBBED) called, flags={}, space_id={}, attribute.title_id={:016X}\n" | 326 | "(STUBBED) called, flags={}, space_id={}, attribute.program_id={:016X}\n" |
| 545 | "attribute.user_id={:016X}{:016X}, attribute.save_id={:016X}\n" | 327 | "attribute.user_id={:016X}{:016X}, attribute.save_id={:016X}\n" |
| 546 | "attribute.type={}, attribute.rank={}, attribute.index={}", | 328 | "attribute.type={}, attribute.rank={}, attribute.index={}", |
| 547 | flags, parameters.space_id, parameters.attribute.title_id, | 329 | flags, space_id, attribute.program_id, attribute.user_id[1], attribute.user_id[0], |
| 548 | parameters.attribute.user_id[1], parameters.attribute.user_id[0], | 330 | attribute.system_save_data_id, attribute.type, attribute.rank, attribute.index); |
| 549 | parameters.attribute.save_id, parameters.attribute.type, parameters.attribute.rank, | 331 | |
| 550 | parameters.attribute.index); | 332 | R_SUCCEED(); |
| 551 | |||
| 552 | IPC::ResponseBuilder rb{ctx, 3}; | ||
| 553 | rb.Push(ResultSuccess); | ||
| 554 | rb.Push(flags); | ||
| 555 | } | 333 | } |
| 556 | 334 | ||
| 557 | void FSP_SRV::OpenDataStorageByCurrentProcess(HLERequestContext& ctx) { | 335 | Result FSP_SRV::OpenDataStorageByCurrentProcess(OutInterface<IStorage> out_interface) { |
| 558 | LOG_DEBUG(Service_FS, "called"); | 336 | LOG_DEBUG(Service_FS, "called"); |
| 559 | 337 | ||
| 560 | if (!romfs) { | 338 | if (!romfs) { |
| 561 | auto current_romfs = romfs_controller->OpenRomFSCurrentProcess(); | 339 | auto current_romfs = romfs_controller->OpenRomFSCurrentProcess(); |
| 562 | if (!current_romfs) { | 340 | if (!current_romfs) { |
| 563 | // TODO (bunnei): Find the right error code to use here | 341 | // TODO (bunnei): Find the right error code to use here |
| 564 | LOG_CRITICAL(Service_FS, "no file system interface available!"); | 342 | LOG_CRITICAL(Service_FS, "No file system interface available!"); |
| 565 | IPC::ResponseBuilder rb{ctx, 2}; | 343 | R_RETURN(ResultUnknown); |
| 566 | rb.Push(ResultUnknown); | ||
| 567 | return; | ||
| 568 | } | 344 | } |
| 569 | 345 | ||
| 570 | romfs = current_romfs; | 346 | romfs = current_romfs; |
| 571 | } | 347 | } |
| 572 | 348 | ||
| 573 | auto storage = std::make_shared<IStorage>(system, romfs); | 349 | *out_interface = std::make_shared<IStorage>(system, romfs); |
| 574 | 350 | ||
| 575 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 351 | R_SUCCEED(); |
| 576 | rb.Push(ResultSuccess); | ||
| 577 | rb.PushIpcInterface<IStorage>(std::move(storage)); | ||
| 578 | } | 352 | } |
| 579 | 353 | ||
| 580 | void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) { | 354 | Result FSP_SRV::OpenDataStorageByDataId(OutInterface<IStorage> out_interface, |
| 581 | IPC::RequestParser rp{ctx}; | 355 | FileSys::StorageId storage_id, u32 unknown, u64 title_id) { |
| 582 | const auto storage_id = rp.PopRaw<FileSys::StorageId>(); | ||
| 583 | const auto unknown = rp.PopRaw<u32>(); | ||
| 584 | const auto title_id = rp.PopRaw<u64>(); | ||
| 585 | |||
| 586 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}", | 356 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, unknown={:08X}, title_id={:016X}", |
| 587 | storage_id, unknown, title_id); | 357 | storage_id, unknown, title_id); |
| 588 | 358 | ||
| @@ -592,19 +362,15 @@ void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) { | |||
| 592 | const auto archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id); | 362 | const auto archive = FileSys::SystemArchive::SynthesizeSystemArchive(title_id); |
| 593 | 363 | ||
| 594 | if (archive != nullptr) { | 364 | if (archive != nullptr) { |
| 595 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 365 | *out_interface = std::make_shared<IStorage>(system, archive); |
| 596 | rb.Push(ResultSuccess); | 366 | R_SUCCEED(); |
| 597 | rb.PushIpcInterface(std::make_shared<IStorage>(system, archive)); | ||
| 598 | return; | ||
| 599 | } | 367 | } |
| 600 | 368 | ||
| 601 | // TODO(DarkLordZach): Find the right error code to use here | 369 | // TODO(DarkLordZach): Find the right error code to use here |
| 602 | LOG_ERROR(Service_FS, | 370 | LOG_ERROR(Service_FS, |
| 603 | "could not open data storage with title_id={:016X}, storage_id={:02X}", title_id, | 371 | "Could not open data storage with title_id={:016X}, storage_id={:02X}", title_id, |
| 604 | storage_id); | 372 | storage_id); |
| 605 | IPC::ResponseBuilder rb{ctx, 2}; | 373 | R_RETURN(ResultUnknown); |
| 606 | rb.Push(ResultUnknown); | ||
| 607 | return; | ||
| 608 | } | 374 | } |
| 609 | 375 | ||
| 610 | const FileSys::PatchManager pm{title_id, fsc, content_provider}; | 376 | const FileSys::PatchManager pm{title_id, fsc, content_provider}; |
| @@ -614,28 +380,20 @@ void FSP_SRV::OpenDataStorageByDataId(HLERequestContext& ctx) { | |||
| 614 | auto storage = std::make_shared<IStorage>( | 380 | auto storage = std::make_shared<IStorage>( |
| 615 | system, pm.PatchRomFS(base.get(), std::move(data), FileSys::ContentRecordType::Data)); | 381 | system, pm.PatchRomFS(base.get(), std::move(data), FileSys::ContentRecordType::Data)); |
| 616 | 382 | ||
| 617 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 383 | *out_interface = std::move(storage); |
| 618 | rb.Push(ResultSuccess); | 384 | R_SUCCEED(); |
| 619 | rb.PushIpcInterface<IStorage>(std::move(storage)); | ||
| 620 | } | 385 | } |
| 621 | 386 | ||
| 622 | void FSP_SRV::OpenPatchDataStorageByCurrentProcess(HLERequestContext& ctx) { | 387 | Result FSP_SRV::OpenPatchDataStorageByCurrentProcess(OutInterface<IStorage> out_interface, |
| 623 | IPC::RequestParser rp{ctx}; | 388 | FileSys::StorageId storage_id, u64 title_id) { |
| 624 | 389 | LOG_WARNING(Service_FS, "(STUBBED) called with storage_id={:02X}, title_id={:016X}", storage_id, | |
| 625 | const auto storage_id = rp.PopRaw<FileSys::StorageId>(); | 390 | title_id); |
| 626 | const auto title_id = rp.PopRaw<u64>(); | ||
| 627 | 391 | ||
| 628 | LOG_DEBUG(Service_FS, "called with storage_id={:02X}, title_id={:016X}", storage_id, title_id); | 392 | R_RETURN(FileSys::ResultTargetNotFound); |
| 629 | |||
| 630 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 631 | rb.Push(FileSys::ResultTargetNotFound); | ||
| 632 | } | 393 | } |
| 633 | 394 | ||
| 634 | void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) { | 395 | Result FSP_SRV::OpenDataStorageWithProgramIndex(OutInterface<IStorage> out_interface, |
| 635 | IPC::RequestParser rp{ctx}; | 396 | u8 program_index) { |
| 636 | |||
| 637 | const auto program_index = rp.PopRaw<u8>(); | ||
| 638 | |||
| 639 | LOG_DEBUG(Service_FS, "called, program_index={}", program_index); | 397 | LOG_DEBUG(Service_FS, "called, program_index={}", program_index); |
| 640 | 398 | ||
| 641 | auto patched_romfs = romfs_controller->OpenPatchedRomFSWithProgramIndex( | 399 | auto patched_romfs = romfs_controller->OpenPatchedRomFSWithProgramIndex( |
| @@ -643,123 +401,80 @@ void FSP_SRV::OpenDataStorageWithProgramIndex(HLERequestContext& ctx) { | |||
| 643 | 401 | ||
| 644 | if (!patched_romfs) { | 402 | if (!patched_romfs) { |
| 645 | // TODO: Find the right error code to use here | 403 | // TODO: Find the right error code to use here |
| 646 | LOG_ERROR(Service_FS, "could not open storage with program_index={}", program_index); | 404 | LOG_ERROR(Service_FS, "Could not open storage with program_index={}", program_index); |
| 647 | 405 | R_RETURN(ResultUnknown); | |
| 648 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 649 | rb.Push(ResultUnknown); | ||
| 650 | return; | ||
| 651 | } | 406 | } |
| 652 | 407 | ||
| 653 | auto storage = std::make_shared<IStorage>(system, std::move(patched_romfs)); | 408 | *out_interface = std::make_shared<IStorage>(system, std::move(patched_romfs)); |
| 654 | 409 | ||
| 655 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 410 | R_SUCCEED(); |
| 656 | rb.Push(ResultSuccess); | ||
| 657 | rb.PushIpcInterface<IStorage>(std::move(storage)); | ||
| 658 | } | 411 | } |
| 659 | 412 | ||
| 660 | void FSP_SRV::DisableAutoSaveDataCreation(HLERequestContext& ctx) { | 413 | Result FSP_SRV::DisableAutoSaveDataCreation() { |
| 661 | LOG_DEBUG(Service_FS, "called"); | 414 | LOG_DEBUG(Service_FS, "called"); |
| 662 | 415 | ||
| 663 | save_data_controller->SetAutoCreate(false); | 416 | save_data_controller->SetAutoCreate(false); |
| 664 | 417 | ||
| 665 | IPC::ResponseBuilder rb{ctx, 2}; | 418 | R_SUCCEED(); |
| 666 | rb.Push(ResultSuccess); | ||
| 667 | } | 419 | } |
| 668 | 420 | ||
| 669 | void FSP_SRV::SetGlobalAccessLogMode(HLERequestContext& ctx) { | 421 | Result FSP_SRV::SetGlobalAccessLogMode(AccessLogMode access_log_mode_) { |
| 670 | IPC::RequestParser rp{ctx}; | 422 | LOG_DEBUG(Service_FS, "called, access_log_mode={}", access_log_mode_); |
| 671 | access_log_mode = rp.PopEnum<AccessLogMode>(); | ||
| 672 | 423 | ||
| 673 | LOG_DEBUG(Service_FS, "called, access_log_mode={}", access_log_mode); | 424 | access_log_mode = access_log_mode_; |
| 674 | 425 | ||
| 675 | IPC::ResponseBuilder rb{ctx, 2}; | 426 | R_SUCCEED(); |
| 676 | rb.Push(ResultSuccess); | ||
| 677 | } | 427 | } |
| 678 | 428 | ||
| 679 | void FSP_SRV::GetGlobalAccessLogMode(HLERequestContext& ctx) { | 429 | Result FSP_SRV::GetGlobalAccessLogMode(Out<AccessLogMode> out_access_log_mode) { |
| 680 | LOG_DEBUG(Service_FS, "called"); | 430 | LOG_DEBUG(Service_FS, "called"); |
| 681 | 431 | ||
| 682 | IPC::ResponseBuilder rb{ctx, 3}; | 432 | *out_access_log_mode = access_log_mode; |
| 683 | rb.Push(ResultSuccess); | ||
| 684 | rb.PushEnum(access_log_mode); | ||
| 685 | } | ||
| 686 | 433 | ||
| 687 | void FSP_SRV::OutputAccessLogToSdCard(HLERequestContext& ctx) { | 434 | R_SUCCEED(); |
| 688 | const auto raw = ctx.ReadBufferCopy(); | 435 | } |
| 689 | auto log = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 690 | reinterpret_cast<const char*>(raw.data()), raw.size()); | ||
| 691 | 436 | ||
| 437 | Result FSP_SRV::OutputAccessLogToSdCard(InBuffer<BufferAttr_HipcMapAlias> log_message_buffer) { | ||
| 692 | LOG_DEBUG(Service_FS, "called"); | 438 | LOG_DEBUG(Service_FS, "called"); |
| 693 | 439 | ||
| 440 | auto log = Common::StringFromFixedZeroTerminatedBuffer( | ||
| 441 | reinterpret_cast<const char*>(log_message_buffer.data()), log_message_buffer.size()); | ||
| 694 | reporter.SaveFSAccessLog(log); | 442 | reporter.SaveFSAccessLog(log); |
| 695 | 443 | ||
| 696 | IPC::ResponseBuilder rb{ctx, 2}; | 444 | R_SUCCEED(); |
| 697 | rb.Push(ResultSuccess); | ||
| 698 | } | 445 | } |
| 699 | 446 | ||
| 700 | void FSP_SRV::GetProgramIndexForAccessLog(HLERequestContext& ctx) { | 447 | Result FSP_SRV::GetProgramIndexForAccessLog(Out<AccessLogVersion> out_access_log_version, |
| 701 | LOG_DEBUG(Service_FS, "called"); | 448 | Out<u32> out_access_log_program_index) { |
| 449 | LOG_DEBUG(Service_FS, "(STUBBED) called"); | ||
| 450 | |||
| 451 | *out_access_log_version = AccessLogVersion::Latest; | ||
| 452 | *out_access_log_program_index = access_log_program_index; | ||
| 702 | 453 | ||
| 703 | IPC::ResponseBuilder rb{ctx, 4}; | 454 | R_SUCCEED(); |
| 704 | rb.Push(ResultSuccess); | ||
| 705 | rb.PushEnum(AccessLogVersion::Latest); | ||
| 706 | rb.Push(access_log_program_index); | ||
| 707 | } | 455 | } |
| 708 | 456 | ||
| 709 | void FSP_SRV::FlushAccessLogOnSdCard(HLERequestContext& ctx) { | 457 | Result FSP_SRV::FlushAccessLogOnSdCard() { |
| 710 | LOG_DEBUG(Service_FS, "(STUBBED) called"); | 458 | LOG_DEBUG(Service_FS, "(STUBBED) called"); |
| 711 | 459 | ||
| 712 | IPC::ResponseBuilder rb{ctx, 2}; | 460 | R_SUCCEED(); |
| 713 | rb.Push(ResultSuccess); | ||
| 714 | } | 461 | } |
| 715 | 462 | ||
| 716 | void FSP_SRV::GetCacheStorageSize(HLERequestContext& ctx) { | 463 | Result FSP_SRV::GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size) { |
| 717 | IPC::RequestParser rp{ctx}; | ||
| 718 | const auto index{rp.Pop<s32>()}; | ||
| 719 | |||
| 720 | LOG_WARNING(Service_FS, "(STUBBED) called with index={}", index); | 464 | LOG_WARNING(Service_FS, "(STUBBED) called with index={}", index); |
| 721 | 465 | ||
| 722 | IPC::ResponseBuilder rb{ctx, 6}; | 466 | *out_data_size = 0; |
| 723 | rb.Push(ResultSuccess); | 467 | *out_journal_size = 0; |
| 724 | rb.Push(s64{0}); | ||
| 725 | rb.Push(s64{0}); | ||
| 726 | } | ||
| 727 | |||
| 728 | class IMultiCommitManager final : public ServiceFramework<IMultiCommitManager> { | ||
| 729 | public: | ||
| 730 | explicit IMultiCommitManager(Core::System& system_) | ||
| 731 | : ServiceFramework{system_, "IMultiCommitManager"} { | ||
| 732 | static const FunctionInfo functions[] = { | ||
| 733 | {1, &IMultiCommitManager::Add, "Add"}, | ||
| 734 | {2, &IMultiCommitManager::Commit, "Commit"}, | ||
| 735 | }; | ||
| 736 | RegisterHandlers(functions); | ||
| 737 | } | ||
| 738 | 468 | ||
| 739 | private: | 469 | R_SUCCEED(); |
| 740 | FileSys::VirtualFile backend; | 470 | } |
| 741 | |||
| 742 | void Add(HLERequestContext& ctx) { | ||
| 743 | LOG_WARNING(Service_FS, "(STUBBED) called"); | ||
| 744 | |||
| 745 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 746 | rb.Push(ResultSuccess); | ||
| 747 | } | ||
| 748 | |||
| 749 | void Commit(HLERequestContext& ctx) { | ||
| 750 | LOG_WARNING(Service_FS, "(STUBBED) called"); | ||
| 751 | |||
| 752 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 753 | rb.Push(ResultSuccess); | ||
| 754 | } | ||
| 755 | }; | ||
| 756 | 471 | ||
| 757 | void FSP_SRV::OpenMultiCommitManager(HLERequestContext& ctx) { | 472 | Result FSP_SRV::OpenMultiCommitManager(OutInterface<IMultiCommitManager> out_interface) { |
| 758 | LOG_DEBUG(Service_FS, "called"); | 473 | LOG_DEBUG(Service_FS, "called"); |
| 759 | 474 | ||
| 760 | IPC::ResponseBuilder rb{ctx, 2, 0, 1}; | 475 | *out_interface = std::make_shared<IMultiCommitManager>(system); |
| 761 | rb.Push(ResultSuccess); | 476 | |
| 762 | rb.PushIpcInterface<IMultiCommitManager>(std::make_shared<IMultiCommitManager>(system)); | 477 | R_SUCCEED(); |
| 763 | } | 478 | } |
| 764 | 479 | ||
| 765 | } // namespace Service::FileSystem | 480 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/fsp/fsp_srv.h b/src/core/hle/service/filesystem/fsp/fsp_srv.h index 59406e6f9..ee67f6bc1 100644 --- a/src/core/hle/service/filesystem/fsp/fsp_srv.h +++ b/src/core/hle/service/filesystem/fsp/fsp_srv.h | |||
| @@ -4,6 +4,9 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include "core/file_sys/fs_save_data_types.h" | ||
| 8 | #include "core/hle/service/cmif_types.h" | ||
| 9 | #include "core/hle/service/filesystem/fsp/fsp_types.h" | ||
| 7 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 8 | 11 | ||
| 9 | namespace Core { | 12 | namespace Core { |
| @@ -20,6 +23,11 @@ namespace Service::FileSystem { | |||
| 20 | class RomFsController; | 23 | class RomFsController; |
| 21 | class SaveDataController; | 24 | class SaveDataController; |
| 22 | 25 | ||
| 26 | class IFileSystem; | ||
| 27 | class ISaveDataInfoReader; | ||
| 28 | class IStorage; | ||
| 29 | class IMultiCommitManager; | ||
| 30 | |||
| 23 | enum class AccessLogVersion : u32 { | 31 | enum class AccessLogVersion : u32 { |
| 24 | V7_0_0 = 2, | 32 | V7_0_0 = 2, |
| 25 | 33 | ||
| @@ -38,30 +46,46 @@ public: | |||
| 38 | ~FSP_SRV() override; | 46 | ~FSP_SRV() override; |
| 39 | 47 | ||
| 40 | private: | 48 | private: |
| 41 | void SetCurrentProcess(HLERequestContext& ctx); | 49 | Result SetCurrentProcess(ClientProcessId pid); |
| 42 | void OpenFileSystemWithPatch(HLERequestContext& ctx); | 50 | Result OpenFileSystemWithPatch(OutInterface<IFileSystem> out_interface, |
| 43 | void OpenSdCardFileSystem(HLERequestContext& ctx); | 51 | FileSystemProxyType type, u64 open_program_id); |
| 44 | void CreateSaveDataFileSystem(HLERequestContext& ctx); | 52 | Result OpenSdCardFileSystem(OutInterface<IFileSystem> out_interface); |
| 45 | void CreateSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx); | 53 | Result CreateSaveDataFileSystem(FileSys::SaveDataCreationInfo save_create_struct, |
| 46 | void OpenSaveDataFileSystem(HLERequestContext& ctx); | 54 | FileSys::SaveDataAttribute save_struct, u128 uid); |
| 47 | void OpenSaveDataFileSystemBySystemSaveDataId(HLERequestContext& ctx); | 55 | Result CreateSaveDataFileSystemBySystemSaveDataId( |
| 48 | void OpenReadOnlySaveDataFileSystem(HLERequestContext& ctx); | 56 | FileSys::SaveDataCreationInfo save_create_struct, FileSys::SaveDataAttribute save_struct); |
| 49 | void OpenSaveDataInfoReaderBySaveDataSpaceId(HLERequestContext& ctx); | 57 | Result OpenSaveDataFileSystem(OutInterface<IFileSystem> out_interface, |
| 50 | void OpenSaveDataInfoReaderOnlyCacheStorage(HLERequestContext& ctx); | 58 | FileSys::SaveDataSpaceId space_id, |
| 51 | void WriteSaveDataFileSystemExtraDataBySaveDataAttribute(HLERequestContext& ctx); | 59 | FileSys::SaveDataAttribute attribute); |
| 52 | void ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute(HLERequestContext& ctx); | 60 | Result OpenSaveDataFileSystemBySystemSaveDataId(OutInterface<IFileSystem> out_interface, |
| 53 | void OpenDataStorageByCurrentProcess(HLERequestContext& ctx); | 61 | FileSys::SaveDataSpaceId space_id, |
| 54 | void OpenDataStorageByDataId(HLERequestContext& ctx); | 62 | FileSys::SaveDataAttribute attribute); |
| 55 | void OpenPatchDataStorageByCurrentProcess(HLERequestContext& ctx); | 63 | Result OpenReadOnlySaveDataFileSystem(OutInterface<IFileSystem> out_interface, |
| 56 | void OpenDataStorageWithProgramIndex(HLERequestContext& ctx); | 64 | FileSys::SaveDataSpaceId space_id, |
| 57 | void DisableAutoSaveDataCreation(HLERequestContext& ctx); | 65 | FileSys::SaveDataAttribute attribute); |
| 58 | void SetGlobalAccessLogMode(HLERequestContext& ctx); | 66 | Result OpenSaveDataInfoReaderBySaveDataSpaceId(OutInterface<ISaveDataInfoReader> out_interface, |
| 59 | void GetGlobalAccessLogMode(HLERequestContext& ctx); | 67 | FileSys::SaveDataSpaceId space); |
| 60 | void OutputAccessLogToSdCard(HLERequestContext& ctx); | 68 | Result OpenSaveDataInfoReaderOnlyCacheStorage(OutInterface<ISaveDataInfoReader> out_interface); |
| 61 | void FlushAccessLogOnSdCard(HLERequestContext& ctx); | 69 | Result WriteSaveDataFileSystemExtraDataBySaveDataAttribute(); |
| 62 | void GetProgramIndexForAccessLog(HLERequestContext& ctx); | 70 | Result ReadSaveDataFileSystemExtraDataWithMaskBySaveDataAttribute( |
| 63 | void OpenMultiCommitManager(HLERequestContext& ctx); | 71 | FileSys::SaveDataSpaceId space_id, FileSys::SaveDataAttribute attribute, |
| 64 | void GetCacheStorageSize(HLERequestContext& ctx); | 72 | InBuffer<BufferAttr_HipcMapAlias> mask_buffer, |
| 73 | OutBuffer<BufferAttr_HipcMapAlias> out_buffer); | ||
| 74 | Result OpenDataStorageByCurrentProcess(OutInterface<IStorage> out_interface); | ||
| 75 | Result OpenDataStorageByDataId(OutInterface<IStorage> out_interface, | ||
| 76 | FileSys::StorageId storage_id, u32 unknown, u64 title_id); | ||
| 77 | Result OpenPatchDataStorageByCurrentProcess(OutInterface<IStorage> out_interface, | ||
| 78 | FileSys::StorageId storage_id, u64 title_id); | ||
| 79 | Result OpenDataStorageWithProgramIndex(OutInterface<IStorage> out_interface, u8 program_index); | ||
| 80 | Result DisableAutoSaveDataCreation(); | ||
| 81 | Result SetGlobalAccessLogMode(AccessLogMode access_log_mode_); | ||
| 82 | Result GetGlobalAccessLogMode(Out<AccessLogMode> out_access_log_mode); | ||
| 83 | Result OutputAccessLogToSdCard(InBuffer<BufferAttr_HipcMapAlias> log_message_buffer); | ||
| 84 | Result FlushAccessLogOnSdCard(); | ||
| 85 | Result GetProgramIndexForAccessLog(Out<AccessLogVersion> out_access_log_version, | ||
| 86 | Out<u32> out_access_log_program_index); | ||
| 87 | Result OpenMultiCommitManager(OutInterface<IMultiCommitManager> out_interface); | ||
| 88 | Result GetCacheStorageSize(s32 index, Out<s64> out_data_size, Out<s64> out_journal_size); | ||
| 65 | 89 | ||
| 66 | FileSystemController& fsc; | 90 | FileSystemController& fsc; |
| 67 | const FileSys::ContentProvider& content_provider; | 91 | const FileSys::ContentProvider& content_provider; |
diff --git a/src/core/hle/service/filesystem/fsp/fsp_util.h b/src/core/hle/service/filesystem/fsp/fsp_types.h index 253f866db..294da6a2d 100644 --- a/src/core/hle/service/filesystem/fsp/fsp_util.h +++ b/src/core/hle/service/filesystem/fsp/fsp_types.h | |||
| @@ -7,6 +7,18 @@ | |||
| 7 | 7 | ||
| 8 | namespace Service::FileSystem { | 8 | namespace Service::FileSystem { |
| 9 | 9 | ||
| 10 | enum class FileSystemProxyType : u8 { | ||
| 11 | Code = 0, | ||
| 12 | Rom = 1, | ||
| 13 | Logo = 2, | ||
| 14 | Control = 3, | ||
| 15 | Manual = 4, | ||
| 16 | Meta = 5, | ||
| 17 | Data = 6, | ||
| 18 | Package = 7, | ||
| 19 | RegisteredUpdate = 8, | ||
| 20 | }; | ||
| 21 | |||
| 10 | struct SizeGetter { | 22 | struct SizeGetter { |
| 11 | std::function<u64()> get_free_size; | 23 | std::function<u64()> get_free_size; |
| 12 | std::function<u64()> get_total_size; | 24 | std::function<u64()> get_total_size; |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 5c2a5bfe6..c0c0a19b8 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -2325,15 +2325,15 @@ void GMainWindow::OnGameListOpenFolder(u64 program_id, GameListOpenTarget target | |||
| 2325 | ASSERT(user_id); | 2325 | ASSERT(user_id); |
| 2326 | 2326 | ||
| 2327 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 2327 | const auto user_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 2328 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, | 2328 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, |
| 2329 | FileSys::SaveDataType::SaveData, program_id, user_id->AsU128(), 0); | 2329 | program_id, user_id->AsU128(), 0); |
| 2330 | 2330 | ||
| 2331 | path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); | 2331 | path = Common::FS::ConcatPathSafe(nand_dir, user_save_data_path); |
| 2332 | } else { | 2332 | } else { |
| 2333 | // Device save data | 2333 | // Device save data |
| 2334 | const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( | 2334 | const auto device_save_data_path = FileSys::SaveDataFactory::GetFullPath( |
| 2335 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, | 2335 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Account, |
| 2336 | FileSys::SaveDataType::SaveData, program_id, {}, 0); | 2336 | program_id, {}, 0); |
| 2337 | 2337 | ||
| 2338 | path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); | 2338 | path = Common::FS::ConcatPathSafe(nand_dir, device_save_data_path); |
| 2339 | } | 2339 | } |
| @@ -2674,7 +2674,7 @@ void GMainWindow::RemoveCacheStorage(u64 program_id) { | |||
| 2674 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); | 2674 | vfs->OpenDirectory(Common::FS::PathToUTF8String(nand_dir), FileSys::OpenMode::Read); |
| 2675 | 2675 | ||
| 2676 | const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( | 2676 | const auto cache_storage_path = FileSys::SaveDataFactory::GetFullPath( |
| 2677 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::NandUser, FileSys::SaveDataType::CacheStorage, | 2677 | {}, vfs_nand_dir, FileSys::SaveDataSpaceId::User, FileSys::SaveDataType::Cache, |
| 2678 | 0 /* program_id */, {}, 0); | 2678 | 0 /* program_id */, {}, 0); |
| 2679 | 2679 | ||
| 2680 | const auto path = Common::FS::ConcatPathSafe(nand_dir, cache_storage_path); | 2680 | const auto path = Common::FS::ConcatPathSafe(nand_dir, cache_storage_path); |