strat: revise fs unsupported operation results, add overflow utils

This commit is contained in:
Michael Scire 2022-03-13 01:32:34 -08:00
parent 46f2d34f25
commit b7ed9c58bb
31 changed files with 265 additions and 142 deletions

View File

@ -118,7 +118,7 @@ namespace ams::fs {
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
return fs::ResultUnsupportedOperationInSubStorageA(); return fs::ResultUnsupportedSetSizeForNotResizableSubStorage();
} }
}; };

View File

@ -64,7 +64,7 @@ namespace ams::fs {
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); 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 { 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<QueryRangeInfo *>(dst)->Clear(); reinterpret_cast<QueryRangeInfo *>(dst)->Clear();
return ResultSuccess(); return ResultSuccess();
default: default:
return fs::ResultUnsupportedOperationInMemoryStorageB(); return fs::ResultUnsupportedOperateRangeForMemoryStorage();
} }
} }
}; };

View File

@ -52,12 +52,12 @@ namespace ams::fs {
AMS_ASSERT(!need_append); AMS_ASSERT(!need_append);
AMS_UNUSED(buffer); AMS_UNUSED(buffer);
return fs::ResultUnsupportedOperationInReadOnlyFileA(); return fs::ResultUnsupportedWriteForReadOnlyFile();
} }
virtual Result DoSetSize(s64 size) override final { virtual Result DoSetSize(s64 size) override final {
R_TRY(this->DrySetSize(size, fs::OpenMode_Read)); 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 { 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: case OperationId::QueryRange:
return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
default: default:
return fs::ResultUnsupportedOperationInReadOnlyFileB(); return fs::ResultUnsupportedOperateRangeForReadOnlyFile();
} }
} }
public: public:
@ -115,57 +115,57 @@ namespace ams::fs {
virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final { virtual Result DoCreateFile(const fs::Path &path, s64 size, int flags) override final {
AMS_UNUSED(path, size, flags); AMS_UNUSED(path, size, flags);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoDeleteFile(const fs::Path &path) override final { virtual Result DoDeleteFile(const fs::Path &path) override final {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoCreateDirectory(const fs::Path &path) override final { virtual Result DoCreateDirectory(const fs::Path &path) override final {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoDeleteDirectory(const fs::Path &path) override final { virtual Result DoDeleteDirectory(const fs::Path &path) override final {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final { virtual Result DoDeleteDirectoryRecursively(const fs::Path &path) override final {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final { virtual Result DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) override final {
AMS_UNUSED(old_path, new_path); 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 { virtual Result DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) override final {
AMS_UNUSED(old_path, new_path); AMS_UNUSED(old_path, new_path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final { virtual Result DoCleanDirectoryRecursively(const fs::Path &path) override final {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateA(); return fs::ResultUnsupportedWriteForReadOnlyFileSystem();
} }
virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final { virtual Result DoGetFreeSpaceSize(s64 *out, const fs::Path &path) override final {
AMS_UNUSED(out, path); AMS_UNUSED(out, path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB(); return fs::ResultUnsupportedCommitProvisionallyForReadOnlyFileSystem();
} }
virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final { virtual Result DoGetTotalSpaceSize(s64 *out, const fs::Path &path) override final {
AMS_UNUSED(out, path); AMS_UNUSED(out, path);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateB(); return fs::ResultUnsupportedCommitProvisionallyForReadOnlyFileSystem();
} }
virtual Result DoCommitProvisionally(s64 counter) override final { virtual Result DoCommitProvisionally(s64 counter) override final {
AMS_UNUSED(counter); AMS_UNUSED(counter);
return fs::ResultUnsupportedOperationInReadOnlyFileSystemTemplateC(); return fs::ResultUnsupportedGetTotalSpaceSizeForReadOnlyFileSystem();
} }
}; };

View File

@ -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 { 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); 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()); 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)); return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst));

View File

@ -107,13 +107,13 @@ namespace ams::fs {
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
/* Ensure we're initialized and validate arguments. */ /* Ensure we're initialized and validate arguments. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); 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()); R_UNLESS(IStorage::CheckOffsetAndSize(m_offset, size), fs::ResultInvalidSize());
/* Ensure that we're allowed to set size. */ /* Ensure that we're allowed to set size. */
s64 cur_size; s64 cur_size;
R_TRY(m_base_storage->GetSize(std::addressof(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. */ /* Set the size. */
R_TRY(m_base_storage->SetSize(m_offset + 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 { 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. */ /* Ensure we're initialized. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
/* Succeed immediately on zero-sized operation. */ /* Succeed immediately on zero-sized operation. */
R_SUCCEED_IF(size == 0); R_SUCCEED_IF(size == 0);

View File

@ -109,12 +109,12 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageA()); R_THROW(fs::ResultUnsupportedWriteForAesCtrCounterExtendedStorage());
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageB()); R_THROW(fs::ResultUnsupportedSetSizeForAesCtrCounterExtendedStorage());
} }
private: private:
Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, fs::SubStorage data_storage, fs::SubStorage table_storage); Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, fs::SubStorage data_storage, fs::SubStorage table_storage);

View File

@ -110,7 +110,7 @@ namespace ams::fssystem {
virtual Result Read(s64 offset, void *buffer, size_t size) override; 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 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 GetSize(s64 *out) override;
virtual Result Flush() override; virtual Result Flush() override;

View File

@ -1424,7 +1424,7 @@ namespace ams::fssystem {
R_TRY(m_core.QueryRange(dst, dst_size, offset, size)); R_TRY(m_core.QueryRange(dst, dst_size, offset, size));
break; break;
default: default:
R_THROW(fs::ResultUnsupportedOperationInCompressedStorageB()); R_THROW(fs::ResultUnsupportedOperateRangeForCompressedStorage());
} }
R_SUCCEED(); R_SUCCEED();
@ -1440,13 +1440,13 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedOperationInCompressedStorageA()); R_THROW(fs::ResultUnsupportedWriteForCompressedStorage());
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
/* NOTE: Is Nintendo returning the wrong result here? */ /* NOTE: Is Nintendo returning the wrong result here? */
R_THROW(fs::ResultUnsupportedOperationInIndirectStorageB()); R_THROW(fs::ResultUnsupportedSetSizeForIndirectStorage());
} }
}; };

View File

@ -162,7 +162,7 @@ namespace ams::fssystem {
virtual Result Read(s64 offset, void *buffer, size_t size) override; 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 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 GetSize(s64 *out) override;
virtual Result Flush() override; virtual Result Flush() override;

View File

@ -147,12 +147,12 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedOperationInIndirectStorageA()); R_THROW(fs::ResultUnsupportedWriteForIndirectStorage());
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedOperationInIndirectStorageB()); R_THROW(fs::ResultUnsupportedSetSizeForIndirectStorage());
} }
protected: protected:
BucketTree &GetEntryTable() { return m_table; } BucketTree &GetEntryTable() { return m_table; }

View File

@ -48,7 +48,7 @@ namespace ams::fssystem {
return m_integrity_storage.Write(offset, buffer, size); 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 { virtual Result GetSize(s64 *out) override {
return m_integrity_storage.GetSize(out); return m_integrity_storage.GetSize(out);

View File

@ -55,7 +55,7 @@ namespace ams::fssystem {
virtual Result Read(s64 offset, void *buffer, size_t size) override; 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 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 GetSize(s64 *out) override;
virtual Result Flush() override; virtual Result Flush() override;

View File

@ -56,12 +56,12 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
R_THROW(fs::ResultUnsupportedOperationInZeroStorageA()); R_THROW(fs::ResultUnsupportedWriteForZeroStorage());
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
R_THROW(fs::ResultUnsupportedOperationInZeroStorageB()); R_THROW(fs::ResultUnsupportedSetSizeForZeroStorage());
} }
}; };
private: private:

View File

@ -86,7 +86,7 @@ namespace ams::fs {
R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange()); R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange());
return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size); return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
default: default:
return fs::ResultUnsupportedOperationInFileStorageA(); return fs::ResultUnsupportedOperateRangeForFileStorage();
} }
} }
@ -171,7 +171,7 @@ namespace ams::fs {
return QueryRange(static_cast<QueryRangeInfo *>(dst), m_handle, offset, size); return QueryRange(static_cast<QueryRangeInfo *>(dst), m_handle, offset, size);
default: default:
return fs::ResultUnsupportedOperationInFileStorageB(); return fs::ResultUnsupportedOperateRangeForFileHandleStorage();
} }
} }

View File

@ -221,12 +221,12 @@ namespace ams::fs {
virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override { virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override {
AMS_UNUSED(offset, buffer, size, option); AMS_UNUSED(offset, buffer, size, option);
return fs::ResultUnsupportedOperationInRomFsFileA(); return fs::ResultUnsupportedWriteForRomFsFile();
} }
virtual Result DoSetSize(s64 size) override { virtual Result DoSetSize(s64 size) override {
AMS_UNUSED(size); 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 { 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); return this->GetStorage()->OperateRange(dst, dst_size, op_id, m_start + offset, operate_size, src, src_size);
} }
default: default:
return fs::ResultUnsupportedOperationInRomFsFileB(); return fs::ResultUnsupportedOperateRangeForRomFsFile();
} }
} }
public: public:
@ -447,37 +447,37 @@ namespace ams::fs {
Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) { Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) {
AMS_UNUSED(path, size, flags); AMS_UNUSED(path, size, flags);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) { Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) { Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) { Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) { Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) { Result RomFsFileSystem::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_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) { Result RomFsFileSystem::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_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) { 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) { Result RomFsFileSystem::DoGetTotalSpaceSize(s64 *out, const fs::Path &path) {
AMS_UNUSED(out, path); AMS_UNUSED(out, path);
return fs::ResultUnsupportedOperationInRomFsFileSystemC(); return fs::ResultUnsupportedGetTotalSpaceSizeForRomFsFileSystem();
} }
Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) { Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
return fs::ResultUnsupportedOperationInRomFsFileSystemA(); return fs::ResultUnsupportedWriteForRomFsFileSystem();
} }
Result RomFsFileSystem::DoCommitProvisionally(s64 counter) { Result RomFsFileSystem::DoCommitProvisionally(s64 counter) {
AMS_UNUSED(counter); AMS_UNUSED(counter);
return fs::ResultUnsupportedOperationInRomFsFileSystemB(); return fs::ResultUnsupportedCommitProvisionallyForRomFsFileSystem();
} }
Result RomFsFileSystem::DoRollback() { Result RomFsFileSystem::DoRollback() {

View File

@ -64,7 +64,7 @@ namespace ams::fs::impl {
} }
default: default:
{ {
R_THROW(fs::ResultUnsupportedOperationInStorageServiceObjectAdapterA()); R_THROW(fs::ResultUnsupportedOperateRangeForStorageServiceObjectAdapter());
} }
} }
} }

View File

@ -245,7 +245,7 @@ namespace ams::fssystem {
return ResultSuccess(); return ResultSuccess();
} }
default: default:
return fs::ResultUnsupportedOperationInAesCtrCounterExtendedStorageC(); return fs::ResultUnsupportedOperateRangeForAesCtrCounterExtendedStorage();
} }
} }

View File

@ -135,7 +135,7 @@ namespace ams::fssystem {
template<typename BasePointer> template<typename BasePointer>
Result AesCtrStorage<BasePointer>::SetSize(s64 size) { Result AesCtrStorage<BasePointer>::SetSize(s64 size) {
AMS_UNUSED(size); AMS_UNUSED(size);
return fs::ResultUnsupportedOperationInAesCtrStorageA(); return fs::ResultUnsupportedSetSizeForAesCtrStorage();
} }
template<typename BasePointer> template<typename BasePointer>

View File

@ -395,7 +395,7 @@ namespace ams::fssystem {
} }
case fs::OperationId::Invalidate: 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_TRY(this->InvalidateImpl());
R_SUCCEED(); R_SUCCEED();
} }
@ -405,7 +405,7 @@ namespace ams::fssystem {
R_SUCCEED(); R_SUCCEED();
} }
default: default:
R_THROW(fs::ResultUnsupportedOperationInBlockCacheBufferedStorageC()); R_THROW(fs::ResultUnsupportedOperateRangeForBlockCacheBufferedStorage());
} }
} }

View File

@ -348,7 +348,7 @@ namespace ams::fssystem {
Result DirectorySaveDataFileSystem::DoCommitProvisionally(s64 counter) { Result DirectorySaveDataFileSystem::DoCommitProvisionally(s64 counter) {
/* Check that we support multi-commit. */ /* 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. */ /* Do nothing. */
AMS_UNUSED(counter); AMS_UNUSED(counter);

View File

@ -330,7 +330,7 @@ namespace ams::fssystem {
return ResultSuccess(); return ResultSuccess();
} }
default: default:
return fs::ResultUnsupportedOperationInHierarchicalIntegrityVerificationStorageB(); return fs::ResultUnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage();
} }
} }

View File

@ -53,7 +53,7 @@ namespace ams::fssystem {
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
return fs::ResultUnsupportedOperationInHierarchicalSha256StorageA(); return fs::ResultUnsupportedSetSizeForHierarchicalSha256Storage();
} }
}; };

View File

@ -171,7 +171,7 @@ namespace ams::fssystem {
R_SUCCEED(); R_SUCCEED();
} }
default: default:
return fs::ResultUnsupportedOperationInIndirectStorageC(); return fs::ResultUnsupportedOperateRangeForIndirectStorage();
} }
R_SUCCEED(); R_SUCCEED();

View File

@ -332,7 +332,7 @@ namespace ams::fssystem {
case fs::OperationId::Invalidate: case fs::OperationId::Invalidate:
{ {
/* Only allow cache invalidation for RomFs. */ /* 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. */ /* Operate on our storages. */
@ -357,7 +357,7 @@ namespace ams::fssystem {
return ResultSuccess(); return ResultSuccess();
} }
default: default:
return fs::ResultUnsupportedOperationInIntegrityVerificationStorageC(); return fs::ResultUnsupportedOperateRangeForIntegrityVerificationStorage();
} }
} }

View File

@ -303,7 +303,7 @@ namespace ams::fssystem {
static_cast<fs::QueryRangeInfo *>(dst)->Clear(); static_cast<fs::QueryRangeInfo *>(dst)->Clear();
R_SUCCEED(); R_SUCCEED();
default: default:
R_THROW(fs::ResultUnsupportedOperationInLocalFileA()); R_THROW(fs::ResultUnsupportedOperateRangeForTmFileSystemFile());
} }
} }
public: public:
@ -619,7 +619,7 @@ namespace ams::fssystem {
static_cast<fs::QueryRangeInfo *>(dst)->Clear(); static_cast<fs::QueryRangeInfo *>(dst)->Clear();
R_SUCCEED(); R_SUCCEED();
default: default:
R_THROW(fs::ResultUnsupportedOperationInLocalFileA()); R_THROW(fs::ResultUnsupportedOperateRangeForTmFileSystemFile());
} }
} }
public: public:

View File

@ -212,12 +212,12 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
return fs::ResultUnsupportedOperationInAesCtrStorageExternalA(); return fs::ResultUnsupportedWriteForAesCtrStorageExternal();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
return fs::ResultUnsupportedOperationInAesCtrStorageExternalB(); return fs::ResultUnsupportedSetSizeForAesCtrStorageExternal();
} }
}; };
@ -254,7 +254,7 @@ namespace ams::fssystem {
return ResultSuccess(); return ResultSuccess();
} }
default: default:
return fs::ResultUnsupportedOperationInSwitchStorageA(); return fs::ResultUnsupportedOperateRangeForSwitchStorage();
} }
} }

View File

@ -70,7 +70,7 @@ namespace ams::fssystem {
/* Ensure appending is not required. */ /* Ensure appending is not required. */
bool needs_append; bool needs_append;
R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, m_mode)); 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. */ /* Appending is prohibited. */
AMS_ASSERT((m_mode & fs::OpenMode_AllowAppend) == 0); AMS_ASSERT((m_mode & fs::OpenMode_AllowAppend) == 0);
@ -85,7 +85,7 @@ namespace ams::fssystem {
virtual Result DoSetSize(s64 size) override final { virtual Result DoSetSize(s64 size) override final {
R_TRY(this->DrySetSize(size, m_mode)); 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 { 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) { switch (op_id) {
case fs::OperationId::Invalidate: case fs::OperationId::Invalidate:
R_UNLESS((m_mode & fs::OpenMode_Read) != 0, fs::ResultReadNotPermitted()); 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; break;
case fs::OperationId::QueryRange: case fs::OperationId::QueryRange:
break; break;
default: default:
R_THROW(fs::ResultUnsupportedOperationInPartitionFileB()); R_THROW(fs::ResultUnsupportedOperateRangeForPartitionFile());
} }
/* Validate offset and size. */ /* Validate offset and size. */
@ -408,55 +408,55 @@ namespace ams::fssystem {
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCleanDirectoryRecursively(const fs::Path &path) { Result PartitionFileSystemCore<MetaType>::DoCleanDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCreateDirectory(const fs::Path &path) { Result PartitionFileSystemCore<MetaType>::DoCreateDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCreateFile(const fs::Path &path, s64 size, int option) { Result PartitionFileSystemCore<MetaType>::DoCreateFile(const fs::Path &path, s64 size, int option) {
AMS_UNUSED(path, size, option); AMS_UNUSED(path, size, option);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteDirectory(const fs::Path &path) { Result PartitionFileSystemCore<MetaType>::DoDeleteDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteDirectoryRecursively(const fs::Path &path) { Result PartitionFileSystemCore<MetaType>::DoDeleteDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteFile(const fs::Path &path) { Result PartitionFileSystemCore<MetaType>::DoDeleteFile(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) { Result PartitionFileSystemCore<MetaType>::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_path, new_path); AMS_UNUSED(old_path, new_path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) { Result PartitionFileSystemCore<MetaType>::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_path, new_path); AMS_UNUSED(old_path, new_path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
} }
template <typename MetaType> template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCommitProvisionally(s64 counter) { Result PartitionFileSystemCore<MetaType>::DoCommitProvisionally(s64 counter) {
AMS_UNUSED(counter); AMS_UNUSED(counter);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemB()); R_THROW(fs::ResultUnsupportedCommitProvisionallyForPartitionFileSystem());
} }
template class PartitionFileSystemCore<PartitionFileSystemMeta>; template class PartitionFileSystemCore<PartitionFileSystemMeta>;

View File

@ -119,12 +119,12 @@ namespace ams::fssystem {
virtual Result Write(s64 offset, const void *buffer, size_t size) override { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
AMS_UNUSED(offset, buffer, size); AMS_UNUSED(offset, buffer, size);
return fs::ResultUnsupportedOperationInReadOnlyBlockCacheStorageA(); return fs::ResultUnsupportedWriteForReadOnlyBlockCacheStorage();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
AMS_UNUSED(size); AMS_UNUSED(size);
return fs::ResultUnsupportedOperationInReadOnlyBlockCacheStorageB(); return fs::ResultUnsupportedSetSizeForReadOnlyBlockCacheStorage();
} }
}; };

View File

@ -66,12 +66,12 @@ namespace ams::fssystem {
R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, fs::OpenMode_Read)); R_TRY(this->DryWrite(std::addressof(needs_append), offset, size, option, fs::OpenMode_Read));
AMS_ASSERT(needs_append == false); AMS_ASSERT(needs_append == false);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFile());
} }
virtual Result DoSetSize(s64 size) override { virtual Result DoSetSize(s64 size) override {
R_TRY(this->DrySetSize(size, fs::OpenMode_Read)); 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 { 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(); R_SUCCEED();
} }
default: default:
R_THROW(fs::ResultUnsupportedOperationInRomFsFileB()); R_THROW(fs::ResultUnsupportedOperateRangeForRomFsFile());
} }
} }
public: public:
@ -303,37 +303,37 @@ namespace ams::fssystem {
Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) { Result RomFsFileSystem::DoCreateFile(const fs::Path &path, s64 size, int flags) {
AMS_UNUSED(path, size, flags); AMS_UNUSED(path, size, flags);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem());
} }
Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) { Result RomFsFileSystem::DoDeleteFile(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem());
} }
Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) { Result RomFsFileSystem::DoCreateDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem());
} }
Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) { Result RomFsFileSystem::DoDeleteDirectory(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem());
} }
Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) { Result RomFsFileSystem::DoDeleteDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(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) { Result RomFsFileSystem::DoRenameFile(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_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) { Result RomFsFileSystem::DoRenameDirectory(const fs::Path &old_path, const fs::Path &new_path) {
AMS_UNUSED(old_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) { Result RomFsFileSystem::DoGetEntryType(fs::DirectoryEntryType *out, const fs::Path &path) {
@ -407,12 +407,12 @@ namespace ams::fssystem {
Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) { Result RomFsFileSystem::DoCleanDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path); AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemA()); R_THROW(fs::ResultUnsupportedWriteForRomFsFileSystem());
} }
Result RomFsFileSystem::DoCommitProvisionally(s64 counter) { Result RomFsFileSystem::DoCommitProvisionally(s64 counter) {
AMS_UNUSED(counter); AMS_UNUSED(counter);
R_THROW(fs::ResultUnsupportedOperationInRomFsFileSystemB()); R_THROW(fs::ResultUnsupportedCommitProvisionallyForRomFsFileSystem());
} }
} }

View File

@ -346,56 +346,92 @@ namespace ams::fs {
R_DEFINE_ERROR_RESULT(WriteNotPermitted, 6203); R_DEFINE_ERROR_RESULT(WriteNotPermitted, 6203);
R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399); R_DEFINE_ERROR_RANGE(UnsupportedOperation, 6300, 6399);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInSubStorageA, 6302); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForNotResizableSubStorage, 6302);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInSubStorageB, 6303); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForResizableSubStorage, 6303);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInMemoryStorageA, 6304); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForMemoryStorage, 6304);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInMemoryStorageB, 6305); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForMemoryStorage, 6305);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageA, 6306); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileStorage, 6306);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileStorageB, 6307); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForFileHandleStorage, 6307);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInSwitchStorageA, 6308); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForSwitchStorage, 6308);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInStorageServiceObjectAdapterA, 6309); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForStorageServiceObjectAdapter, 6309);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageA, 6310); R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrCounterExtendedStorage, 6310);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageB, 6311); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrCounterExtendedStorage, 6311);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrCounterExtendedStorageC, 6312); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForAesCtrCounterExtendedStorage, 6312);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageExternalA, 6313); R_DEFINE_ERROR_RESULT(UnsupportedWriteForAesCtrStorageExternal, 6313);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageExternalB, 6314); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorageExternal, 6314);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInAesCtrStorageA, 6315); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAesCtrStorage, 6315);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalIntegrityVerificationStorageA, 6316); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalIntegrityVerificationStorage, 6316);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalIntegrityVerificationStorageB, 6317); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForHierarchicalIntegrityVerificationStorage, 6317);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageA, 6318); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityVerificationStorage, 6318);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageB, 6319); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForNonSaveDataIntegrityVerificationStorage, 6319);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityVerificationStorageC, 6320); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegrityVerificationStorage, 6320);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageA, 6321); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForBlockCacheBufferedStorage, 6321);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageB, 6322); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForNonSaveDataBlockCacheBufferedStorage, 6322);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInBlockCacheBufferedStorageC, 6323); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForBlockCacheBufferedStorage, 6323);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageA, 6324); R_DEFINE_ERROR_RESULT(UnsupportedWriteForIndirectStorage, 6324);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageB, 6325); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIndirectStorage, 6325);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIndirectStorageC, 6326); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIndirectStorage, 6326);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInZeroStorageA, 6327); R_DEFINE_ERROR_RESULT(UnsupportedWriteForZeroStorage, 6327);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInZeroStorageB, 6328); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForZeroStorage, 6328);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInHierarchicalSha256StorageA, 6329); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalSha256Storage, 6329);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyBlockCacheStorageA, 6330); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyBlockCacheStorage, 6330);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyBlockCacheStorageB, 6331); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForReadOnlyBlockCacheStorage, 6331);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInIntegrityRomFsStorageA , 6332); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegrityRomFsStorage, 6332);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInFileServiceObjectAdapterA, 6362); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForDuplexStorage, 6333);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemA, 6364); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForDuplexStorage, 6334);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemB, 6365); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForHierarchicalDuplexStorage, 6335);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileSystemC, 6366); R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForRemapStorage, 6336);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileA, 6367); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForRemapStorage, 6337);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInRomFsFileB, 6368); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForRemapStorage, 6338);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateA, 6369); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForIntegritySaveDataStorage, 6339);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateB, 6370); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForIntegritySaveDataStorage, 6340);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileSystemTemplateC, 6371); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalIntegritySaveDataStorage, 6341);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileA, 6372); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalIntegritySaveDataStorage, 6342);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInReadOnlyFileB, 6373); R_DEFINE_ERROR_RESULT(UnsupportedGetSizeForJournalStorage, 6343);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemA, 6374); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForJournalStorage, 6344);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileSystemB, 6375); R_DEFINE_ERROR_RESULT(UnsupportedOperateRangeForJournalStorage, 6345);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileA, 6376); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForUnionStorage, 6346);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInPartitionFileB, 6377); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForAllocationTableStorage, 6347);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInLocalFileA, 6378); R_DEFINE_ERROR_RESULT(UnsupportedReadForWriteOnlyGameCardStorage, 6348);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInDirectorySaveDataFileSystemA, 6384); R_DEFINE_ERROR_RESULT(UnsupportedSetSizeForWriteOnlyGameCardStorage, 6349);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInCompressedStorageA, 6387); R_DEFINE_ERROR_RESULT(UnsupportedWriteForReadOnlyGameCardStorage, 6350);
R_DEFINE_ERROR_RESULT(UnsupportedOperationInCompressedStorageB, 6388); 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_RANGE(PermissionDenied, 6400, 6449);
R_DEFINE_ERROR_RESULT(PermissionDeniedForCreateHostFileSystem, 6403); R_DEFINE_ERROR_RESULT(PermissionDeniedForCreateHostFileSystem, 6403);

View File

@ -69,4 +69,91 @@ namespace ams::util {
return ::ams::util::impl::IsIntValueRepresentableImpl<To, From>(v); return ::ams::util::impl::IsIntValueRepresentableImpl<To, From>(v);
} }
template<std::integral T>
constexpr ALWAYS_INLINE bool CanAddWithoutOverflow(T x, T y) {
if constexpr (std::unsigned_integral<T>) {
return x <= std::numeric_limits<T>::max() - y;
} else {
if (y >= 0) {
return x <= std::numeric_limits<T>::max() - y;
} else {
return x >= std::numeric_limits<T>::min() - y;
}
}
}
template<std::integral T>
constexpr ALWAYS_INLINE bool CanSubtractWithoutOverflow(T x, T y) {
if constexpr (std::unsigned_integral<T>) {
return x >= std::numeric_limits<T>::min() + y;
} else {
if (y >= 0) {
return x >= std::numeric_limits<T>::min() + y;
} else {
return x <= std::numeric_limits<T>::max() + y;
}
}
}
template<std::integral T>
constexpr ALWAYS_INLINE bool CanMultiplyWithoutOverflow(T x, T y) {
if (x == 0 || y == 0) {
return true;
}
if constexpr (std::unsigned_integral<T>) {
return y <= std::numeric_limits<T>::max() / x;
} else {
if (x > 0) {
if (y > 0) {
return y <= std::numeric_limits<T>::max() / x;
} else /*if (y < 0) */ {
return y >= std::numeric_limits<T>::min() / x;
}
} else /* if (x < 0) */ {
if (y > 0) {
return x >= std::numeric_limits<T>::min() / y;
} else /*if (y < 0) */ {
return y >= std::numeric_limits<T>::max() / x;
}
}
}
}
template<std::integral T>
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<std::integral T>
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<std::integral T>
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;
}
}
} }