From b7ed9c58bbd13de24038b99631057eb877ff5755 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Sun, 13 Mar 2022 01:32:34 -0800 Subject: [PATCH] strat: revise fs unsupported operation results, add overflow utils --- fusee/program/source/fs/fusee_fs_storage.hpp | 2 +- .../stratosphere/fs/fs_memory_storage.hpp | 4 +- .../fs/fs_read_only_filesystem.hpp | 28 ++-- .../stratosphere/fs/fs_remote_filesystem.hpp | 2 +- .../include/stratosphere/fs/fs_substorage.hpp | 6 +- ...ystem_aes_ctr_counter_extended_storage.hpp | 4 +- .../fssystem_block_cache_buffered_storage.hpp | 2 +- .../fssystem/fssystem_compressed_storage.hpp | 6 +- ...rchical_integrity_verification_storage.hpp | 2 +- .../fssystem/fssystem_indirect_storage.hpp | 4 +- .../fssystem_integrity_romfs_storage.hpp | 2 +- ...ssystem_integrity_verification_storage.hpp | 2 +- .../fssystem/fssystem_sparse_storage.hpp | 4 +- .../source/fs/common/fs_file_storage.cpp | 4 +- .../source/fs/fs_romfs_filesystem.cpp | 26 ++-- .../fs_storage_service_object_adapter.hpp | 2 +- ...ystem_aes_ctr_counter_extended_storage.cpp | 2 +- .../fssystem/fssystem_aes_ctr_storage.cpp | 2 +- .../fssystem_block_cache_buffered_storage.cpp | 4 +- ...fssystem_directory_savedata_filesystem.cpp | 2 +- ...rchical_integrity_verification_storage.cpp | 2 +- .../fssystem_hierarchical_sha256_storage.hpp | 2 +- .../fssystem/fssystem_indirect_storage.cpp | 2 +- ...ssystem_integrity_verification_storage.cpp | 4 +- .../fssystem/fssystem_local_file_system.cpp | 4 +- .../fssystem_nca_file_system_driver.cpp | 6 +- .../fssystem_partition_file_system.cpp | 26 ++-- ...fssystem_read_only_block_cache_storage.hpp | 4 +- .../fssystem/fssystem_romfs_filesystem.cpp | 24 ++-- .../include/vapours/results/fs_results.hpp | 136 +++++++++++------- .../include/vapours/util/util_int_util.hpp | 87 +++++++++++ 31 files changed, 265 insertions(+), 142 deletions(-) diff --git a/fusee/program/source/fs/fusee_fs_storage.hpp b/fusee/program/source/fs/fusee_fs_storage.hpp index 09f92030b..8b44c42ef 100644 --- a/fusee/program/source/fs/fusee_fs_storage.hpp +++ b/fusee/program/source/fs/fusee_fs_storage.hpp @@ -118,7 +118,7 @@ namespace ams::fs { } virtual Result SetSize(s64 size) override { - return fs::ResultUnsupportedOperationInSubStorageA(); + return fs::ResultUnsupportedSetSizeForNotResizableSubStorage(); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp index 8b3b377e4..9c46fd0fb 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_memory_storage.hpp @@ -64,7 +64,7 @@ namespace ams::fs { virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInMemoryStorageA(); + return fs::ResultUnsupportedSetSizeForMemoryStorage(); } virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { @@ -79,7 +79,7 @@ namespace ams::fs { reinterpret_cast(dst)->Clear(); return ResultSuccess(); default: - return fs::ResultUnsupportedOperationInMemoryStorageB(); + return fs::ResultUnsupportedOperateRangeForMemoryStorage(); } } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp index 647ee0bcc..372e73a35 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_read_only_filesystem.hpp @@ -52,12 +52,12 @@ namespace ams::fs { AMS_ASSERT(!need_append); AMS_UNUSED(buffer); - return fs::ResultUnsupportedOperationInReadOnlyFileA(); + return fs::ResultUnsupportedWriteForReadOnlyFile(); } virtual Result DoSetSize(s64 size) override final { R_TRY(this->DrySetSize(size, fs::OpenMode_Read)); - return fs::ResultUnsupportedOperationInReadOnlyFileA(); + return fs::ResultUnsupportedWriteForReadOnlyFile(); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { @@ -66,7 +66,7 @@ namespace ams::fs { case OperationId::QueryRange: return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); default: - return fs::ResultUnsupportedOperationInReadOnlyFileB(); + return fs::ResultUnsupportedOperateRangeForReadOnlyFile(); } } public: @@ -115,57 +115,57 @@ namespace ams::fs { virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final { AMS_UNUSED(path, size, flags); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoDeleteFile(const fs::Path &path) override final { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoCreateDirectory(const fs::Path &path) override final { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoDeleteDirectory(const fs::Path &path) override final { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final { AMS_UNUSED(old_path, new_path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override final { AMS_UNUSED(old_path, new_path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); + return fs::ResultUnsupportedWriteForReadOnlyFileSystem(); } virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final { AMS_UNUSED(out, path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB(); + return fs::ResultUnsupportedCommitProvisionallyForReadOnlyFileSystem(); } virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final { AMS_UNUSED(out, path); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB(); + return fs::ResultUnsupportedCommitProvisionallyForReadOnlyFileSystem(); } virtual Result DoCommitProvisionally(s64 counter) override final { AMS_UNUSED(counter); - return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateC(); + return fs::ResultUnsupportedGetTotalSpaceSizeForReadOnlyFileSystem(); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp index dda728e18..e169a542d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_remote_filesystem.hpp @@ -57,7 +57,7 @@ namespace ams::fs { virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { AMS_UNUSED(src, src_size); - R_UNLESS(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperationInFileServiceObjectAdapterA()); + R_UNLESS(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperateRangeForFileServiceObjectAdapter()); R_UNLESS(dst_size == sizeof(FileQueryRangeInfo), fs::ResultInvalidSize()); return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst)); diff --git a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp index b9d0afc2e..b0ceaca6d 100644 --- a/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fs/fs_substorage.hpp @@ -107,13 +107,13 @@ namespace ams::fs { virtual Result SetSize(s64 size) override { /* Ensure we're initialized and validate arguments. */ R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); - R_UNLESS(m_resizable, fs::ResultUnsupportedOperationInSubStorageA()); + R_UNLESS(m_resizable, fs::ResultUnsupportedSetSizeForNotResizableSubStorage()); R_UNLESS(IStorage::CheckOffsetAndSize(m_offset, size), fs::ResultInvalidSize()); /* Ensure that we're allowed to set size. */ s64 cur_size; R_TRY(m_base_storage->GetSize(std::addressof(cur_size))); - R_UNLESS(cur_size == m_offset + m_size, fs::ResultUnsupportedOperationInSubStorageB()); + R_UNLESS(cur_size == m_offset + m_size, fs::ResultUnsupportedSetSizeForResizableSubStorage()); /* Set the size. */ R_TRY(m_base_storage->SetSize(m_offset + size)); @@ -132,7 +132,7 @@ namespace ams::fs { virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { /* Ensure we're initialized. */ - R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); + R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); /* Succeed immediately on zero-sized operation. */ R_SUCCEED_IF(size == 0); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp index e1a7922ae..a7a3ebb46 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_aes_ctr_counter_extended_storage.hpp @@ -109,12 +109,12 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - R_THROW(fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageA()); + R_THROW(fs::ResultUnsupportedWriteForAesCtrCounterExtendedStorage()); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - R_THROW(fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageB()); + R_THROW(fs::ResultUnsupportedSetSizeForAesCtrCounterExtendedStorage()); } private: Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, fs::SubStorage data_storage, fs::SubStorage table_storage); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp index 2bdd81585..2c15a1d75 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp @@ -110,7 +110,7 @@ namespace ams::fssystem { virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result Write(s64 offset, const void *buffer, size_t size) override; - virtual Result SetSize(s64) override { R_THROW(fs::ResultUnsupportedOperationInBlockCacheBufferedStorageA()); } + virtual Result SetSize(s64) override { R_THROW(fs::ResultUnsupportedSetSizeForBlockCacheBufferedStorage()); } virtual Result GetSize(s64 *out) override; virtual Result Flush() override; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp index ed1b434aa..e7a752eb7 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_compressed_storage.hpp @@ -1424,7 +1424,7 @@ namespace ams::fssystem { R_TRY(m_core.QueryRange(dst, dst_size, offset, size)); break; default: - R_THROW(fs::ResultUnsupportedOperationInCompressedStorageB()); + R_THROW(fs::ResultUnsupportedOperateRangeForCompressedStorage()); } R_SUCCEED(); @@ -1440,13 +1440,13 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - R_THROW(fs::ResultUnsupportedOperationInCompressedStorageA()); + R_THROW(fs::ResultUnsupportedWriteForCompressedStorage()); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); /* NOTE: Is Nintendo returning the wrong result here? */ - R_THROW(fs::ResultUnsupportedOperationInIndirectStorageB()); + R_THROW(fs::ResultUnsupportedSetSizeForIndirectStorage()); } }; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp index ea45400cd..1d4be4381 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp @@ -162,7 +162,7 @@ namespace ams::fssystem { virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result Write(s64 offset, const void *buffer, size_t size) override; - virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedOperationInHierarchicalIntegrityVerificationStorageA(); } + virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedSetSizeForHierarchicalIntegrityVerificationStorage(); } virtual Result GetSize(s64 *out) override; virtual Result Flush() override; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp index e14dd4658..1ecc9dc58 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_indirect_storage.hpp @@ -147,12 +147,12 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - R_THROW(fs::ResultUnsupportedOperationInIndirectStorageA()); + R_THROW(fs::ResultUnsupportedWriteForIndirectStorage()); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - R_THROW(fs::ResultUnsupportedOperationInIndirectStorageB()); + R_THROW(fs::ResultUnsupportedSetSizeForIndirectStorage()); } protected: BucketTree &GetEntryTable() { return m_table; } diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp index 15d1e5f71..0985c4fc4 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp @@ -48,7 +48,7 @@ namespace ams::fssystem { return m_integrity_storage.Write(offset, buffer, size); } - virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedOperationInIntegrityRomFsStorageA(); } + virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedSetSizeForIntegrityRomFsStorage(); } virtual Result GetSize(s64 *out) override { return m_integrity_storage.GetSize(out); diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp index 5e0aa3254..7bce5c6c2 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp @@ -55,7 +55,7 @@ namespace ams::fssystem { virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result Write(s64 offset, const void *buffer, size_t size) override; - virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedOperationInIntegrityVerificationStorageA(); } + virtual Result SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedSetSizeForIntegrityVerificationStorage(); } virtual Result GetSize(s64 *out) override; virtual Result Flush() override; diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp index d0d406ce5..9c3713918 100644 --- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp +++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_sparse_storage.hpp @@ -56,12 +56,12 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - R_THROW(fs::ResultUnsupportedOperationInZeroStorageA()); + R_THROW(fs::ResultUnsupportedWriteForZeroStorage()); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - R_THROW(fs::ResultUnsupportedOperationInZeroStorageB()); + R_THROW(fs::ResultUnsupportedSetSizeForZeroStorage()); } }; private: diff --git a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp index 20b53317e..84d60518d 100644 --- a/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp +++ b/libraries/libstratosphere/source/fs/common/fs_file_storage.cpp @@ -86,7 +86,7 @@ namespace ams::fs { R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange()); return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); default: - return fs::ResultUnsupportedOperationInFileStorageA(); + return fs::ResultUnsupportedOperateRangeForFileStorage(); } } @@ -171,7 +171,7 @@ namespace ams::fs { return QueryRange(static_cast(dst), m_handle, offset, size); default: - return fs::ResultUnsupportedOperationInFileStorageB(); + return fs::ResultUnsupportedOperateRangeForFileHandleStorage(); } } diff --git a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp index f6c7b9e32..5da9eb064 100644 --- a/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp +++ b/libraries/libstratosphere/source/fs/fs_romfs_filesystem.cpp @@ -221,12 +221,12 @@ namespace ams::fs { virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override { AMS_UNUSED(offset, buffer, size, option); - return fs::ResultUnsupportedOperationInRomFsFileA(); + return fs::ResultUnsupportedWriteForRomFsFile(); } virtual Result DoSetSize(s64 size) override { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInRomFsFileA(); + return fs::ResultUnsupportedWriteForRomFsFile(); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { @@ -245,7 +245,7 @@ namespace ams::fs { return this->GetStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size); } default: - return fs::ResultUnsupportedOperationInRomFsFileB(); + return fs::ResultUnsupportedOperateRangeForRomFsFile(); } } public: @@ -447,37 +447,37 @@ namespace ams::fs { Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) { AMS_UNUSED(path, size, flags); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) { @@ -540,17 +540,17 @@ namespace ams::fs { Result RomFsFileSystem::DoGetTotalSpaceSize(s64 *out, const fs::Path &path) { AMS_UNUSED(out, path); - return fs::ResultUnsupportedOperationInRomFsFileSystemC(); + return fs::ResultUnsupportedGetTotalSpaceSizeForRomFsFileSystem(); } Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - return fs::ResultUnsupportedOperationInRomFsFileSystemA(); + return fs::ResultUnsupportedWriteForRomFsFileSystem(); } Result RomFsFileSystem::DoCommitProvisionally(s64 counter) { AMS_UNUSED(counter); - return fs::ResultUnsupportedOperationInRomFsFileSystemB(); + return fs::ResultUnsupportedCommitProvisionallyForRomFsFileSystem(); } Result RomFsFileSystem::DoRollback() { diff --git a/libraries/libstratosphere/source/fs/impl/fs_storage_service_object_adapter.hpp b/libraries/libstratosphere/source/fs/impl/fs_storage_service_object_adapter.hpp index 8ad5ee109..fbdfd729b 100644 --- a/libraries/libstratosphere/source/fs/impl/fs_storage_service_object_adapter.hpp +++ b/libraries/libstratosphere/source/fs/impl/fs_storage_service_object_adapter.hpp @@ -64,7 +64,7 @@ namespace ams::fs::impl { } default: { - R_THROW(fs::ResultUnsupportedOperationInStorageServiceObjectAdapterA()); + R_THROW(fs::ResultUnsupportedOperateRangeForStorageServiceObjectAdapter()); } } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp index d9de29af3..dede6050a 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_counter_extended_storage.cpp @@ -245,7 +245,7 @@ namespace ams::fssystem { return ResultSuccess(); } default: - return fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageC(); + return fs::ResultUnsupportedOperateRangeForAesCtrCounterExtendedStorage(); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp index 9048dcaef..b078c73c8 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_aes_ctr_storage.cpp @@ -135,7 +135,7 @@ namespace ams::fssystem { template Result AesCtrStorage::SetSize(s64 size) { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInAesCtrStorageA(); + return fs::ResultUnsupportedSetSizeForAesCtrStorage(); } template diff --git a/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp index f2d6d2b9e..4df5697f1 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp @@ -395,7 +395,7 @@ namespace ams::fssystem { } case fs::OperationId::Invalidate: { - R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInBlockCacheBufferedStorageB()); + R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperateRangeForNonSaveDataBlockCacheBufferedStorage()); R_TRY(this->InvalidateImpl()); R_SUCCEED(); } @@ -405,7 +405,7 @@ namespace ams::fssystem { R_SUCCEED(); } default: - R_THROW(fs::ResultUnsupportedOperationInBlockCacheBufferedStorageC()); + R_THROW(fs::ResultUnsupportedOperateRangeForBlockCacheBufferedStorage()); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp index 34d84bcf5..2c4d76691 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_directory_savedata_filesystem.cpp @@ -348,7 +348,7 @@ namespace ams::fssystem { Result DirectorySaveDataFileSystem::DoCommitProvisionally(s64 counter) { /* Check that we support multi-commit. */ - R_UNLESS(m_is_multi_commit_supported, fs::ResultUnsupportedOperationInDirectorySaveDataFileSystemA()); + R_UNLESS(m_is_multi_commit_supported, fs::ResultUnsupportedCommitProvisionallyForDirectorySaveDataFileSystem()); /* Do nothing. */ AMS_UNUSED(counter); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp index 02ebe77c5..b77bb581c 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp @@ -330,7 +330,7 @@ namespace ams::fssystem { return ResultSuccess(); } default: - return fs::ResultUnsupportedOperationInHierarchicalIntegrityVerificationStorageB(); + return fs::ResultUnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage(); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp index a392e0746..afa473289 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_sha256_storage.hpp @@ -53,7 +53,7 @@ namespace ams::fssystem { virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInHierarchicalSha256StorageA(); + return fs::ResultUnsupportedSetSizeForHierarchicalSha256Storage(); } }; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp index bace3fb33..710aa68b4 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_indirect_storage.cpp @@ -171,7 +171,7 @@ namespace ams::fssystem { R_SUCCEED(); } default: - return fs::ResultUnsupportedOperationInIndirectStorageC(); + return fs::ResultUnsupportedOperateRangeForIndirectStorage(); } R_SUCCEED(); diff --git a/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp index 7618bae7a..637138dc9 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp @@ -332,7 +332,7 @@ namespace ams::fssystem { case fs::OperationId::Invalidate: { /* Only allow cache invalidation for RomFs. */ - R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperationInIntegrityVerificationStorageB()); + R_UNLESS(m_storage_type != fs::StorageType_SaveData, fs::ResultUnsupportedOperateRangeForNonSaveDataIntegrityVerificationStorage()); /* Operate on our storages. */ @@ -357,7 +357,7 @@ namespace ams::fssystem { return ResultSuccess(); } default: - return fs::ResultUnsupportedOperationInIntegrityVerificationStorageC(); + return fs::ResultUnsupportedOperateRangeForIntegrityVerificationStorage(); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_local_file_system.cpp b/libraries/libstratosphere/source/fssystem/fssystem_local_file_system.cpp index 1a6bcc477..9b95f7316 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_local_file_system.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_local_file_system.cpp @@ -303,7 +303,7 @@ namespace ams::fssystem { static_cast(dst)->Clear(); R_SUCCEED(); default: - R_THROW(fs::ResultUnsupportedOperationInLocalFileA()); + R_THROW(fs::ResultUnsupportedOperateRangeForTmFileSystemFile()); } } public: @@ -619,7 +619,7 @@ namespace ams::fssystem { static_cast(dst)->Clear(); R_SUCCEED(); default: - R_THROW(fs::ResultUnsupportedOperationInLocalFileA()); + R_THROW(fs::ResultUnsupportedOperateRangeForTmFileSystemFile()); } } public: diff --git a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp index d1f9c460f..5feb3dba9 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp @@ -212,12 +212,12 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - return fs::ResultUnsupportedOperationInAesCtrStorageExternalA(); + return fs::ResultUnsupportedWriteForAesCtrStorageExternal(); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInAesCtrStorageExternalB(); + return fs::ResultUnsupportedSetSizeForAesCtrStorageExternal(); } }; @@ -254,7 +254,7 @@ namespace ams::fssystem { return ResultSuccess(); } default: - return fs::ResultUnsupportedOperationInSwitchStorageA(); + return fs::ResultUnsupportedOperateRangeForSwitchStorage(); } } diff --git a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp index 34969bd3c..d13c02a37 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_partition_file_system.cpp @@ -70,7 +70,7 @@ namespace ams::fssystem { /* Ensure appending is not required. */ bool needs_append; R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, m_mode)); - R_UNLESS(!needs_append, fs::ResultUnsupportedOperationInPartitionFileA()); + R_UNLESS(!needs_append, fs::ResultUnsupportedWriteForPartitionFile()); /* Appending is prohibited. */ AMS_ASSERT((m_mode & fs::OpenMode_AllowAppend) == 0); @@ -85,7 +85,7 @@ namespace ams::fssystem { virtual Result DoSetSize(s64 size) override final { R_TRY(this->DrySetSize(size, m_mode)); - R_RETURN(fs::ResultUnsupportedOperationInPartitionFileA()); + R_RETURN(fs::ResultUnsupportedWriteForPartitionFile()); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final { @@ -93,12 +93,12 @@ namespace ams::fssystem { switch (op_id) { case fs::OperationId::Invalidate: R_UNLESS((m_mode & fs::OpenMode_Read) != 0, fs::ResultReadNotPermitted()); - R_UNLESS((m_mode & fs::OpenMode_Write) == 0, fs::ResultUnsupportedOperationInPartitionFileB()); + R_UNLESS((m_mode & fs::OpenMode_Write) == 0, fs::ResultUnsupportedOperateRangeForPartitionFile()); break; case fs::OperationId::QueryRange: break; default: - R_THROW(fs::ResultUnsupportedOperationInPartitionFileB()); + R_THROW(fs::ResultUnsupportedOperateRangeForPartitionFile()); } /* Validate offset and size. */ @@ -408,55 +408,55 @@ namespace ams::fssystem { template Result PartitionFileSystemCore::DoCleanDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoCreateDirectory(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoCreateFile(const fs::Path &path, s64 size, int option) { AMS_UNUSED(path, size, option); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoDeleteDirectory(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoDeleteDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoDeleteFile(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem()); } template Result PartitionFileSystemCore::DoCommitProvisionally(s64 counter) { AMS_UNUSED(counter); - R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemB()); + R_THROW(fs::ResultUnsupportedCommitProvisionallyForPartitionFileSystem()); } template class PartitionFileSystemCore; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp index 08d796b23..3cd2e7342 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_read_only_block_cache_storage.hpp @@ -119,12 +119,12 @@ namespace ams::fssystem { virtual Result Write(s64 offset, const void *buffer, size_t size) override { AMS_UNUSED(offset, buffer, size); - return fs::ResultUnsupportedOperationInReadOnlyBlockCacheStorageA(); + return fs::ResultUnsupportedWriteForReadOnlyBlockCacheStorage(); } virtual Result SetSize(s64 size) override { AMS_UNUSED(size); - return fs::ResultUnsupportedOperationInReadOnlyBlockCacheStorageB(); + return fs::ResultUnsupportedSetSizeForReadOnlyBlockCacheStorage(); } }; diff --git a/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp b/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp index 822c2465d..f54ead8d1 100644 --- a/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp +++ b/libraries/libstratosphere/source/fssystem/fssystem_romfs_filesystem.cpp @@ -66,12 +66,12 @@ namespace ams::fssystem { R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, fs::OpenMode_Read)); AMS_ASSERT(needs_append == false); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFile()); } virtual Result DoSetSize(s64 size) override { R_TRY(this->DrySetSize(size, fs::OpenMode_Read)); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFile()); } virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override { @@ -94,7 +94,7 @@ namespace ams::fssystem { R_SUCCEED(); } default: - R_THROW(fs::ResultUnsupportedOperationInRomFsFileB()); + R_THROW(fs::ResultUnsupportedOperateRangeForRomFsFile()); } } public: @@ -303,37 +303,37 @@ namespace ams::fssystem { Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) { AMS_UNUSED(path, size, flags); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) { AMS_UNUSED(old_path, new_path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) { @@ -407,12 +407,12 @@ namespace ams::fssystem { Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) { AMS_UNUSED(path); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); + R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem()); } Result RomFsFileSystem::DoCommitProvisionally(s64 counter) { AMS_UNUSED(counter); - R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemB()); + R_THROW(fs::ResultUnsupportedCommitProvisionallyForRomFsFileSystem()); } } diff --git a/libraries/libvapours/include/vapours/results/fs_results.hpp b/libraries/libvapours/include/vapours/results/fs_results.hpp index 466a8735d..b1f04a4a7 100644 --- a/libraries/libvapours/include/vapours/results/fs_results.hpp +++ b/libraries/libvapours/include/vapours/results/fs_results.hpp @@ -346,56 +346,92 @@ namespace ams::fs { R_DEFINE_ERROR_RESULT(WriteNotPermitted, 6203); R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInSubStorageA, 6302); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInSubStorageB, 6303); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInMemoryStorageA, 6304); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInMemoryStorageB, 6305); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageA, 6306); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageB, 6307); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInSwitchStorageA, 6308); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInStorageServiceObjectAdapterA, 6309); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageA, 6310); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageB, 6311); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageC, 6312); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageExternalA, 6313); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageExternalB, 6314); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageA, 6315); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalIntegrityVerificationStorageA, 6316); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalIntegrityVerificationStorageB, 6317); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageA, 6318); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageB, 6319); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageC, 6320); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageA, 6321); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageB, 6322); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageC, 6323); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageA, 6324); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageB, 6325); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageC, 6326); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInZeroStorageA, 6327); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInZeroStorageB, 6328); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalSha256StorageA, 6329); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyBlockCacheStorageA, 6330); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyBlockCacheStorageB, 6331); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityRomFsStorageA , 6332); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileServiceObjectAdapterA, 6362); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemA, 6364); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemB, 6365); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemC, 6366); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileA, 6367); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileB, 6368); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateA, 6369); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateB, 6370); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateC, 6371); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileA, 6372); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileB, 6373); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemA, 6374); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemB, 6375); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileA, 6376); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileB, 6377); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInLocalFileA, 6378); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInDirectorySaveDataFileSystemA, 6384); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInCompressedStorageA, 6387); - R_DEFINE_ERROR_RESULT(UnsupportedOperationInCompressedStorageB, 6388); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForNotResizableSubStorage, 6302); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForResizableSubStorage, 6303); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForMemoryStorage, 6304); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForMemoryStorage, 6305); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileStorage, 6306); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileHandleStorage, 6307); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForSwitchStorage, 6308); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForStorageServiceObjectAdapter, 6309); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrCounterExtendedStorage, 6310); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrCounterExtendedStorage, 6311); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForAesCtrCounterExtendedStorage, 6312); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrStorageExternal, 6313); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorageExternal, 6314); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorage, 6315); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalIntegrityVerificationStorage, 6316); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage, 6317); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityVerificationStorage, 6318); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForNonSaveDataIntegrityVerificationStorage, 6319); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegrityVerificationStorage, 6320); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForBlockCacheBufferedStorage, 6321); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForNonSaveDataBlockCacheBufferedStorage, 6322); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForBlockCacheBufferedStorage, 6323); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForIndirectStorage, 6324); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIndirectStorage, 6325); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIndirectStorage, 6326); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForZeroStorage, 6327); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroStorage, 6328); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalSha256Storage, 6329); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyBlockCacheStorage, 6330); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForReadOnlyBlockCacheStorage, 6331); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityRomFsStorage, 6332); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForDuplexStorage, 6333); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForDuplexStorage, 6334); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalDuplexStorage, 6335); + R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForRemapStorage, 6336); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForRemapStorage, 6337); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRemapStorage, 6338); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegritySaveDataStorage, 6339); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegritySaveDataStorage, 6340); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalIntegritySaveDataStorage, 6341); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalIntegritySaveDataStorage, 6342); + R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForJournalStorage, 6343); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalStorage, 6344); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalStorage, 6345); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForUnionStorage, 6346); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAllocationTableStorage, 6347); + R_DEFINE_ERROR_RESULT(UnsupportedReadForWriteOnlyGameCardStorage, 6348); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForWriteOnlyGameCardStorage, 6349); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyGameCardStorage, 6350); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForReadOnlyGameCardStorage, 6351); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForReadOnlyGameCardStorage, 6352); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForSdmmcStorage, 6353); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForSdmmcStorage, 6354); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFatFile, 6355); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForStorageFile, 6356); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForInternalStorageConcatenationFile, 6357); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForInternalStorageConcatenationFile, 6358); + R_DEFINE_ERROR_RESULT(UnsupportedQueryEntryForConcatenationFileSystem, 6359); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForConcatenationFile, 6360); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroBitmapFile, 6361); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileServiceObjectAdapter, 6362); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForAesXtsFile, 6363); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForRomFsFileSystem, 6364); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForRomFsFileSystem, 6365); + R_DEFINE_ERROR_RESULT(UnsupportedGetTotalSpaceSizeForRomFsFileSystem, 6366); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForRomFsFile, 6367); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRomFsFile, 6368); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyFileSystem, 6369); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForReadOnlyFileSystem, 6370); + R_DEFINE_ERROR_RESULT(UnsupportedGetTotalSpaceSizeForReadOnlyFileSystem, 6371); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyFile, 6372); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForReadOnlyFile, 6373); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForPartitionFileSystem, 6374); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForPartitionFileSystem, 6375); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForPartitionFile, 6376); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForPartitionFile, 6377); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForTmFileSystemFile, 6378); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForSaveDataInternalStorageFileSystem, 6379); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForApplicationTemporaryFileSystem, 6382); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForSaveDataFileSystem, 6383); + R_DEFINE_ERROR_RESULT(UnsupportedCommitProvisionallyForDirectorySaveDataFileSystem, 6384); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForZeroBitmapHashStorageFile, 6385); + R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroBitmapHashStorageFile, 6386); + R_DEFINE_ERROR_RESULT(UnsupportedWriteForCompressedStorage, 6387); + R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForCompressedStorage, 6388); + R_DEFINE_ERROR_RANGE(PermissionDenied, 6400, 6449); R_DEFINE_ERROR_RESULT(PermissionDeniedForCreateHostFileSystem, 6403); diff --git a/libraries/libvapours/include/vapours/util/util_int_util.hpp b/libraries/libvapours/include/vapours/util/util_int_util.hpp index e958b9e78..7cfed798c 100644 --- a/libraries/libvapours/include/vapours/util/util_int_util.hpp +++ b/libraries/libvapours/include/vapours/util/util_int_util.hpp @@ -69,4 +69,91 @@ namespace ams::util { return ::ams::util::impl::IsIntValueRepresentableImpl(v); } + template + constexpr ALWAYS_INLINE bool CanAddWithoutOverflow(T x, T y) { + if constexpr (std::unsigned_integral) { + return x <= std::numeric_limits::max() - y; + } else { + if (y >= 0) { + return x <= std::numeric_limits::max() - y; + } else { + return x >= std::numeric_limits::min() - y; + } + } + } + + template + constexpr ALWAYS_INLINE bool CanSubtractWithoutOverflow(T x, T y) { + if constexpr (std::unsigned_integral) { + return x >= std::numeric_limits::min() + y; + } else { + if (y >= 0) { + return x >= std::numeric_limits::min() + y; + } else { + return x <= std::numeric_limits::max() + y; + } + } + } + + template + constexpr ALWAYS_INLINE bool CanMultiplyWithoutOverflow(T x, T y) { + if (x == 0 || y == 0) { + return true; + } + + if constexpr (std::unsigned_integral) { + return y <= std::numeric_limits::max() / x; + } else { + if (x > 0) { + if (y > 0) { + return y <= std::numeric_limits::max() / x; + } else /*if (y < 0) */ { + return y >= std::numeric_limits::min() / x; + } + } else /* if (x < 0) */ { + if (y > 0) { + return x >= std::numeric_limits::min() / y; + } else /*if (y < 0) */ { + return y >= std::numeric_limits::max() / x; + } + } + } + } + + template + constexpr inline bool TryAddWithoutOverflow(T *out, T x, T y) { + AMS_ASSERT(out != nullptr); + + if (CanAddWithoutOverflow(x, y)) { + *out = x + y; + return true; + } else { + return false; + } + } + + template + constexpr inline bool TrySubtractWithoutOverflow(T *out, T x, T y) { + AMS_ASSERT(out != nullptr); + + if (CanSubtractWithoutOverflow(x, y)) { + *out = x - y; + return true; + } else { + return false; + } + } + + template + constexpr inline bool TryMultiplyWithoutOverflow(T *out, T x, T y) { + AMS_ASSERT(out != nullptr); + + if (CanMultiplyWithoutOverflow(x, y)) { + *out = x * y; + return true; + } else { + return false; + } + } + }