diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp index 42e6fc466..4a1a91339 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_save_data_types.hpp @@ -74,6 +74,14 @@ namespace ams::fs { constexpr inline SystemSaveDataId InvalidSystemSaveDataId = 0; constexpr inline UserId InvalidUserId = {}; + enum SaveDataFlags : u32 { + SaveDataFlags_None = (0 << 0), + SaveDataFlags_KeepAfterResettingSystemSaveData = (1 << 0), + SaveDataFlags_KeepAfterRefurbishment = (1 << 1), + SaveDataFlags_KeepAfterResettingSystemSaveDataWithoutUserSaveData = (1 << 2), + SaveDataFlags_NeedsSecureDelete = (1 << 3), + }; + struct SaveDataCreationInfo { s64 size; s64 journal_size; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp index e9ee108c9..d9d35d7a7 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_manager_impl.cpp @@ -27,7 +27,7 @@ namespace ams::ncm { constexpr fs::SystemSaveDataId BuiltInSystemSaveDataId = 0x8000000000000120; constexpr u64 BuiltInSystemSaveDataSize = 0x6c000; constexpr u64 BuiltInSystemSaveDataJournalSize = 0x6c000; - constexpr u32 BuiltInSystemSaveDataFlags = FsSaveDataFlags_KeepAfterResettingSystemSaveData | FsSaveDataFlags_KeepAfterRefurbishment; + constexpr u32 BuiltInSystemSaveDataFlags = fs::SaveDataFlags_KeepAfterResettingSystemSaveData | fs::SaveDataFlags_KeepAfterRefurbishment; constexpr SystemSaveDataInfo BuiltInSystemSystemSaveDataInfo = { .id = BuiltInSystemSaveDataId, @@ -151,7 +151,10 @@ namespace ams::ncm { /* Mount existing system save data if present, otherwise create it then mount. */ R_TRY_CATCH(fs::MountSystemSaveData(mount_name, info.space_id, info.id)) { R_CATCH(fs::ResultTargetNotFound) { - R_TRY(fs::CreateSystemSaveData(info.space_id, info.id, OwnerId, info.size, info.journal_size, info.flags)); + /* On 1.0.0, not all flags existed. Mask when appropriate. */ + constexpr u32 SaveDataFlags100Mask = fs::SaveDataFlags_KeepAfterResettingSystemSaveData; + const u32 flags = (hos::GetVersion() >= hos::Version_200) ? (info.flags) : (info.flags & SaveDataFlags100Mask); + R_TRY(fs::CreateSystemSaveData(info.space_id, info.id, OwnerId, info.size, info.journal_size, flags)); R_TRY(fs::MountSystemSaveData(mount_name, info.space_id, info.id)); } } R_END_TRY_CATCH; @@ -347,8 +350,10 @@ namespace ams::ncm { } /* Ensure correct flags on the BuiltInSystem save data. */ + /* NOTE: Nintendo does not check this succeeds, and it does on older system versions. */ + /* We will not check the error, either, even though this kind of defeats the call's purpose. */ if (hos::GetVersion() >= hos::Version_200) { - R_TRY(EnsureBuiltInSystemSaveDataFlags()); + EnsureBuiltInSystemSaveDataFlags(); } R_TRY(this->ActivateContentMetaDatabase(StorageId::BuiltInSystem));