diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_code.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_code.hpp index 514c1b391..dd5e5b33d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_code.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_code.hpp @@ -20,10 +20,10 @@ namespace ams::fs { - /* ACCURATE_TO_VERSION: 13.4.0.0 */ - Result MountCode(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id); + /* ACCURATE_TO_VERSION: 16.2.0.0 */ + Result MountCode(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id); - Result MountCodeForAtmosphereWithRedirection(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id, bool is_hbl, bool is_specific); - Result MountCodeForAtmosphere(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id); + Result MountCodeForAtmosphereWithRedirection(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id, bool is_hbl, bool is_specific); + Result MountCodeForAtmosphere(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id); } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_content.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_content.hpp index 5a709e7e8..b379c1394 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_content.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_content.hpp @@ -28,8 +28,8 @@ namespace ams::fs { ContentType_Data = 4, }; - Result MountContent(const char *name, const char *path, ContentType content_type); - Result MountContent(const char *name, const char *path, ncm::ProgramId id, ContentType content_type); - Result MountContent(const char *name, const char *path, ncm::DataId id, ContentType content_type); + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ContentType content_type); + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId id, ContentType content_type); + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ncm::DataId id, ContentType content_type); } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_content_attributes.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_content_attributes.hpp index 863ccce05..a8025d180 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_content_attributes.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_content_attributes.hpp @@ -21,7 +21,8 @@ namespace ams::fs { /* ACCURATE_TO_VERSION: Unknown */ enum ContentAttributes : u8 { - ContentAttributes_None = 0, + ContentAttributes_None = 0x0, + ContentAttributes_All = 0xF, }; } diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_rights_id.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_rights_id.hpp index b2567281b..43fc53cea 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_rights_id.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_rights_id.hpp @@ -15,6 +15,7 @@ */ #pragma once #include +#include namespace ams::fs { @@ -41,7 +42,7 @@ namespace ams::fs { constexpr inline RightsId InvalidRightsId = {}; /* Rights ID API */ - Result GetRightsId(RightsId *out, const char *path); - Result GetRightsId(RightsId *out, u8 *out_key_generation, const char *path); + Result GetRightsId(RightsId *out, const char *path, fs::ContentAttributes attr); + Result GetRightsId(RightsId *out, u8 *out_key_generation, const char *path, fs::ContentAttributes attr); } \ No newline at end of file diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp index 4d6f6c19c..c05920cc8 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/fssrv_file_system_proxy_impl.hpp @@ -50,8 +50,9 @@ namespace ams::fssrv { Result SetCurrentProcess(const ams::sf::ClientProcessId &client_pid); Result OpenDataFileSystemByCurrentProcess(ams::sf::Out> out); Result OpenFileSystemWithPatch(ams::sf::Out> out, ncm::ProgramId program_id, u32 type); - Result OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type); + Result OpenFileSystemWithIdObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type); Result OpenDataFileSystemByProgramId(ams::sf::Out> out, ncm::ProgramId program_id); + Result OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u64 program_id, u32 type); Result OpenBisFileSystem(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 id); Result OpenBisStorage(ams::sf::Out> out, u32 id); Result InvalidateBisCache(); @@ -90,7 +91,8 @@ namespace ams::fssrv { Result OpenPatchDataStorageByCurrentProcess(ams::sf::Out> out); Result OpenDataFileSystemWithProgramIndex(ams::sf::Out> out, u8 index); Result OpenDataStorageWithProgramIndex(ams::sf::Out> out, u8 index); - Result OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type); + Result OpenDataStorageByPathObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type); + Result OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u32 type); Result OpenDeviceOperator(ams::sf::Out> out); Result OpenSdCardDetectionEventNotifier(ams::sf::Out> out); Result OpenGameCardDetectionEventNotifier(ams::sf::Out> out); @@ -103,7 +105,8 @@ namespace ams::fssrv { Result RegisterExternalKey(const fs::RightsId &rights_id, const spl::AccessKey &access_key); Result UnregisterAllExternalKey(); Result GetRightsIdByPath(ams::sf::Out out, const fssrv::sf::FspPath &path); - Result GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path); + Result GetRightsIdAndKeyGenerationByPathObsolete(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path); + Result GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path, fs::ContentAttributes attr); Result SetCurrentPosixTimeWithTimeDifference(s64 posix_time, s32 time_difference); Result GetFreeSpaceSizeForSaveData(ams::sf::Out out, u8 space_id); Result VerifySaveDataFileSystemBySaveDataSpaceId(); @@ -142,7 +145,8 @@ namespace ams::fssrv { public: /* fsp-ldr */ Result OpenCodeFileSystemDeprecated(ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id); - Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id); + Result OpenCodeFileSystemDeprecated2(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id); + Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id); Result IsArchivedProgram(ams::sf::Out out, u64 process_id); }; static_assert(sf::IsIFileSystemProxy); @@ -156,11 +160,16 @@ namespace ams::fssrv { R_THROW(fs::ResultPortAcceptableCountLimited()); } - Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { + Result OpenCodeFileSystemDeprecated2(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { AMS_UNUSED(out_fs, out_verif, path, program_id); R_THROW(fs::ResultPortAcceptableCountLimited()); } + Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id) { + AMS_UNUSED(out_fs, out_verif, path, attr, program_id); + R_THROW(fs::ResultPortAcceptableCountLimited()); + } + Result IsArchivedProgram(ams::sf::Out out, u64 process_id) { AMS_UNUSED(out, process_id); R_THROW(fs::ResultPortAcceptableCountLimited()); diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy.hpp index 043044885..5e8fade2f 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy.hpp @@ -27,8 +27,9 @@ AMS_SF_METHOD_INFO(C, H, 1, Result, SetCurrentProcess, (const ams::sf::ClientProcessId &client_pid), (client_pid)) \ AMS_SF_METHOD_INFO(C, H, 2, Result, OpenDataFileSystemByCurrentProcess, (ams::sf::Out> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 7, Result, OpenFileSystemWithPatch, (ams::sf::Out> out, ncm::ProgramId program_id, u32 type), (out, program_id, type), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 8, Result, OpenFileSystemWithId, (ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type), (out, path, program_id, type), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, OpenFileSystemWithIdObsolete, (ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type), (out, path, program_id, type), hos::Version_2_0_0) \ AMS_SF_METHOD_INFO(C, H, 9, Result, OpenDataFileSystemByProgramId, (ams::sf::Out> out, ncm::ProgramId program_id), (out, program_id), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, OpenFileSystemWithId, (ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u64 program_id, u32 type), (out, path, attr, program_id, type), hos::Version_16_0_0) \ AMS_SF_METHOD_INFO(C, H, 11, Result, OpenBisFileSystem, (ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 id), (out, path, id)) \ AMS_SF_METHOD_INFO(C, H, 12, Result, OpenBisStorage, (ams::sf::Out> out, u32 id), (out, id)) \ AMS_SF_METHOD_INFO(C, H, 13, Result, InvalidateBisCache, (), ()) \ @@ -87,7 +88,8 @@ AMS_SF_METHOD_INFO(C, H, 203, Result, OpenPatchDataStorageByCurrentProcess, (ams::sf::Out> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 204, Result, OpenDataFileSystemWithProgramIndex, (ams::sf::Out> out, u8 index), (out, index), hos::Version_7_0_0) \ AMS_SF_METHOD_INFO(C, H, 205, Result, OpenDataStorageWithProgramIndex, (ams::sf::Out> out, u8 index), (out, index), hos::Version_7_0_0) \ - AMS_SF_METHOD_INFO(C, H, 206, Result, OpenDataStorageByPath, (ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type), (out, path, type), hos::Version_13_0_0) \ + AMS_SF_METHOD_INFO(C, H, 206, Result, OpenDataStorageByPathObsolete, (ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type), (out, path, type), hos::Version_13_0_0, hos::Version_15_0_1) \ + AMS_SF_METHOD_INFO(C, H, 206, Result, OpenDataStorageByPath, (ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u32 type), (out, path, attr, type), hos::Version_16_0_0) \ AMS_SF_METHOD_INFO(C, H, 400, Result, OpenDeviceOperator, (ams::sf::Out> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 500, Result, OpenSdCardDetectionEventNotifier, (ams::sf::Out> out), (out)) \ AMS_SF_METHOD_INFO(C, H, 501, Result, OpenGameCardDetectionEventNotifier, (ams::sf::Out> out), (out)) \ @@ -103,8 +105,9 @@ AMS_SF_METHOD_INFO(C, H, 606, Result, GetRightsId, (ams::sf::Out out, ncm::ProgramId program_id, ncm::StorageId storage_id), (out, program_id, storage_id), hos::Version_2_0_0) \ AMS_SF_METHOD_INFO(C, H, 607, Result, RegisterExternalKey, (const fs::RightsId &rights_id, const spl::AccessKey &access_key), (rights_id, access_key), hos::Version_2_0_0) \ AMS_SF_METHOD_INFO(C, H, 608, Result, UnregisterAllExternalKey, (), (), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 609, Result, GetRightsIdByPath, (ams::sf::Out out, const fssrv::sf::FspPath &path), (out, path), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 610, Result, GetRightsIdAndKeyGenerationByPath, (ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path), (out, out_key_generation, path), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 609, Result, GetRightsIdByPath, (ams::sf::Out out, const fssrv::sf::FspPath &path), (out, path), hos::Version_2_0_0, hos::Version_15_0_1) \ + AMS_SF_METHOD_INFO(C, H, 610, Result, GetRightsIdAndKeyGenerationByPathObsolete, (ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path), (out, out_key_generation, path), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 610, Result, GetRightsIdAndKeyGenerationByPath, (ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path, fs::ContentAttributes attr), (out, out_key_generation, path, attr), hos::Version_16_0_0) \ AMS_SF_METHOD_INFO(C, H, 611, Result, SetCurrentPosixTimeWithTimeDifference, (s64 posix_time, s32 time_difference), (posix_time, time_difference), hos::Version_4_0_0) \ AMS_SF_METHOD_INFO(C, H, 612, Result, GetFreeSpaceSizeForSaveData, (ams::sf::Out out, u8 space_id), (out, space_id), hos::Version_4_0_0) \ AMS_SF_METHOD_INFO(C, H, 613, Result, VerifySaveDataFileSystemBySaveDataSpaceId, (), (), hos::Version_4_0_0) \ diff --git a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy_for_loader.hpp b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy_for_loader.hpp index e6693d1bf..4ba1f0a8f 100644 --- a/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy_for_loader.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssrv/sf/fssrv_sf_i_file_system_proxy_for_loader.hpp @@ -18,12 +18,14 @@ #include #include #include +#include /* ACCURATE_TO_VERSION: 13.4.0.0 */ -#define AMS_FSSRV_I_FILE_SYSTEM_PROXY_FOR_LOADER_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, OpenCodeFileSystemDeprecated, (ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id), (out_fs, path, program_id), hos::Version_Min, hos::Version_9_2_0) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, OpenCodeFileSystem, (ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id), (out_fs, out_verif, path, program_id), hos::Version_10_0_0) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, IsArchivedProgram, (ams::sf::Out out, u64 process_id), (out, process_id)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, SetCurrentProcess, (const ams::sf::ClientProcessId &client_pid), (client_pid), hos::Version_4_0_0) +#define AMS_FSSRV_I_FILE_SYSTEM_PROXY_FOR_LOADER_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenCodeFileSystemDeprecated, (ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id), (out_fs, path, program_id), hos::Version_Min, hos::Version_9_2_0) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenCodeFileSystemDeprecated2, (ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id), (out_fs, out_verif, path, program_id), hos::Version_10_0_0, hos::Version_15_0_1) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, OpenCodeFileSystem, (ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id), (out_fs, out_verif, path, attr, program_id), hos::Version_16_0_0) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, IsArchivedProgram, (ams::sf::Out out, u64 process_id), (out, process_id)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, SetCurrentProcess, (const ams::sf::ClientProcessId &client_pid), (client_pid), hos::Version_4_0_0) AMS_SF_DEFINE_INTERFACE(ams::fssrv::sf, IFileSystemProxyForLoader, AMS_FSSRV_I_FILE_SYSTEM_PROXY_FOR_LOADER_INTERFACE_INFO, 0xDC92EE15) diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp index 9ee093e9e..947fbfaad 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_database.hpp @@ -172,7 +172,14 @@ namespace ams::ncm { Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) { AMS_ASSERT(m_interface != nullptr); - R_RETURN(m_interface->GetPatchId(out_patch_id, key)); + static_assert(sizeof(*out_patch_id) == sizeof(u64)); + R_RETURN(m_interface->GetPatchContentMetaId(reinterpret_cast(out_patch_id), key)); + } + + Result GetDataPatchId(DataPatchId *out_patch_id, const ContentMetaKey &key) { + AMS_ASSERT(m_interface != nullptr); + static_assert(sizeof(*out_patch_id) == sizeof(u64)); + R_RETURN(m_interface->GetPatchContentMetaId(reinterpret_cast(out_patch_id), key)); } Result DisableForcibly() { diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp index 3fd41f1b8..16b15dd10 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_meta_utils.hpp @@ -23,17 +23,22 @@ namespace ams::ncm { - using MountContentMetaFunction = Result (*)(const char *mount_name, const char *path); + using MountContentMetaFunction = Result (*)(const char *mount_name, const char *path, fs::ContentAttributes attr); bool IsContentMetaFileName(const char *name); - Result ReadContentMetaPathAlongWithExtendedDataAndDigest(AutoBuffer *out, const char *path); - Result ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(AutoBuffer *out, const char *path); + Result ReadContentMetaPathAlongWithExtendedDataAndDigest(AutoBuffer *out, const char *path, fs::ContentAttributes attr); + Result ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(AutoBuffer *out, const char *path, fs::ContentAttributes attr); - Result ReadContentMetaPathWithoutExtendedDataOrDigest(AutoBuffer *out, const char *path); - Result ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort(AutoBuffer *out, const char *path); + Result ReadContentMetaPathWithoutExtendedDataOrDigest(AutoBuffer *out, const char *path, fs::ContentAttributes attr); + Result ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort(AutoBuffer *out, const char *path, fs::ContentAttributes attr); - Result ReadVariationContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const Path &path, FirmwareVariationId firmware_variation_id); + using ReadContentMetaPathFunction = Result (*)(AutoBuffer *out, const char *path, fs::ContentAttributes attr); + + Result TryReadContentMetaPath(fs::ContentAttributes *out_attr, AutoBuffer *out, const char *path, ReadContentMetaPathFunction func); + Result TryReadContentMetaPath(AutoBuffer *out, const char *path, ReadContentMetaPathFunction func); + + Result ReadVariationContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const Path &path, fs::ContentAttributes attr, FirmwareVariationId firmware_variation_id); void SetMountContentMetaFunction(MountContentMetaFunction func); diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp index e236560d3..27fd2d539 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_content_storage.hpp @@ -142,12 +142,14 @@ namespace ams::ncm { R_RETURN(m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset)); } - Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) { + Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) { AMS_ASSERT(m_interface != nullptr); const auto vers = hos::GetVersion(); - if (vers >= hos::Version_3_0_0) { - R_RETURN(m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id)); + if (vers >= hos::Version_16_0_0) { + R_RETURN(m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id, attr)); + } else if (vers >= hos::Version_3_0_0) { + R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdDeprecated2(out_rights_id, placeholder_id)); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; @@ -155,12 +157,14 @@ namespace ams::ncm { } } - Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id) { + Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id, fs::ContentAttributes attr) { AMS_ASSERT(m_interface != nullptr); const auto vers = hos::GetVersion(); - if (vers >= hos::Version_3_0_0) { - R_RETURN(m_interface->GetRightsIdFromContentId(out_rights_id, content_id)); + if (vers >= hos::Version_16_0_0) { + R_RETURN(m_interface->GetRightsIdFromContentId(out_rights_id, content_id, attr)); + } else if (vers >= hos::Version_3_0_0) { + R_RETURN(m_interface->GetRightsIdFromContentIdDeprecated2(out_rights_id, content_id)); } else { AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); *out_rights_id = {}; @@ -193,9 +197,15 @@ namespace ams::ncm { R_RETURN(m_interface->RepairInvalidFileAttribute()); } - Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) { AMS_ASSERT(m_interface != nullptr); - R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id)); + + const auto vers = hos::GetVersion(); + if (vers >= hos::Version_16_0_0) { + R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id, attr)); + } else { + R_RETURN(m_interface->GetRightsIdFromPlaceHolderIdWithCacheDeprecated(out_rights_id, placeholder_id, cache_content_id)); + } } }; diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp index 787b797df..411701b79 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_meta_database.hpp @@ -30,7 +30,7 @@ AMS_SF_METHOD_INFO(C, H, 9, Result, HasAll, (sf::Out out, const sf::InArray &keys), (out, keys)) \ AMS_SF_METHOD_INFO(C, H, 10, Result, GetSize, (sf::Out out_size, const ncm::ContentMetaKey &key), (out_size, key)) \ AMS_SF_METHOD_INFO(C, H, 11, Result, GetRequiredSystemVersion, (sf::Out out_version, const ncm::ContentMetaKey &key), (out_version, key)) \ - AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchId, (sf::Out out_patch_id, const ncm::ContentMetaKey &key), (out_patch_id, key)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, GetPatchContentMetaId, (sf::Out out_patch_id, const ncm::ContentMetaKey &key), (out_patch_id, key)) \ AMS_SF_METHOD_INFO(C, H, 13, Result, DisableForcibly, (), ()) \ AMS_SF_METHOD_INFO(C, H, 14, Result, LookupOrphanContent, (const sf::OutArray &out_orphaned, const sf::InArray &content_ids), (out_orphaned, content_ids)) \ AMS_SF_METHOD_INFO(C, H, 15, Result, Commit, (), ()) \ diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp index 753e10bab..743459bf8 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_i_content_storage.hpp @@ -20,38 +20,41 @@ #include #include -#define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \ - AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out out), (out)) \ - AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id, s64 size), (placeholder_id, content_id, size)) \ - AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (ncm::PlaceHolderId placeholder_id), (placeholder_id)) \ - AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \ - AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (ncm::PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data), (placeholder_id, offset, data)) \ - AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id), (placeholder_id, content_id)) \ - AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ncm::ContentId content_id), (content_id)) \ - AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out out, ncm::ContentId content_id), (out, content_id)) \ - AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out out, ncm::ContentId content_id), (out, content_id)) \ - AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \ - AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, (), ()) \ - AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out out_count, const sf::OutArray &out_buf), (out_count, out_buf)) \ - AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out out_count), (out_count)) \ - AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out out_count, const sf::OutArray &out_buf, s32 start_offset), (out_count, out_buf, start_offset)) \ - AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out out_size, ncm::ContentId content_id), (out_size, content_id)) \ - AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, (), ()) \ - AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId old_content_id, ncm::ContentId new_content_id), (placeholder_id, old_content_id, new_content_id), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (ncm::PlaceHolderId placeholder_id, s64 size), (placeholder_id, size), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (const sf::OutBuffer &buf, ncm::ContentId content_id, s64 offset), (buf, content_id, offset), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \ - AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_3_0_0) \ - AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_2_0_0, hos::Version_2_3_0) \ - AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_3_0_0) \ - AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ncm::ContentId content_id, s64 offset, const sf::InBuffer &data), (content_id, offset, data), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out out_size), (out_size), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out out_size), (out_size), hos::Version_2_0_0) \ - AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), (), hos::Version_3_0_0) \ - AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id), hos::Version_4_0_0) \ - AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), (), hos::Version_4_0_0) \ - AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id, ncm::ContentId cache_content_id), (out_rights_id, placeholder_id, cache_content_id), hos::Version_8_0_0) \ - AMS_SF_METHOD_INFO(C, H, 28, Result, RegisterPath, (const ncm::ContentId &content_id, const ncm::Path &path), (content_id, path), hos::Version_13_0_0) \ - AMS_SF_METHOD_INFO(C, H, 29, Result, ClearRegisteredPath, (), (), hos::Version_13_0_0) +#define AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO(C, H) \ + AMS_SF_METHOD_INFO(C, H, 0, Result, GeneratePlaceHolderId, (sf::Out out), (out)) \ + AMS_SF_METHOD_INFO(C, H, 1, Result, CreatePlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id, s64 size), (placeholder_id, content_id, size)) \ + AMS_SF_METHOD_INFO(C, H, 2, Result, DeletePlaceHolder, (ncm::PlaceHolderId placeholder_id), (placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 3, Result, HasPlaceHolder, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 4, Result, WritePlaceHolder, (ncm::PlaceHolderId placeholder_id, s64 offset, const sf::InBuffer &data), (placeholder_id, offset, data)) \ + AMS_SF_METHOD_INFO(C, H, 5, Result, Register, (ncm::PlaceHolderId placeholder_id, ncm::ContentId content_id), (placeholder_id, content_id)) \ + AMS_SF_METHOD_INFO(C, H, 6, Result, Delete, (ncm::ContentId content_id), (content_id)) \ + AMS_SF_METHOD_INFO(C, H, 7, Result, Has, (sf::Out out, ncm::ContentId content_id), (out, content_id)) \ + AMS_SF_METHOD_INFO(C, H, 8, Result, GetPath, (sf::Out out, ncm::ContentId content_id), (out, content_id)) \ + AMS_SF_METHOD_INFO(C, H, 9, Result, GetPlaceHolderPath, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id)) \ + AMS_SF_METHOD_INFO(C, H, 10, Result, CleanupAllPlaceHolder, (), ()) \ + AMS_SF_METHOD_INFO(C, H, 11, Result, ListPlaceHolder, (sf::Out out_count, const sf::OutArray &out_buf), (out_count, out_buf)) \ + AMS_SF_METHOD_INFO(C, H, 12, Result, GetContentCount, (sf::Out out_count), (out_count)) \ + AMS_SF_METHOD_INFO(C, H, 13, Result, ListContentId, (sf::Out out_count, const sf::OutArray &out_buf, s32 start_offset), (out_count, out_buf, start_offset)) \ + AMS_SF_METHOD_INFO(C, H, 14, Result, GetSizeFromContentId, (sf::Out out_size, ncm::ContentId content_id), (out_size, content_id)) \ + AMS_SF_METHOD_INFO(C, H, 15, Result, DisableForcibly, (), ()) \ + AMS_SF_METHOD_INFO(C, H, 16, Result, RevertToPlaceHolder, (ncm::PlaceHolderId placeholder_id, ncm::ContentId old_content_id, ncm::ContentId new_content_id), (placeholder_id, old_content_id, new_content_id), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 17, Result, SetPlaceHolderSize, (ncm::PlaceHolderId placeholder_id, s64 size), (placeholder_id, size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 18, Result, ReadContentIdFile, (const sf::OutBuffer &buf, ncm::ContentId content_id, s64 offset), (buf, content_id, offset), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_2_0_0, hos::Version_2_3_0) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderIdDeprecated2, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id), (out_rights_id, placeholder_id), hos::Version_3_0_0, hos::Version_15_0_1) \ + AMS_SF_METHOD_INFO(C, H, 19, Result, GetRightsIdFromPlaceHolderId, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id, fs::ContentAttributes attr), (out_rights_id, placeholder_id, attr), hos::Version_16_0_0) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated, (sf::Out out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_2_0_0, hos::Version_2_3_0) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentIdDeprecated2, (sf::Out out_rights_id, ncm::ContentId content_id), (out_rights_id, content_id), hos::Version_3_0_0, hos::Version_15_0_1) \ + AMS_SF_METHOD_INFO(C, H, 20, Result, GetRightsIdFromContentId, (sf::Out out_rights_id, ncm::ContentId content_id, fs::ContentAttributes attr), (out_rights_id, content_id, attr), hos::Version_16_0_0) \ + AMS_SF_METHOD_INFO(C, H, 21, Result, WriteContentForDebug, (ncm::ContentId content_id, s64 offset, const sf::InBuffer &data), (content_id, offset, data), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 22, Result, GetFreeSpaceSize, (sf::Out out_size), (out_size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 23, Result, GetTotalSpaceSize, (sf::Out out_size), (out_size), hos::Version_2_0_0) \ + AMS_SF_METHOD_INFO(C, H, 24, Result, FlushPlaceHolder, (), (), hos::Version_3_0_0) \ + AMS_SF_METHOD_INFO(C, H, 25, Result, GetSizeFromPlaceHolderId, (sf::Out out, ncm::PlaceHolderId placeholder_id), (out, placeholder_id), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 26, Result, RepairInvalidFileAttribute, (), (), hos::Version_4_0_0) \ + AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCacheDeprecated, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id, ncm::ContentId cache_content_id), (out_rights_id, placeholder_id, cache_content_id), hos::Version_8_0_0) \ + AMS_SF_METHOD_INFO(C, H, 27, Result, GetRightsIdFromPlaceHolderIdWithCache, (sf::Out out_rights_id, ncm::PlaceHolderId placeholder_id, ncm::ContentId cache_content_id, fs::ContentAttributes attr), (out_rights_id, placeholder_id, cache_content_id, attr), hos::Version_16_0_0) \ + AMS_SF_METHOD_INFO(C, H, 28, Result, RegisterPath, (const ncm::ContentId &content_id, const ncm::Path &path), (content_id, path), hos::Version_13_0_0) \ + AMS_SF_METHOD_INFO(C, H, 29, Result, ClearRegisteredPath, (), (), hos::Version_13_0_0) AMS_SF_DEFINE_INTERFACE(ams::ncm, IContentStorage, AMS_NCM_I_CONTENT_STORAGE_INTERFACE_INFO, 0xFEAE3DD1) diff --git a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp index e84f9e380..24b71eae0 100644 --- a/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp +++ b/libraries/libstratosphere/include/stratosphere/ncm/ncm_install_task_base.hpp @@ -191,7 +191,7 @@ namespace ams::ncm { InstallContentInfo MakeInstallContentInfoFrom(const InstallContentMetaInfo &info, const PlaceHolderId &placeholder_id, util::optional is_temporary); - Result ReadContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const ContentMetaKey &key); + Result ReadContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const ContentMetaKey &key, fs::ContentAttributes attr); Result ListRightsIdsByInstallContentMeta(s32 *out_count, Span out_span, const InstallContentMeta &content_meta, s32 offset); public: virtual Result CheckInstallable() { R_SUCCEED(); } diff --git a/libraries/libstratosphere/source/fs/fs_application.cpp b/libraries/libstratosphere/source/fs/fs_application.cpp index 39d99483a..7aadc5403 100644 --- a/libraries/libstratosphere/source/fs/fs_application.cpp +++ b/libraries/libstratosphere/source/fs/fs_application.cpp @@ -35,7 +35,7 @@ namespace ams::fs { /* Open the filesystem. */ auto fsp = impl::GetFileSystemProxyServiceObject(); sf::SharedPointer fs; - R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), sf_path, ncm::InvalidProgramId.value, impl::FileSystemProxyType_Package)); + R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), sf_path, fs::ContentAttributes_None, ncm::InvalidProgramId.value, impl::FileSystemProxyType_Package)); /* Allocate a new filesystem wrapper. */ auto fsa = std::make_unique(std::move(fs)); diff --git a/libraries/libstratosphere/source/fs/fs_code.cpp b/libraries/libstratosphere/source/fs/fs_code.cpp index b39df8f15..23fa37a13 100644 --- a/libraries/libstratosphere/source/fs/fs_code.cpp +++ b/libraries/libstratosphere/source/fs/fs_code.cpp @@ -69,7 +69,7 @@ namespace ams::fs { return GetReference(g_stratosphere_romfs_fs); } - Result OpenCodeFileSystemImpl(CodeVerificationData *out_verification_data, std::unique_ptr *out, const char *path, ncm::ProgramId program_id) { + Result OpenCodeFileSystemImpl(CodeVerificationData *out_verification_data, std::unique_ptr *out, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id) { /* Print a path suitable for the remote service. */ fssrv::sf::Path sf_path; R_TRY(FormatToFspPath(std::addressof(sf_path), "%s", path)); @@ -79,7 +79,7 @@ namespace ams::fs { R_TRY(fsp->SetCurrentProcess({})); sf::SharedPointer fs; - R_TRY(fsp->OpenCodeFileSystem(std::addressof(fs), out_verification_data, sf_path, program_id)); + R_TRY(fsp->OpenCodeFileSystem(std::addressof(fs), out_verification_data, sf_path, attr, program_id)); /* Allocate a new filesystem wrapper. */ auto fsa = std::make_unique(std::move(fs)); @@ -93,7 +93,7 @@ namespace ams::fs { /* Open the filesystem. */ auto fsp = impl::GetFileSystemProxyServiceObject(); sf::SharedPointer fs; - R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), path, ncm::InvalidProgramId.value, impl::FileSystemProxyType_Package)); + R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), path, fs::ContentAttributes_None, ncm::InvalidProgramId.value, impl::FileSystemProxyType_Package)); /* Allocate a new filesystem wrapper. */ auto fsa = std::make_unique(std::move(fs)); @@ -148,7 +148,7 @@ namespace ams::fs { R_SUCCEED(); } - Result OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(CodeVerificationData *out_verification_data, std::unique_ptr *out, const char *path, ncm::ProgramId program_id) { + Result OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(CodeVerificationData *out_verification_data, std::unique_ptr *out, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id) { /* If we can open an sd card code fs, use it. */ R_SUCCEED_IF(R_SUCCEEDED(OpenSdCardCodeFileSystemImpl(out, program_id))); @@ -156,7 +156,7 @@ namespace ams::fs { R_SUCCEED_IF(R_SUCCEEDED(OpenStratosphereCodeFileSystemImpl(out, program_id))); /* Otherwise, fall back to a normal code fs. */ - R_RETURN(OpenCodeFileSystemImpl(out_verification_data, out, path, program_id)); + R_RETURN(OpenCodeFileSystemImpl(out_verification_data, out, path, attr, program_id)); } Result OpenHblCodeFileSystemImpl(std::unique_ptr *out) { @@ -338,7 +338,7 @@ namespace ams::fs { public: AtmosphereCodeFileSystem() : m_initialized(false) { /* ... */ } - Result Initialize(CodeVerificationData *out_verification_data, const char *path, ncm::ProgramId program_id, bool is_hbl, bool is_specific) { + Result Initialize(CodeVerificationData *out_verification_data, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id, bool is_hbl, bool is_specific) { AMS_ABORT_UNLESS(!m_initialized); /* If we're hbl, we need to open a hbl fs. */ @@ -350,7 +350,7 @@ namespace ams::fs { /* Open the code filesystem. */ std::unique_ptr fsa; - R_TRY(OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(out_verification_data, std::addressof(fsa), path, program_id)); + R_TRY(OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(out_verification_data, std::addressof(fsa), path, attr, program_id)); m_code_fs.emplace(std::move(fsa), program_id, is_specific); m_program_id = program_id; @@ -386,7 +386,7 @@ namespace ams::fs { } - Result MountCode(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id) { + Result MountCode(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id) { auto mount_impl = [=]() -> Result { /* Clear the output. */ std::memset(out, 0, sizeof(*out)); @@ -399,7 +399,7 @@ namespace ams::fs { /* Open the code file system. */ std::unique_ptr fsa; - R_TRY(OpenCodeFileSystemImpl(out, std::addressof(fsa), path, program_id)); + R_TRY(OpenCodeFileSystemImpl(out, std::addressof(fsa), path, attr, program_id)); /* Register. */ R_RETURN(fsa::Register(name, std::move(fsa))); @@ -414,7 +414,7 @@ namespace ams::fs { R_SUCCEED(); } - Result MountCodeForAtmosphereWithRedirection(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id, bool is_hbl, bool is_specific) { + Result MountCodeForAtmosphereWithRedirection(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id, bool is_hbl, bool is_specific) { auto mount_impl = [=]() -> Result { /* Clear the output. */ std::memset(out, 0, sizeof(*out)); @@ -430,7 +430,7 @@ namespace ams::fs { R_UNLESS(ams_code_fs != nullptr, fs::ResultAllocationMemoryFailedInCodeA()); /* Initialize the code file system. */ - R_TRY(ams_code_fs->Initialize(out, path, program_id, is_hbl, is_specific)); + R_TRY(ams_code_fs->Initialize(out, path, attr, program_id, is_hbl, is_specific)); /* Register. */ R_RETURN(fsa::Register(name, std::move(ams_code_fs))); @@ -445,7 +445,7 @@ namespace ams::fs { R_SUCCEED(); } - Result MountCodeForAtmosphere(CodeVerificationData *out, const char *name, const char *path, ncm::ProgramId program_id) { + Result MountCodeForAtmosphere(CodeVerificationData *out, const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId program_id) { auto mount_impl = [=]() -> Result { /* Clear the output. */ std::memset(out, 0, sizeof(*out)); @@ -458,7 +458,7 @@ namespace ams::fs { /* Open the code file system. */ std::unique_ptr fsa; - R_TRY(OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(out, std::addressof(fsa), path, program_id)); + R_TRY(OpenSdCardCodeOrStratosphereCodeOrCodeFileSystemImpl(out, std::addressof(fsa), path, attr, program_id)); /* Create a wrapper fs. */ auto wrap_fsa = std::make_unique(std::move(fsa), program_id, false); diff --git a/libraries/libstratosphere/source/fs/fs_content.cpp b/libraries/libstratosphere/source/fs/fs_content.cpp index f343862c6..059edb64f 100644 --- a/libraries/libstratosphere/source/fs/fs_content.cpp +++ b/libraries/libstratosphere/source/fs/fs_content.cpp @@ -32,7 +32,7 @@ namespace ams::fs { } } - Result MountContentImpl(const char *name, const char *path, u64 id, ContentType type) { + Result MountContentImpl(const char *name, const char *path, fs::ContentAttributes attr, u64 id, ContentType type) { /* Validate the mount name. */ R_TRY(impl::CheckMountNameAllowingReserved(name)); @@ -46,7 +46,7 @@ namespace ams::fs { /* Open the filesystem. */ auto fsp = impl::GetFileSystemProxyServiceObject(); sf::SharedPointer fs; - R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), sf_path, id, ConvertToFileSystemProxyType(type))); + R_TRY(fsp->OpenFileSystemWithId(std::addressof(fs), sf_path, attr, id, ConvertToFileSystemProxyType(type))); /* Allocate a new filesystem wrapper. */ auto fsa = std::make_unique(std::move(fs)); @@ -58,12 +58,12 @@ namespace ams::fs { } - Result MountContent(const char *name, const char *path, ContentType content_type) { + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ContentType content_type) { auto mount_impl = [=]() -> Result { /* This API only supports mounting Meta content. */ R_UNLESS(content_type == ContentType_Meta, fs::ResultInvalidArgument()); - R_RETURN(MountContentImpl(name, path, ncm::InvalidProgramId.value, content_type)); + R_RETURN(MountContentImpl(name, path, attr, ncm::InvalidProgramId.value, content_type)); }; /* Perform the mount. */ @@ -75,9 +75,9 @@ namespace ams::fs { R_SUCCEED(); } - Result MountContent(const char *name, const char *path, ncm::ProgramId id, ContentType content_type) { + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ncm::ProgramId id, ContentType content_type) { auto mount_impl = [=]() -> Result { - R_RETURN(MountContentImpl(name, path, id.value, content_type)); + R_RETURN(MountContentImpl(name, path, attr, id.value, content_type)); }; /* Perform the mount. */ @@ -89,9 +89,9 @@ namespace ams::fs { R_SUCCEED(); } - Result MountContent(const char *name, const char *path, ncm::DataId id, ContentType content_type) { + Result MountContent(const char *name, const char *path, fs::ContentAttributes attr, ncm::DataId id, ContentType content_type) { auto mount_impl = [=]() -> Result { - R_RETURN(MountContentImpl(name, path, id.value, content_type)); + R_RETURN(MountContentImpl(name, path, attr, id.value, content_type)); }; /* Perform the mount. */ diff --git a/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy.hpp b/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy.hpp index 0d21aaf05..f7eda97ad 100644 --- a/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy.hpp +++ b/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy.hpp @@ -56,10 +56,13 @@ namespace ams::fs { AMS_ABORT("TODO"); } + Result OpenFileSystemWithIdObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type) { + R_RETURN(this->OpenFileSystemWithId(out, path, fs::ContentAttributes_None, program_id, type)); + } - Result OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type) { + Result OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u64 program_id, u32 type) { ::FsFileSystem fs; - R_TRY(fsOpenFileSystemWithId(std::addressof(fs), program_id, static_cast<::FsFileSystemType>(type), path.str)); + R_TRY(fsOpenFileSystemWithId(std::addressof(fs), program_id, static_cast<::FsFileSystemType>(type), path.str, static_cast<::FsContentAttributes>(static_cast(attr)))); out.SetValue(ObjectFactory::CreateSharedEmplaced(fs)); R_SUCCEED(); @@ -261,7 +264,11 @@ namespace ams::fs { AMS_ABORT("TODO"); } - Result OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type) { + Result OpenDataStorageByPathObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type) { + AMS_ABORT("TODO"); + } + + Result OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u32 type) { AMS_ABORT("TODO"); } @@ -319,9 +326,13 @@ namespace ams::fs { R_RETURN(fsGetRightsIdByPath(path.str, reinterpret_cast<::FsRightsId *>(out.GetPointer()))); } - Result GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path) { + Result GetRightsIdAndKeyGenerationByPathObsolete(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path) { + R_RETURN(this->GetRightsIdAndKeyGenerationByPath(out, out_key_generation, path, fs::ContentAttributes_None)) + } + + Result GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path, fs::ContentAttributes attr) { static_assert(sizeof(RightsId) == sizeof(::FsRightsId)); - R_RETURN(fsGetRightsIdAndKeyGenerationByPath(path.str, out_key_generation.GetPointer(), reinterpret_cast<::FsRightsId *>(out.GetPointer()))); + R_RETURN(fsGetRightsIdAndKeyGenerationByPath(path.str, static_cast<::FsContentAttributes>(static_cast(attr)), out_key_generation.GetPointer(), reinterpret_cast<::FsRightsId *>(out.GetPointer()))); } Result SetCurrentPosixTimeWithTimeDifference(s64 posix_time, s32 time_difference) { diff --git a/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy_for_loader.hpp b/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy_for_loader.hpp index a7cca39b3..fff9ba88c 100644 --- a/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy_for_loader.hpp +++ b/libraries/libstratosphere/source/fs/fs_remote_file_system_proxy_for_loader.hpp @@ -33,15 +33,23 @@ namespace ams::fs { Result OpenCodeFileSystemDeprecated(ams::sf::Out> out_fs, const fssrv::sf::Path &path, ncm::ProgramId program_id) { ::FsCodeInfo dummy; ::FsFileSystem fs; - R_TRY(fsldrOpenCodeFileSystem(std::addressof(dummy), program_id.value, path.str, std::addressof(fs))); + R_TRY(fsldrOpenCodeFileSystem(std::addressof(dummy), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast(fs::ContentAttributes_None)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced(fs)); R_SUCCEED(); } - Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { + Result OpenCodeFileSystemDeprecated2(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { ::FsFileSystem fs; - R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, std::addressof(fs))); + R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast(fs::ContentAttributes_None)), std::addressof(fs))); + + out_fs.SetValue(ObjectFactory::CreateSharedEmplaced(fs)); + R_SUCCEED(); + } + + Result OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id) { + ::FsFileSystem fs; + R_TRY(fsldrOpenCodeFileSystem(reinterpret_cast<::FsCodeInfo *>(out_verif.GetPointer()), program_id.value, path.str, static_cast<::FsContentAttributes>(static_cast(attr)), std::addressof(fs))); out_fs.SetValue(ObjectFactory::CreateSharedEmplaced(fs)); R_SUCCEED(); diff --git a/libraries/libstratosphere/source/fs/fs_rights_id.cpp b/libraries/libstratosphere/source/fs/fs_rights_id.cpp index a090cefbb..0de773224 100644 --- a/libraries/libstratosphere/source/fs/fs_rights_id.cpp +++ b/libraries/libstratosphere/source/fs/fs_rights_id.cpp @@ -19,7 +19,13 @@ namespace ams::fs { - Result GetRightsId(RightsId *out, const char *path) { + Result GetRightsId(RightsId *out, const char *path, fs::ContentAttributes attr) { + /* If possible, prefer the non-removed functionality. */ + if (hos::GetVersion() >= hos::Version_3_0_0) { + u8 dummy_key_generation; + R_RETURN(GetRightsId(out, std::addressof(dummy_key_generation), path, attr)); + } + AMS_FS_R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); AMS_FS_R_UNLESS(path != nullptr, fs::ResultNullptrArgument()); @@ -33,7 +39,7 @@ namespace ams::fs { R_SUCCEED(); } - Result GetRightsId(RightsId *out, u8 *out_key_generation, const char *path) { + Result GetRightsId(RightsId *out, u8 *out_key_generation, const char *path, fs::ContentAttributes attr) { AMS_FS_R_UNLESS(out != nullptr, fs::ResultNullptrArgument()); AMS_FS_R_UNLESS(out_key_generation != nullptr, fs::ResultNullptrArgument()); AMS_FS_R_UNLESS(path != nullptr, fs::ResultNullptrArgument()); @@ -43,7 +49,7 @@ namespace ams::fs { R_TRY(fs::ConvertToFspPath(std::addressof(sf_path), path)); auto fsp = impl::GetFileSystemProxyServiceObject(); - AMS_FS_R_TRY(fsp->GetRightsIdAndKeyGenerationByPath(out, out_key_generation, sf_path)); + AMS_FS_R_TRY(fsp->GetRightsIdAndKeyGenerationByPath(out, out_key_generation, sf_path, attr)); R_SUCCEED(); } diff --git a/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_impl.cpp b/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_impl.cpp index 0f2c8273c..75b7b7276 100644 --- a/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_impl.cpp +++ b/libraries/libstratosphere/source/fssrv/fssrv_file_system_proxy_impl.cpp @@ -53,7 +53,11 @@ namespace ams::fssrv { AMS_ABORT("TODO"); } - Result FileSystemProxyImpl::OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type) { + Result FileSystemProxyImpl::OpenFileSystemWithIdObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u64 program_id, u32 type) { + AMS_ABORT("TODO"); + } + + Result FileSystemProxyImpl::OpenFileSystemWithId(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u64 program_id, u32 type) { AMS_ABORT("TODO"); } @@ -255,7 +259,11 @@ namespace ams::fssrv { AMS_ABORT("TODO"); } - Result FileSystemProxyImpl::OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type) { + Result FileSystemProxyImpl::OpenDataStorageByPathObsolete(ams::sf::Out> out, const fssrv::sf::FspPath &path, u32 type) { + AMS_ABORT("TODO"); + } + + Result FileSystemProxyImpl::OpenDataStorageByPath(ams::sf::Out> out, const fssrv::sf::FspPath &path, fs::ContentAttributes attr, u32 type) { AMS_ABORT("TODO"); } @@ -303,7 +311,11 @@ namespace ams::fssrv { AMS_ABORT("TODO"); } - Result FileSystemProxyImpl::GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path) { + Result FileSystemProxyImpl::GetRightsIdAndKeyGenerationByPathObsolete(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path) { + AMS_ABORT("TODO"); + } + + Result FileSystemProxyImpl::GetRightsIdAndKeyGenerationByPath(ams::sf::Out out, ams::sf::Out out_key_generation, const fssrv::sf::FspPath &path, fs::ContentAttributes attr) { AMS_ABORT("TODO"); } @@ -448,11 +460,16 @@ namespace ams::fssrv { AMS_UNUSED(out_fs, path, program_id); } - Result FileSystemProxyImpl::OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { + Result FileSystemProxyImpl::OpenCodeFileSystemDeprecated2(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, ncm::ProgramId program_id) { AMS_ABORT("TODO"); AMS_UNUSED(out_fs, out_verif, path, program_id); } + Result FileSystemProxyImpl::OpenCodeFileSystem(ams::sf::Out> out_fs, ams::sf::Out out_verif, const fssrv::sf::Path &path, fs::ContentAttributes attr, ncm::ProgramId program_id) { + AMS_ABORT("TODO"); + AMS_UNUSED(out_fs, out_verif, path, attr, program_id); + } + Result FileSystemProxyImpl::IsArchivedProgram(ams::sf::Out out, u64 process_id) { AMS_ABORT("TODO"); AMS_UNUSED(out, process_id); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp index be098ea1e..1f6965b00 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_management_utils.cpp @@ -37,7 +37,7 @@ namespace ams::ncm { char path[MaxPackagePathLength]; R_TRY(ConvertToFsCommonPath(path, sizeof(path), package_root_path, entry.name)); - R_RETURN(ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(out, path)); + R_RETURN(ncm::TryReadContentMetaPath(out, path, ncm::ReadContentMetaPathWithoutExtendedDataOrDigest)); } template @@ -108,7 +108,7 @@ namespace ams::ncm { /* Read the content meta path, and build. */ ncm::AutoBuffer package_meta; - if (R_SUCCEEDED(ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(std::addressof(package_meta), path.str))) { + if (R_SUCCEEDED(ncm::TryReadContentMetaPath(std::addressof(package_meta), path.str, ncm::ReadContentMetaPathWithoutExtendedDataOrDigest))) { /* Get the size of the content. */ s64 size; R_TRY(storage->GetSize(std::addressof(size), content_id)); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp index 647ba99e6..279130f4a 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.cpp @@ -275,11 +275,11 @@ namespace ams::ncm { R_SUCCEED(); } - Result ContentMetaDatabaseImpl::GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { + Result ContentMetaDatabaseImpl::GetPatchContentMetaId(sf::Out out_patch_id, const ContentMetaKey &key) { R_TRY(this->EnsureEnabled()); /* Only applications can have patches. */ - R_UNLESS(key.type == ContentMetaType::Application, ncm::ResultInvalidContentMetaKey()); + R_UNLESS(key.type == ContentMetaType::Application || key.type == ContentMetaType::AddOnContent, ncm::ResultInvalidContentMetaKey()); /* Obtain the content meta for the key. */ const void *meta; @@ -290,7 +290,17 @@ namespace ams::ncm { ContentMetaReader reader(meta, meta_size); /* Obtain the patch id. */ - out_patch_id.SetValue(reader.GetExtendedHeader()->patch_id); + switch (key.type) { + case ContentMetaType::Application: + out_patch_id.SetValue(reader.GetExtendedHeader()->patch_id.value); + break; + case ContentMetaType::Patch: + R_UNLESS(reader.GetExtendedHeaderSize() == sizeof(AddOnContentMetaExtendedHeader), ncm::ResultInvalidAddOnContentMetaExtendedHeader()); + out_patch_id.SetValue(reader.GetExtendedHeader()->data_patch_id.value); + break; + AMS_UNREACHABLE_DEFAULT_CASE(); + } + R_SUCCEED(); } diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp index fddb30e2c..7b51783cc 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl.hpp @@ -50,7 +50,7 @@ namespace ams::ncm { virtual Result HasAll(sf::Out out, const sf::InArray &keys) override; virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) override; virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) override; - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) override; + virtual Result GetPatchContentMetaId(sf::Out out_patch_id, const ContentMetaKey &key) override; virtual Result DisableForcibly() override; virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) override; virtual Result Commit() override; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp index 96ecc178f..d89483d80 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_database_impl_base.hpp @@ -66,7 +66,7 @@ namespace ams::ncm { virtual Result HasAll(sf::Out out, const sf::InArray &keys) = 0; virtual Result GetSize(sf::Out out_size, const ContentMetaKey &key) = 0; virtual Result GetRequiredSystemVersion(sf::Out out_version, const ContentMetaKey &key) = 0; - virtual Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) = 0; + virtual Result GetPatchContentMetaId(sf::Out out_patch_id, const ContentMetaKey &key) = 0; virtual Result DisableForcibly() = 0; virtual Result LookupOrphanContent(const sf::OutArray &out_orphaned, const sf::InArray &content_ids) = 0; virtual Result Commit() = 0; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp index b036c384e..1759f9cf0 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_meta_utils.cpp @@ -20,8 +20,8 @@ namespace ams::ncm { namespace { - Result MountContentMetaByRemoteFileSystemProxy(const char *mount_name, const char *path) { - R_RETURN(fs::MountContent(mount_name, path, fs::ContentType_Meta)); + Result MountContentMetaByRemoteFileSystemProxy(const char *mount_name, const char *path, fs::ContentAttributes attr) { + R_RETURN(fs::MountContent(mount_name, path, attr, fs::ContentType_Meta)); } constinit MountContentMetaFunction g_mount_content_meta_func = MountContentMetaByRemoteFileSystemProxy; @@ -30,8 +30,8 @@ namespace ams::ncm { namespace impl { - Result MountContentMetaImpl(const char *mount_name, const char *path) { - R_RETURN(g_mount_content_meta_func(mount_name, path)); + Result MountContentMetaImpl(const char *mount_name, const char *path, fs::ContentAttributes attr) { + R_RETURN(g_mount_content_meta_func(mount_name, path, attr)); } } @@ -40,10 +40,10 @@ namespace ams::ncm { return impl::PathView(name).HasSuffix(".cnmt"); } - Result ReadContentMetaPathAlongWithExtendedDataAndDigest(AutoBuffer *out, const char *path) { + Result ReadContentMetaPathAlongWithExtendedDataAndDigest(AutoBuffer *out, const char *path, fs::ContentAttributes attr) { /* Mount the content. */ auto mount_name = impl::CreateUniqueMountName(); - R_TRY(impl::MountContentMetaImpl(mount_name.str, path)); + R_TRY(impl::MountContentMetaImpl(mount_name.str, path, attr)); ON_SCOPE_EXIT { fs::Unmount(mount_name.str); }; /* Open the root directory. */ @@ -89,15 +89,15 @@ namespace ams::ncm { R_THROW(ncm::ResultContentMetaNotFound()); } - Result ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(AutoBuffer *out, const char *path) { + Result ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(AutoBuffer *out, const char *path, fs::ContentAttributes attr) { fs::ScopedAutoAbortDisabler aad; - R_RETURN(ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path)); + R_RETURN(ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path, attr)); } - Result ReadContentMetaPathWithoutExtendedDataOrDigest(AutoBuffer *out, const char *path) { + Result ReadContentMetaPathWithoutExtendedDataOrDigest(AutoBuffer *out, const char *path, fs::ContentAttributes attr) { /* Mount the content. */ auto mount_name = impl::CreateUniqueMountName(); - R_TRY(impl::MountContentMetaImpl(mount_name.str, path)); + R_TRY(impl::MountContentMetaImpl(mount_name.str, path, attr)); ON_SCOPE_EXIT { fs::Unmount(mount_name.str); }; /* Open the root directory. */ @@ -157,14 +157,44 @@ namespace ams::ncm { R_THROW(ncm::ResultContentMetaNotFound()); } - Result ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort(AutoBuffer *out, const char *path) { + Result ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort(AutoBuffer *out, const char *path, fs::ContentAttributes attr) { fs::ScopedAutoAbortDisabler aad; - R_RETURN(ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path)); + R_RETURN(ReadContentMetaPathAlongWithExtendedDataAndDigest(out, path, attr)); } - Result ReadVariationContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const Path &path, FirmwareVariationId firmware_variation_id) { + Result TryReadContentMetaPath(fs::ContentAttributes *out_attr, AutoBuffer *out, const char *path, ReadContentMetaPathFunction func) { + /* Try with attributes = none. */ + fs::ContentAttributes attr = fs::ContentAttributes_None; + R_TRY_CATCH(func(out, path, attr)) { + R_CATCH(fs::ResultNcaHeaderSignature1VerificationFailed) { + /* On signature failure, try with attributes = all. */ + attr = fs::ContentAttributes_All; + R_TRY(func(out, path, attr)); + } + } R_END_TRY_CATCH; + + /* Set output attributes. */ + *out_attr = attr; + R_SUCCEED(); + } + + Result TryReadContentMetaPath(AutoBuffer *out, const char *path, ReadContentMetaPathFunction func) { + /* Try with attributes = none. */ + fs::ContentAttributes attr = fs::ContentAttributes_None; + R_TRY_CATCH(func(out, path, attr)) { + R_CATCH(fs::ResultNcaHeaderSignature1VerificationFailed) { + /* On signature failure, try with attributes = all. */ + attr = fs::ContentAttributes_All; + R_TRY(func(out, path, attr)); + } + } R_END_TRY_CATCH; + + R_SUCCEED(); + } + + Result ReadVariationContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const Path &path, fs::ContentAttributes attr, FirmwareVariationId firmware_variation_id) { AutoBuffer meta; - R_TRY(ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(std::addressof(meta), path.str)); + R_TRY(ReadContentMetaPathAlongWithExtendedDataAndDigestSuppressingFsAbort(std::addressof(meta), path.str, attr)); /* Create a reader for the content meta. */ PackagedContentMetaReader reader(meta.Get(), meta.GetSize()); diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp index 1928303c2..cc0ed64b3 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.cpp @@ -714,14 +714,18 @@ namespace ams::ncm { Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { /* Obtain the regular rights id for the placeholder id. */ ncm::RightsId rights_id; - R_TRY(this->GetRightsIdFromPlaceHolderId(std::addressof(rights_id), placeholder_id)); + R_TRY(this->GetRightsIdFromPlaceHolderIdDeprecated2(std::addressof(rights_id), placeholder_id)); /* Output the fs rights id. */ out_rights_id.SetValue(rights_id.id); R_SUCCEED(); } - Result ContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + R_RETURN(this->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id, fs::ContentAttributes_None)); + } + + Result ContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) { R_TRY(this->EnsureEnabled()); /* Get the placeholder path. */ @@ -729,20 +733,24 @@ namespace ams::ncm { R_TRY(this->GetPlaceHolderPath(std::addressof(path), placeholder_id)); /* Get the rights id for the placeholder id. */ - R_RETURN(GetRightsId(out_rights_id.GetPointer(), path)); + R_RETURN(GetRightsId(out_rights_id.GetPointer(), path, attr)); } Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { /* Obtain the regular rights id for the content id. */ ncm::RightsId rights_id; - R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id)); + R_TRY(this->GetRightsIdFromContentIdDeprecated2(std::addressof(rights_id), content_id)); /* Output the fs rights id. */ out_rights_id.SetValue(rights_id.id); R_SUCCEED(); } - Result ContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { + Result ContentStorageImpl::GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) { + R_RETURN(this->GetRightsIdFromContentId(out_rights_id, content_id, fs::ContentAttributes_None)); + } + + Result ContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) { R_TRY(this->EnsureEnabled()); /* Attempt to obtain the rights id from the cache. */ @@ -756,7 +764,7 @@ namespace ams::ncm { /* Obtain the rights id for the content. */ ncm::RightsId rights_id; - R_TRY(GetRightsId(std::addressof(rights_id), path)); + R_TRY(GetRightsId(std::addressof(rights_id), path, attr)); /* Store the rights id to the cache. */ m_rights_id_cache->Store(content_id, rights_id); @@ -875,7 +883,11 @@ namespace ams::ncm { R_SUCCEED(); } - Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + R_RETURN(this->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id, fs::ContentAttributes_None)); + } + + Result ContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) { R_TRY(this->EnsureEnabled()); /* Attempt to find the rights id in the cache. */ @@ -893,7 +905,7 @@ namespace ams::ncm { /* Get the rights id. */ ncm::RightsId rights_id; - R_TRY(GetRightsId(std::addressof(rights_id), common_path)); + R_TRY(GetRightsId(std::addressof(rights_id), common_path, attr)); m_rights_id_cache->Store(cache_content_id, rights_id); /* Set output. */ diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp index 237620532..8cf758810 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl.hpp @@ -91,16 +91,19 @@ namespace ams::ncm { virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override; virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) override; virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; - virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; + virtual Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; + virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) override; virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) override; - virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) override; + virtual Result GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) override; + virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) override; virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) override; virtual Result GetFreeSpaceSize(sf::Out out_size) override; virtual Result GetTotalSpaceSize(sf::Out out_size) override; virtual Result FlushPlaceHolder() override; virtual Result GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id) override; virtual Result RepairInvalidFileAttribute() override; - virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override; + virtual Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override; + virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) override; virtual Result RegisterPath(const ContentId &content_id, const Path &path) override; virtual Result ClearRegisteredPath() override; }; diff --git a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp index b14d3dc8f..4fad47d56 100644 --- a/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_content_storage_impl_base.hpp @@ -34,11 +34,11 @@ namespace ams::ncm { R_SUCCEED(); } - static Result GetRightsId(ncm::RightsId *out_rights_id, const Path &path) { + static Result GetRightsId(ncm::RightsId *out_rights_id, const Path &path, fs::ContentAttributes attr) { if (hos::GetVersion() >= hos::Version_3_0_0) { - R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), std::addressof(out_rights_id->key_generation), path.str)); + R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), std::addressof(out_rights_id->key_generation), path.str, attr)); } else { - R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), path.str)); + R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), path.str, attr)); out_rights_id->key_generation = 0; } R_SUCCEED(); @@ -65,16 +65,19 @@ namespace ams::ncm { virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) = 0; virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) = 0; virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) = 0; - virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) = 0; + virtual Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) = 0; + virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) = 0; virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) = 0; - virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) = 0; + virtual Result GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) = 0; + virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) = 0; virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) = 0; virtual Result GetFreeSpaceSize(sf::Out out_size) = 0; virtual Result GetTotalSpaceSize(sf::Out out_size) = 0; virtual Result FlushPlaceHolder() = 0; virtual Result GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id) = 0; virtual Result RepairInvalidFileAttribute() = 0; - virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) = 0; + virtual Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) = 0; + virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) = 0; virtual Result RegisterPath(const ContentId &content_id, const Path &path) = 0; virtual Result ClearRegisteredPath() = 0; }; diff --git a/libraries/libstratosphere/source/ncm/ncm_extended_data_mapper.hpp b/libraries/libstratosphere/source/ncm/ncm_extended_data_mapper.hpp index 6efe6795c..633ffd809 100644 --- a/libraries/libstratosphere/source/ncm/ncm_extended_data_mapper.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_extended_data_mapper.hpp @@ -302,7 +302,7 @@ namespace ams::ncm { this->Finalize(); } - Result Initialize(const char *content_path, bool suppress_fs_auto_abort) { + Result Initialize(const char *content_path, fs::ContentAttributes attr, bool suppress_fs_auto_abort) { /* Set whether we should suppress fs aborts. */ m_suppress_fs_auto_abort = suppress_fs_auto_abort; @@ -311,7 +311,7 @@ namespace ams::ncm { /* Mount the content. */ auto mount_name = impl::CreateUniqueMountName(); - R_TRY(impl::MountContentMetaImpl(mount_name.str, content_path)); + R_TRY(impl::MountContentMetaImpl(mount_name.str, content_path, attr)); /* Set our mount name. */ m_mount_name.emplace(mount_name.str); diff --git a/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp b/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp index 4499a2046..e4140fabc 100644 --- a/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_fs_utils.hpp @@ -45,6 +45,6 @@ namespace ams::ncm::impl { MountName CreateUniqueMountName(); RootDirectoryPath GetRootDirectoryPath(const MountName &mount_name); - Result MountContentMetaImpl(const char *mount_name, const char *path); + Result MountContentMetaImpl(const char *mount_name, const char *path, fs::ContentAttributes attr); } diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp index df28cc613..3ae075e09 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.cpp @@ -129,22 +129,31 @@ namespace ams::ncm { R_THROW(ncm::ResultNotSupported()); } - Result HostContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) { AMS_UNUSED(out_rights_id, placeholder_id); R_THROW(ncm::ResultNotSupported()); } + Result HostContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) { + AMS_UNUSED(out_rights_id, placeholder_id, attr); + R_THROW(ncm::ResultNotSupported()); + } + Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { /* Obtain the regular rights id for the content id. */ ncm::RightsId rights_id; - R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id)); + R_TRY(this->GetRightsIdFromContentIdDeprecated2(std::addressof(rights_id), content_id)); /* Output the fs rights id. */ out_rights_id.SetValue(rights_id.id); R_SUCCEED(); } - Result HostContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { + Result HostContentStorageImpl::GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) { + R_RETURN(this->GetRightsIdFromContentId(out_rights_id, content_id, fs::ContentAttributes_None)); + } + + Result HostContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) { R_TRY(this->EnsureEnabled()); /* Get the content path. */ @@ -153,7 +162,7 @@ namespace ams::ncm { /* Acquire the rights id for the content. */ RightsId rights_id; - R_TRY_CATCH(GetRightsId(std::addressof(rights_id), path)) { + R_TRY_CATCH(GetRightsId(std::addressof(rights_id), path, attr)) { /* The content is absent, output a blank rights id. */ R_CATCH(fs::ResultTargetNotFound) { out_rights_id.SetValue({}); @@ -194,11 +203,16 @@ namespace ams::ncm { R_THROW(ncm::ResultNotSupported()); } - Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id); R_THROW(ncm::ResultNotSupported()); } + Result HostContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) { + AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id, attr); + R_THROW(ncm::ResultNotSupported()); + } + Result HostContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) { AMS_ABORT_UNLESS(spl::IsDevelopment()); R_RETURN(m_registered_content->RegisterPath(content_id, path)); diff --git a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp index 6a6b532dc..bdc93c403 100644 --- a/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_host_content_storage_impl.hpp @@ -29,11 +29,11 @@ namespace ams::ncm { R_SUCCEED(); } - static Result GetRightsId(ncm::RightsId *out_rights_id, const Path &path) { + static Result GetRightsId(ncm::RightsId *out_rights_id, const Path &path, fs::ContentAttributes attr) { if (hos::GetVersion() >= hos::Version_3_0_0) { - R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), std::addressof(out_rights_id->key_generation), path.str)); + R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), std::addressof(out_rights_id->key_generation), path.str, attr)); } else { - R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), path.str)); + R_TRY(fs::GetRightsId(std::addressof(out_rights_id->id), path.str, attr)); out_rights_id->key_generation = 0; } R_SUCCEED(); @@ -62,16 +62,19 @@ namespace ams::ncm { virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size); virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset); virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id); - virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id); + virtual Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id); + virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr); virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id); - virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id); + virtual Result GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id); + virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr); virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data); virtual Result GetFreeSpaceSize(sf::Out out_size); virtual Result GetTotalSpaceSize(sf::Out out_size); virtual Result FlushPlaceHolder(); virtual Result GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id); virtual Result RepairInvalidFileAttribute(); - virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id); + virtual Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id); + virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr); virtual Result RegisterPath(const ContentId &content_id, const Path &path); virtual Result ClearRegisteredPath(); }; diff --git a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp index f44c27688..231d18064 100644 --- a/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_install_task_base.cpp @@ -592,7 +592,7 @@ namespace ams::ncm { /* Open the content storage and obtain the rights id. */ ncm::ContentStorage storage; R_TRY(OpenContentStorage(std::addressof(storage), content_info->storage_id)); - R_TRY(storage.GetRightsId(std::addressof(rights_id), content_info->placeholder_id)); + R_TRY(storage.GetRightsId(std::addressof(rights_id), content_info->placeholder_id, content_info->GetContentAttributes())); } /* Install a ticket if necessary. */ @@ -827,10 +827,13 @@ namespace ams::ncm { continue; } + /* Get the content info. */ + const auto *content_info = reader.GetContentInfo(ContentType::Meta); + /* List content meta infos. */ std::unique_ptr content_meta_infos; s32 num_content_meta_infos; - R_TRY(this->ReadContentMetaInfoList(std::addressof(num_content_meta_infos), std::addressof(content_meta_infos), reader.GetKey())); + R_TRY(this->ReadContentMetaInfoList(std::addressof(num_content_meta_infos), std::addressof(content_meta_infos), reader.GetKey(), content_info->GetContentAttributes())); /* Iterate over content meta infos. */ for (s32 j = 0; j < num_content_meta_infos; j++) { @@ -870,10 +873,13 @@ namespace ams::ncm { continue; } + /* Get the content info. */ + const auto *content_info = reader.GetContentInfo(ContentType::Meta); + /* List content meta infos. */ std::unique_ptr content_meta_infos; s32 num_content_meta_infos; - R_TRY(this->ReadContentMetaInfoList(std::addressof(num_content_meta_infos), std::addressof(content_meta_infos), reader.GetKey())); + R_TRY(this->ReadContentMetaInfoList(std::addressof(num_content_meta_infos), std::addressof(content_meta_infos), reader.GetKey(), content_info->GetContentAttributes())); /* Iterate over content meta infos. */ for (s32 j = 0; j < num_content_meta_infos; j++) { @@ -989,8 +995,9 @@ namespace ams::ncm { } Result InstallTaskBase::GetInstallContentMetaDataFromPath(AutoBuffer *out, const Path &path, const InstallContentInfo &content_info, util::optional source_version) { + fs::ContentAttributes attr; AutoBuffer meta; - R_TRY(ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort(std::addressof(meta), path.str)); + R_TRY(TryReadContentMetaPath(std::addressof(attr), std::addressof(meta), path.str, ReadContentMetaPathWithoutExtendedDataOrDigestSuppressingFsAbort)); /* Create a reader. */ PackagedContentMetaReader reader(meta.Get(), meta.GetSize()); @@ -1005,7 +1012,7 @@ namespace ams::ncm { /* Create a mapper. */ auto mapper = MultiCacheReadonlyMapper<4>(Span(buffers[0], sizeof(buffers[0])), Span(buffers[1], sizeof(buffers[1]))); - R_TRY(mapper.Initialize(path.str, true)); + R_TRY(mapper.Initialize(path.str, static_cast(static_cast(attr) & fs::ContentAttributes_All), true)); /* Create an accessor. */ auto accessor = PatchMetaExtendedDataAccessor{std::addressof(mapper)}; @@ -1153,7 +1160,7 @@ namespace ams::ncm { R_SUCCEED(); } - Result InstallTaskBase::ReadContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const ContentMetaKey &key) { + Result InstallTaskBase::ReadContentMetaInfoList(s32 *out_count, std::unique_ptr *out_meta_infos, const ContentMetaKey &key, fs::ContentAttributes attr) { /* Get the install content meta info. */ InstallContentMetaInfo install_content_meta_info; R_TRY(this->GetInstallContentMetaInfo(std::addressof(install_content_meta_info), key)); @@ -1173,7 +1180,7 @@ namespace ams::ncm { content_storage.GetPlaceHolderPath(std::addressof(path), placeholder_id); /* Read the variation list. */ - R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, m_firmware_variation_id)); + R_TRY(ReadVariationContentMetaInfoList(out_count, out_meta_infos, path, attr, m_firmware_variation_id)); /* Delete the placeholder. */ content_storage.DeletePlaceHolder(placeholder_id); @@ -1377,7 +1384,7 @@ namespace ams::ncm { /* Get the rights id. */ RightsId rights_id; - R_TRY(content_storage.GetRightsId(std::addressof(rights_id), content_info->GetPlaceHolderId())); + R_TRY(content_storage.GetRightsId(std::addressof(rights_id), content_info->GetPlaceHolderId(), content_info->GetContentAttributes())); /* Skip empty rights ids. */ if (rights_id.id == fs::InvalidRightsId) { diff --git a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp index 4679dddfe..49e89e6cc 100644 --- a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp +++ b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.cpp @@ -216,22 +216,31 @@ namespace ams::ncm { R_THROW(ncm::ResultNotSupported()); } - Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) { AMS_UNUSED(out_rights_id, placeholder_id); R_THROW(ncm::ResultNotSupported()); } + Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) { + AMS_UNUSED(out_rights_id, placeholder_id, attr); + R_THROW(ncm::ResultNotSupported()); + } + Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { /* Obtain the regular rights id for the content id. */ ncm::RightsId rights_id; - R_TRY(this->GetRightsIdFromContentId(std::addressof(rights_id), content_id)); + R_TRY(this->GetRightsIdFromContentIdDeprecated2(std::addressof(rights_id), content_id)); /* Output the fs rights id. */ out_rights_id.SetValue(rights_id.id); R_SUCCEED(); } - Result ReadOnlyContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { + Result ReadOnlyContentStorageImpl::GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) { + R_RETURN(this->GetRightsIdFromContentId(out_rights_id, content_id, fs::ContentAttributes_None)); + } + + Result ReadOnlyContentStorageImpl::GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) { R_TRY(this->EnsureEnabled()); /* Get the content path. */ @@ -240,7 +249,7 @@ namespace ams::ncm { /* Get the rights id. */ ncm::RightsId rights_id; - R_TRY(GetRightsId(std::addressof(rights_id), path)); + R_TRY(GetRightsId(std::addressof(rights_id), path, attr)); out_rights_id.SetValue(rights_id); R_SUCCEED(); @@ -274,11 +283,16 @@ namespace ams::ncm { R_THROW(ncm::ResultNotSupported()); } - Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id); R_THROW(ncm::ResultNotSupported()); } + Result ReadOnlyContentStorageImpl::GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) { + AMS_UNUSED(out_rights_id, placeholder_id, cache_content_id, attr); + R_THROW(ncm::ResultNotSupported()); + } + Result ReadOnlyContentStorageImpl::RegisterPath(const ContentId &content_id, const Path &path) { AMS_UNUSED(content_id, path); R_THROW(ncm::ResultInvalidOperation()); diff --git a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.hpp index 1a49877f0..d3b140c3c 100644 --- a/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_read_only_content_storage_impl.hpp @@ -44,16 +44,19 @@ namespace ams::ncm { virtual Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) override; virtual Result ReadContentIdFile(const sf::OutBuffer &buf, ContentId content_id, s64 offset) override; virtual Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; - virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; + virtual Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) override; + virtual Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) override; virtual Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) override; - virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) override; + virtual Result GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) override; + virtual Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) override; virtual Result WriteContentForDebug(ContentId content_id, s64 offset, const sf::InBuffer &data) override; virtual Result GetFreeSpaceSize(sf::Out out_size) override; virtual Result GetTotalSpaceSize(sf::Out out_size) override; virtual Result FlushPlaceHolder() override; virtual Result GetSizeFromPlaceHolderId(sf::Out out, PlaceHolderId placeholder_id) override; virtual Result RepairInvalidFileAttribute() override; - virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override; + virtual Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) override; + virtual Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) override; virtual Result RegisterPath(const ContentId &content_id, const Path &path) override; virtual Result ClearRegisteredPath() override; }; diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp index 5281a3ac3..0919d6d45 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_meta_database_impl.hpp @@ -120,8 +120,8 @@ namespace ams::ncm { R_RETURN(ncmContentMetaDatabaseGetRequiredSystemVersion(std::addressof(m_srv), out_version.GetPointer(), Convert(key))); } - Result GetPatchId(sf::Out out_patch_id, const ContentMetaKey &key) { - R_RETURN(ncmContentMetaDatabaseGetPatchId(std::addressof(m_srv), reinterpret_cast(out_patch_id.GetPointer()), Convert(key))); + Result GetPatchContentMetaId(sf::Out out_patch_id, const ContentMetaKey &key) { + R_RETURN(ncmContentMetaDatabaseGetPatchContentMetaId(std::addressof(m_srv), out_patch_id.GetPointer(), Convert(key))); } Result DisableForcibly() { diff --git a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp index 94b648a7c..954acffcd 100644 --- a/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp +++ b/libraries/libstratosphere/source/ncm/ncm_remote_content_storage_impl.hpp @@ -56,6 +56,10 @@ namespace ams::ncm { static_assert(sizeof(ContentId) == sizeof(::NcmContentId)); return reinterpret_cast(std::addressof(c)); } + + ALWAYS_INLINE ::FsContentAttributes Convert(fs::ContentAttributes attr) { + return static_cast<::FsContentAttributes>(static_cast(attr)); + } public: Result GeneratePlaceHolderId(sf::Out out) { R_RETURN(ncmContentStorageGeneratePlaceHolderId(std::addressof(m_srv), Convert(out.GetPointer()))); @@ -137,16 +141,20 @@ namespace ams::ncm { Result GetRightsIdFromPlaceHolderIdDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id))); + R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id), Convert(fs::ContentAttributes_None))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); R_SUCCEED(); } - Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + Result GetRightsIdFromPlaceHolderIdDeprecated2(sf::Out out_rights_id, PlaceHolderId placeholder_id) { + R_RETURN(this->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id, fs::ContentAttributes_None)); + } + + Result GetRightsIdFromPlaceHolderId(sf::Out out_rights_id, PlaceHolderId placeholder_id, fs::ContentAttributes attr) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id))); + R_TRY(ncmContentStorageGetRightsIdFromPlaceHolderId(std::addressof(m_srv), std::addressof(rights_id), Convert(placeholder_id), Convert(attr))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -155,16 +163,20 @@ namespace ams::ncm { Result GetRightsIdFromContentIdDeprecated(sf::Out out_rights_id, ContentId content_id) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id))); + R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id), Convert(fs::ContentAttributes_None))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); R_SUCCEED(); } - Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id) { + Result GetRightsIdFromContentIdDeprecated2(sf::Out out_rights_id, ContentId content_id) { + R_RETURN(this->GetRightsIdFromContentId(out_rights_id, content_id, fs::ContentAttributes_None)); + } + + Result GetRightsIdFromContentId(sf::Out out_rights_id, ContentId content_id, fs::ContentAttributes attr) { ::NcmRightsId rights_id; - R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id))); + R_TRY(ncmContentStorageGetRightsIdFromContentId(std::addressof(m_srv), std::addressof(rights_id), Convert(content_id), Convert(attr))); static_assert(sizeof(*out_rights_id.GetPointer()) <= sizeof(rights_id)); std::memcpy(out_rights_id.GetPointer(), std::addressof(rights_id), sizeof(*out_rights_id.GetPointer())); @@ -195,10 +207,14 @@ namespace ams::ncm { R_RETURN(ncmContentStorageRepairInvalidFileAttribute(std::addressof(m_srv))); } - Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + Result GetRightsIdFromPlaceHolderIdWithCacheDeprecated(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { + R_RETURN(this->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id, fs::ContentAttributes_None)); + } + + Result GetRightsIdFromPlaceHolderIdWithCache(sf::Out out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id, fs::ContentAttributes attr) { static_assert(sizeof(::NcmRightsId) == sizeof(ncm::RightsId)); ::NcmRightsId *out = reinterpret_cast<::NcmRightsId *>(out_rights_id.GetPointer()); - R_RETURN(ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id))); + R_RETURN(ncmContentStorageGetRightsIdFromPlaceHolderIdWithCache(std::addressof(m_srv), out, Convert(placeholder_id), Convert(cache_content_id), Convert(attr))); } Result RegisterPath(const ContentId &content_id, const Path &path) { diff --git a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp index 4ab05b0c3..e1e6cb7da 100644 --- a/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp +++ b/libraries/libstratosphere/source/pgl/srv/pgl_srv_shell_host_utils.cpp @@ -263,7 +263,7 @@ namespace ams::pgl::srv { R_UNLESS(has_content, pgl::ResultContentMetaNotFound()); /* Read the content meta buffer. */ - R_RETURN(ncm::ReadContentMetaPathWithoutExtendedDataOrDigest(std::addressof(m_content_meta_buffer), meta_path.str)); + R_RETURN(ncm::TryReadContentMetaPath(std::addressof(m_content_meta_buffer), meta_path.str, ncm::ReadContentMetaPathWithoutExtendedDataOrDigest)); } Result SearchContent(bool *out, lr::Path *out_path, const char *extension, fs::OpenDirectoryMode mode) const { diff --git a/libraries/libvapours/include/vapours/results/ncm_results.hpp b/libraries/libvapours/include/vapours/results/ncm_results.hpp index dd46af9e0..45d7c3a0a 100644 --- a/libraries/libvapours/include/vapours/results/ncm_results.hpp +++ b/libraries/libvapours/include/vapours/results/ncm_results.hpp @@ -52,6 +52,7 @@ namespace ams::ncm { R_DEFINE_ERROR_RESULT(UnexpectedContentMetaPrepared, 360); R_DEFINE_ERROR_RESULT(InvalidFirmwareVariation, 380); R_DEFINE_ERROR_RESULT(InvalidContentMetaFileSize, 390); + R_DEFINE_ERROR_RESULT(InvalidAddOnContentMetaExtendedHeader, 400); R_DEFINE_ERROR_RANGE(ContentStorageNotActive, 250, 258); R_DEFINE_ERROR_RESULT(GameCardContentStorageNotActive, 251);