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

@@ -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<QueryRangeInfo *>(dst), m_handle, offset, size);
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 {
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() {

View File

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

View File

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

View File

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

View File

@@ -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());
}
}

View File

@@ -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);

View File

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

View File

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

View File

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

View File

@@ -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();
}
}

View File

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

View File

@@ -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();
}
}

View File

@@ -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 <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCleanDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCreateDirectory(const fs::Path &path) {
AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCreateFile(const fs::Path &path, s64 size, int option) {
AMS_UNUSED(path, size, option);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteDirectory(const fs::Path &path) {
AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteDirectoryRecursively(const fs::Path &path) {
AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoDeleteFile(const fs::Path &path) {
AMS_UNUSED(path);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemA());
R_THROW(fs::ResultUnsupportedWriteForPartitionFileSystem());
}
template <typename MetaType>
Result PartitionFileSystemCore<MetaType>::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 <typename MetaType>
Result PartitionFileSystemCore<MetaType>::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 <typename MetaType>
Result PartitionFileSystemCore<MetaType>::DoCommitProvisionally(s64 counter) {
AMS_UNUSED(counter);
R_THROW(fs::ResultUnsupportedOperationInPartitionFileSystemB());
R_THROW(fs::ResultUnsupportedCommitProvisionallyForPartitionFileSystem());
}
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 {
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();
}
};

View File

@@ -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());
}
}