fs: revise allocation-fail result names

This commit is contained in:
Michael Scire 2022-03-13 01:51:42 -08:00 committed by SciresM
parent 11e4bed199
commit e13b81aa9e
50 changed files with 304 additions and 218 deletions

View file

@ -139,7 +139,7 @@ namespace ams::fssystem {
} else {
m_internal_free_lists.reset(new PageList[m_order_max + 1]);
m_free_lists = m_internal_free_lists.get();
R_UNLESS(m_free_lists != nullptr, fs::ResultAllocationFailureInFileSystemBuddyHeapA());
R_UNLESS(m_free_lists != nullptr, fs::ResultAllocationMemoryFailedInFileSystemBuddyHeapA());
}
/* All but the last page region should go to the max order. */

View file

@ -29,7 +29,7 @@ namespace ams::fssystem {
}
/* We need to have at least one entry buffer. */
R_UNLESS(m_internal_entry_buffer != nullptr || m_external_entry_buffer != nullptr, fs::ResultAllocationFailureInFileSystemBufferManagerA());
R_UNLESS(m_internal_entry_buffer != nullptr || m_external_entry_buffer != nullptr, fs::ResultAllocationMemoryFailedInFileSystemBufferManagerA());
/* Set entries. */
m_entries = reinterpret_cast<Entry *>(m_external_entry_buffer != nullptr ? m_external_entry_buffer : m_internal_entry_buffer.get());

View file

@ -46,14 +46,14 @@ namespace ams::fssystem {
Result AesCtrCounterExtendedStorage::CreateExternalDecryptor(std::unique_ptr<IDecryptor> *out, DecryptFunction func, s32 key_index) {
std::unique_ptr<IDecryptor> decryptor = std::make_unique<ExternalDecryptor>(func, key_index);
R_UNLESS(decryptor != nullptr, fs::ResultAllocationFailureInAesCtrCounterExtendedStorageA());
R_UNLESS(decryptor != nullptr, fs::ResultAllocationMemoryFailedInAesCtrCounterExtendedStorageA());
*out = std::move(decryptor);
return ResultSuccess();
}
Result AesCtrCounterExtendedStorage::CreateSoftwareDecryptor(std::unique_ptr<IDecryptor> *out) {
std::unique_ptr<IDecryptor> decryptor = std::make_unique<SoftwareDecryptor>();
R_UNLESS(decryptor != nullptr, fs::ResultAllocationFailureInAesCtrCounterExtendedStorageA());
R_UNLESS(decryptor != nullptr, fs::ResultAllocationMemoryFailedInAesCtrCounterExtendedStorageA());
*out = std::move(decryptor);
return ResultSuccess();
}

View file

@ -149,7 +149,7 @@ namespace ams::fssystem {
do {
/* Do the bulk read. If we fail due to pooled buffer allocation failing, fall back to the normal read codepath. */
R_TRY_CATCH(this->BulkRead(read_offset, dst, read_size, std::addressof(head_range), std::addressof(tail_range), std::addressof(head_entry), std::addressof(tail_entry), head_cache_needed, tail_cache_needed)) {
R_CATCH(fs::ResultAllocationFailurePooledBufferNotEnoughSize) { break; }
R_CATCH(fs::ResultAllocationPooledBufferNotEnoughSize) { break; }
} R_END_TRY_CATCH;
/* Se successfully did a bulk read, so we're done. */
@ -463,7 +463,7 @@ namespace ams::fssystem {
if (start_offset < offset || offset + size < end_offset) {
/* Allocate a work buffer. */
std::unique_ptr<char[], fs::impl::Deleter> work = fs::impl::MakeUnique<char[]>(m_verification_block_size);
R_UNLESS(work != nullptr, fs::ResultAllocationFailureInBlockCacheBufferedStorageB());
R_UNLESS(work != nullptr, fs::ResultAllocationMemoryFailedInBlockCacheBufferedStorageB());
/* Handle data before the aligned range. */
if (start_offset < offset) {
@ -1005,7 +1005,7 @@ namespace ams::fssystem {
read_buffer = reinterpret_cast<char *>(range_head->first);
} else {
pooled_buffer.AllocateParticularlyLarge(buffer_size, 1);
R_UNLESS(pooled_buffer.GetSize() >= buffer_size, fs::ResultAllocationFailurePooledBufferNotEnoughSize());
R_UNLESS(pooled_buffer.GetSize() >= buffer_size, fs::ResultAllocationPooledBufferNotEnoughSize());
read_buffer = pooled_buffer.GetBuffer();
}

View file

@ -608,7 +608,7 @@ namespace ams::fssystem {
/* Allocate the caches. */
m_caches.reset(new Cache[buffer_count]);
R_UNLESS(m_caches != nullptr, fs::ResultAllocationFailureInBufferedStorageA());
R_UNLESS(m_caches != nullptr, fs::ResultAllocationMemoryFailedInBufferedStorageA());
/* Initialize the caches. */
for (auto i = 0; i < buffer_count; i++) {
@ -793,7 +793,7 @@ namespace ams::fssystem {
do {
/* Try to do a bulk read. */
R_TRY_CATCH(this->BulkRead(cur_offset, static_cast<u8 *>(buffer) + buf_offset, remaining_size, head_cache_needed, tail_cache_needed)) {
R_CATCH(fs::ResultAllocationFailurePooledBufferNotEnoughSize) {
R_CATCH(fs::ResultAllocationPooledBufferNotEnoughSize) {
/* If the read fails due to insufficient pooled buffer size, */
/* then we want to fall back to the normal read path. */
break;
@ -940,7 +940,7 @@ namespace ams::fssystem {
work_buffer = static_cast<char *>(buffer);
} else {
pooled_buffer.AllocateParticularlyLarge(static_cast<size_t>(aligned_size), 1);
R_UNLESS(static_cast<s64>(pooled_buffer.GetSize()) >= aligned_size, fs::ResultAllocationFailurePooledBufferNotEnoughSize());
R_UNLESS(static_cast<s64>(pooled_buffer.GetSize()) >= aligned_size, fs::ResultAllocationPooledBufferNotEnoughSize());
work_buffer = pooled_buffer.GetBuffer();
}

View file

@ -271,7 +271,7 @@ namespace ams::fssystem {
/* Make DirectorySaveDataFile. */
std::unique_ptr<fs::fsa::IFile> file = std::make_unique<DirectorySaveDataFile>(std::move(base_file), this, mode);
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInDirectorySaveDataFileSystem());
R_UNLESS(file != nullptr, fs::ResultAllocationMemoryFailedInDirectorySaveDataFileSystemA());
/* Increment our open writable files, if the file is writable. */
if (mode & fs::OpenMode_Write) {

View file

@ -24,7 +24,7 @@ namespace ams::fssystem {
/* Set master hash. */
m_master_hash = master_hash;
m_master_hash_storage = std::make_unique<fs::MemoryStorage>(std::addressof(m_master_hash), sizeof(Hash));
R_UNLESS(m_master_hash_storage != nullptr, fs::ResultAllocationFailureInIntegrityRomFsStorageA());
R_UNLESS(m_master_hash_storage != nullptr, fs::ResultAllocationMemoryFailedInIntegrityRomFsStorageA());
/* Set the master hash storage. */
storage_info[0] = fs::SubStorage(m_master_hash_storage.get(), 0, sizeof(Hash));

View file

@ -283,7 +283,7 @@ namespace ams::fssystem {
/* Allocate a work buffer. */
const auto buf_size = static_cast<size_t>(std::min(sign_size, static_cast<s64>(1) << (m_upper_layer_verification_block_order + 2)));
std::unique_ptr<char[], fs::impl::Deleter> buf = fs::impl::MakeUnique<char[]>(buf_size);
R_UNLESS(buf != nullptr, fs::ResultAllocationFailureInIntegrityVerificationStorageA());
R_UNLESS(buf != nullptr, fs::ResultAllocationMemoryFailedInIntegrityVerificationStorageA());
/* Clear the work buffer. */
std::memset(buf.get(), 0, buf_size);
@ -315,7 +315,7 @@ namespace ams::fssystem {
/* Allocate a work buffer. */
std::unique_ptr<char[], fs::impl::Deleter> buf = fs::impl::MakeUnique<char[]>(sign_size);
R_UNLESS(buf != nullptr, fs::ResultAllocationFailureInIntegrityVerificationStorageB());
R_UNLESS(buf != nullptr, fs::ResultAllocationMemoryFailedInIntegrityVerificationStorageB());
/* Read the existing signature. */
R_TRY(m_hash_storage.Read(sign_offset, buf.get(), sign_size));

View file

@ -88,7 +88,7 @@ namespace ams::fssystem {
for (auto it = list->begin(); it != list->end(); ++it) {
if (it->Contains(key, key_size, key2)) {
std::unique_ptr accessor = std::make_unique<KeySlotCacheAccessor>(it->GetKeySlotIndex(), std::move(lk));
R_UNLESS(accessor != nullptr, fs::ResultAllocationFailure());
R_UNLESS(accessor != nullptr, fs::ResultAllocationMemoryFailed());
*out = std::move(accessor);

View file

@ -880,7 +880,7 @@ namespace ams::fssystem {
/* Allocate our native path buffer. */
native_path = fs::impl::MakeUnique<NativeCharacterType[]>(native_len + 1);
R_UNLESS(native_path != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(native_path != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Convert path. */
const auto res = ::MultiByteToWideChar(CP_UTF8, 0, m_root_path.GetString(), -1, native_path.get(), native_len);
@ -901,7 +901,7 @@ namespace ams::fssystem {
/* Tentatively assume other operating systems do the sane thing and use utf-8 strings. */
native_path = fs::impl::MakeUnique<NativeCharacterType[]>(native_len + 1);
R_UNLESS(native_path != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(native_path != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Copy in path. */
std::memcpy(native_path.get(), m_root_path.GetString(), native_len + 1);
@ -972,7 +972,7 @@ namespace ams::fssystem {
/* Allocate our native path buffer. */
native_path = fs::impl::MakeUnique<NativeCharacterType[]>(native_len + min_len + 1);
R_UNLESS(native_path != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(native_path != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Convert path. */
const auto res = ::MultiByteToWideChar(CP_UTF8, 0, full_path.GetString(), -1, native_path.get(), native_len);
@ -999,7 +999,7 @@ namespace ams::fssystem {
/* Allocate case sensitive buffer. */
auto case_sensitive_buffer_size = sizeof(NativeCharacterType) * (m_native_path_length + native_len + 1 + fs::EntryNameLengthMax);
NativePathBuffer case_sensitive_path_buffer = fs::impl::MakeUnique<NativeCharacterType[]>(case_sensitive_buffer_size / sizeof(NativeCharacterType));
R_UNLESS(case_sensitive_path_buffer != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(case_sensitive_path_buffer != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Get root path. */
const NativeCharacterType *root_path = m_native_path_buffer.get() != nullptr ? m_native_path_buffer.get() : L"";
@ -1022,7 +1022,7 @@ namespace ams::fssystem {
/* Tentatively assume other operating systems do the sane thing and use utf-8 strings. */
native_path = fs::impl::MakeUnique<NativeCharacterType[]>(native_len + min_len + 1);
R_UNLESS(native_path != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(native_path != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Copy in path. */
std::memcpy(native_path.get(), full_path.GetString(), native_len + 1);
@ -1075,7 +1075,7 @@ namespace ams::fssystem {
/* Allocate a new path buffer. */
NativePathBuffer cur_path_buf = fs::impl::MakeUnique<NativeCharacterType[]>(path_len + MAX_PATH);
R_UNLESS(cur_path_buf.get() != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(cur_path_buf.get() != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Copy the path into the temporary buffer. */
::wcscpy(cur_path_buf.get(), path);
@ -1143,7 +1143,7 @@ namespace ams::fssystem {
/* Allocate a temporary buffer. */
NativePathBuffer cur_path_buf = fs::impl::MakeUnique<NativeCharacterType[]>(path_len + PATH_MAX);
R_UNLESS(cur_path_buf.get() != nullptr, fs::ResultAllocationFailureInMakeUnique());
R_UNLESS(cur_path_buf.get() != nullptr, fs::ResultAllocationMemoryFailedMakeUnique());
/* Copy the path into the temporary buffer. */
std::memcpy(cur_path_buf.get(), path, path_len);
@ -1561,7 +1561,7 @@ namespace ams::fssystem {
/* Create a new local file. */
auto file = std::make_unique<LocalFile>(file_handle, mode);
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInLocalFileSystemA());
R_UNLESS(file != nullptr, fs::ResultAllocationMemoryFailedInLocalFileSystemA());
/* Set the output file. */
*out_file = std::move(file);
@ -1629,7 +1629,7 @@ namespace ams::fssystem {
/* Create a new local directory. */
auto dir = std::make_unique<LocalDirectory>(dir_handle, search_handle, mode, std::move(native_path));
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInLocalFileSystemB());
R_UNLESS(dir != nullptr, fs::ResultAllocationMemoryFailedInLocalFileSystemB());
/* Set the output directory. */
*out_dir = std::move(dir);

View file

@ -312,7 +312,7 @@ namespace ams::fssystem {
} else {
/* Otherwise, allocate a default splitter. */
*out_splitter = fssystem::AllocateShared<DefaultAsynchronousAccessSplitter>();
R_UNLESS(*out_splitter != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(*out_splitter != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
}
return ResultSuccess();
@ -430,7 +430,7 @@ namespace ams::fssystem {
} else {
/* Allocate a dummy memory storage as original storage. */
original_indirectable_storage = fssystem::AllocateShared<fs::MemoryStorage>(nullptr, 0);
R_UNLESS(original_indirectable_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(original_indirectable_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
}
/* Create the indirect storage. */
@ -517,7 +517,7 @@ namespace ams::fssystem {
Result NcaFileSystemDriver::CreateBodySubStorage(std::shared_ptr<fs::IStorage> *out, s64 offset, s64 size) {
/* Create the body storage. */
auto body_storage = fssystem::AllocateShared<SharedNcaBodyStorage>(m_reader->GetSharedBodyStorage(), m_reader);
R_UNLESS(body_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(body_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Get the body storage size. */
s64 body_size = 0;
@ -528,7 +528,7 @@ namespace ams::fssystem {
/* Create substorage. */
auto body_substorage = fssystem::AllocateShared<fs::SubStorage>(std::move(body_storage), offset, size);
R_UNLESS(body_substorage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(body_substorage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the output storage. */
*out = std::move(body_substorage);
@ -550,7 +550,7 @@ namespace ams::fssystem {
/* Create buffered storage. */
auto buffered_storage = fssystem::AllocateShared<BufferedStorage>();
R_UNLESS(buffered_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(buffered_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the buffered storage. */
R_TRY(buffered_storage->Initialize(fs::SubStorage(std::move(base_storage), 0, base_size), m_buffer_manager, AesCtrStorageCacheBlockSize, AesCtrStorageCacheCount));
@ -576,20 +576,20 @@ namespace ams::fssystem {
std::shared_ptr<fs::IStorage> aes_ctr_storage;
if (m_reader->HasExternalDecryptionKey()) {
aes_ctr_storage = fssystem::AllocateShared<AesCtrStorageExternal>(std::move(base_storage), m_reader->GetExternalDecryptionKey(), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, m_reader->GetExternalDecryptAesCtrFunctionForExternalKey(), -1);
R_UNLESS(aes_ctr_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aes_ctr_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
} else {
/* Create software decryption storage. */
auto sw_storage = fssystem::AllocateShared<AesCtrStorageBySharedPointer>(base_storage, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorageBySharedPointer::KeySize, iv, AesCtrStorageBySharedPointer::IvSize);
R_UNLESS(sw_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(sw_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* If we have a hardware key and should use it, make the hardware decryption storage. */
if (m_reader->HasInternalDecryptionKeyForAesHw() && !m_reader->IsSoftwareAesPrioritized()) {
auto hw_storage = fssystem::AllocateShared<AesCtrStorageExternal>(base_storage, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorageExternal::KeySize, iv, AesCtrStorageExternal::IvSize, m_reader->GetExternalDecryptAesCtrFunction(), GetKeyTypeValue(m_reader->GetKeyIndex(), m_reader->GetKeyGeneration()));
R_UNLESS(hw_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(hw_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Create the selection storage. */
auto switch_storage = fssystem::AllocateShared<SwitchStorage<bool (*)()>>(std::move(hw_storage), std::move(sw_storage), IsUsingHwAesCtrForSpeedEmulation);
R_UNLESS(switch_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(switch_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Use the selection storage. */
aes_ctr_storage = std::move(switch_storage);
@ -601,7 +601,7 @@ namespace ams::fssystem {
/* Create alignment matching storage. */
auto aligned_storage = fssystem::AllocateShared<AlignmentMatchingStorage<NcaHeader::CtrBlockSize, 1>>(std::move(aes_ctr_storage));
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the out storage. */
*out = std::move(aligned_storage);
@ -621,11 +621,11 @@ namespace ams::fssystem {
const auto * const key1 = m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts1);
const auto * const key2 = m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesXts2);
auto xts_storage = fssystem::AllocateShared<AesXtsStorageBySharedPointer>(std::move(base_storage), key1, key2, AesXtsStorageBySharedPointer::KeySize, iv, AesXtsStorageBySharedPointer::IvSize, NcaHeader::XtsBlockSize);
R_UNLESS(xts_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(xts_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Create alignment matching storage. */
auto aligned_storage = fssystem::AllocateShared<AlignmentMatchingStorage<NcaHeader::XtsBlockSize, 1>>(std::move(xts_storage));
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the out storage. */
*out = std::move(aligned_storage);
@ -648,7 +648,7 @@ namespace ams::fssystem {
/* Create the encrypted storage. */
auto enc_storage = fssystem::AllocateShared<fs::SubStorage>(std::move(base_storage), meta_offset, meta_size);
R_UNLESS(enc_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(enc_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Create the decrypted storage. */
std::shared_ptr<fs::IStorage> decrypted_storage;
@ -656,7 +656,7 @@ namespace ams::fssystem {
/* Create meta storage. */
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the meta storage. */
R_TRY(meta_storage->Initialize(fs::SubStorage(std::move(decrypted_storage), 0, meta_size), m_buffer_manager, SparseTableCacheBlockSize, SparseTableCacheCount));
@ -685,7 +685,7 @@ namespace ams::fssystem {
/* Create the sparse storage. */
auto sparse_storage = fssystem::AllocateShared<fssystem::SparseStorage>();
R_UNLESS(sparse_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(sparse_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Sanity check that we can be doing this. */
AMS_ASSERT(header.entry_count != 0);
@ -742,7 +742,7 @@ namespace ams::fssystem {
} else {
/* If there are no entries, there's nothing to actually do. */
sparse_storage = fssystem::AllocateShared<fssystem::SparseStorage>();
R_UNLESS(sparse_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(sparse_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
sparse_storage->Initialize(fs_size);
}
@ -782,7 +782,7 @@ namespace ams::fssystem {
/* Create the encrypted storage. */
auto enc_storage = fssystem::AllocateShared<fs::SubStorage>(std::move(base_storage), meta_offset, meta_size);
R_UNLESS(enc_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(enc_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Create the decrypted storage. */
std::shared_ptr<fs::IStorage> decrypted_storage;
@ -790,7 +790,7 @@ namespace ams::fssystem {
/* Create meta storage. */
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the meta storage. */
R_TRY(meta_storage->Initialize(fs::SubStorage(std::move(decrypted_storage), 0, meta_size), m_buffer_manager, AesCtrExTableCacheBlockSize, AesCtrExTableCacheCount));
@ -798,7 +798,7 @@ namespace ams::fssystem {
/* Create an alignment-matching storage. */
using AlignedStorage = AlignmentMatchingStorage<NcaHeader::CtrBlockSize, 1>;
auto aligned_storage = fssystem::AllocateShared<AlignedStorage>(std::move(meta_storage));
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the output. */
*out = std::move(aligned_storage);
@ -843,7 +843,7 @@ namespace ams::fssystem {
/* Create the aes ctr ex storage. */
auto impl_storage = fssystem::AllocateShared<AesCtrCounterExtendedStorage>();
R_UNLESS(impl_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(impl_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the aes ctr ex storage. */
R_TRY(impl_storage->Initialize(m_allocator, m_reader->GetExternalDecryptionKey(), AesCtrStorageBySharedPointer::KeySize, secure_value, counter_offset, data_storage, node_storage, entry_storage, entry_count, std::move(decryptor)));
@ -862,7 +862,7 @@ namespace ams::fssystem {
/* Make the software storage. */
auto sw_storage = fssystem::AllocateShared<AesCtrCounterExtendedStorage>();
R_UNLESS(sw_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(sw_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the software storage. */
R_TRY(sw_storage->Initialize(m_allocator, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtr), AesCtrStorageBySharedPointer::KeySize, secure_value, counter_offset, data_storage, node_storage, entry_storage, entry_count, std::move(sw_decryptor)));
@ -880,14 +880,14 @@ namespace ams::fssystem {
/* Create the hardware storage. */
auto hw_storage = fssystem::AllocateShared<AesCtrCounterExtendedStorage>();
R_UNLESS(hw_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(hw_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the hardware storage. */
R_TRY(hw_storage->Initialize(m_allocator, m_reader->GetDecryptionKey(NcaHeader::DecryptionKey_AesCtrHw), AesCtrStorageBySharedPointer::KeySize, secure_value, counter_offset, data_storage, node_storage, entry_storage, entry_count, std::move(hw_decryptor)));
/* Create the selection storage. */
auto switch_storage = fssystem::AllocateShared<SwitchStorage<bool (*)()>>(std::move(hw_storage), std::move(sw_storage), IsUsingHwAesCtrForSpeedEmulation);
R_UNLESS(switch_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(switch_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the implementation storage. */
aes_ctr_ex_storage = std::move(switch_storage);
@ -900,7 +900,7 @@ namespace ams::fssystem {
/* Create an alignment-matching storage. */
using AlignedStorage = AlignmentMatchingStorage<NcaHeader::CtrBlockSize, 1>;
auto aligned_storage = fssystem::AllocateShared<AlignedStorage>(std::move(aes_ctr_ex_storage));
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the output. */
*out = std::move(aligned_storage);
@ -922,7 +922,7 @@ namespace ams::fssystem {
/* Allocate the meta storage. */
auto meta_storage = fssystem::AllocateShared<BufferedStorage>();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the meta storage. */
R_TRY(meta_storage->Initialize(fs::SubStorage(base_storage, patch_info.indirect_offset, patch_info.indirect_size), m_buffer_manager, IndirectTableCacheBlockSize, IndirectTableCacheCount));
@ -955,7 +955,7 @@ namespace ams::fssystem {
/* Create the indirect data storage. */
auto indirect_data_storage = fssystem::AllocateShared<BufferedStorage>();
R_UNLESS(indirect_data_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(indirect_data_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the indirect data storage. */
R_TRY(indirect_data_storage->Initialize(fs::SubStorage(base_storage, 0, indirect_data_size), m_buffer_manager, IndirectDataCacheBlockSize, IndirectDataCacheCount));
@ -965,7 +965,7 @@ namespace ams::fssystem {
/* Create the indirect storage. */
auto indirect_storage = fssystem::AllocateShared<IndirectStorage>();
R_UNLESS(indirect_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(indirect_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the indirect storage. */
R_TRY(indirect_storage->Initialize(m_allocator, fs::SubStorage(meta_storage, 0, node_size), fs::SubStorage(meta_storage, node_size, entry_size), header.entry_count));
@ -1014,8 +1014,8 @@ namespace ams::fssystem {
/* Make a buffer holder storage. */
auto buffer_hold_storage = fssystem::AllocateShared<MemoryResourceBufferHoldStorage>(std::move(base_storage), m_allocator, total_buffer_size);
R_UNLESS(buffer_hold_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(buffer_hold_storage->IsValid(), fs::ResultAllocationFailureInNcaFileSystemDriverI());
R_UNLESS(buffer_hold_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
R_UNLESS(buffer_hold_storage->IsValid(), fs::ResultAllocationMemoryFailedInNcaFileSystemDriverI());
/* Get storage size. */
s64 base_size;
@ -1030,7 +1030,7 @@ namespace ams::fssystem {
/* Make the verification storage. */
auto verification_storage = fssystem::AllocateShared<VerificationStorage>();
R_UNLESS(verification_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(verification_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Make layer storages. */
fs::SubStorage layer_storages[VerificationStorage::LayerCount] = {
@ -1044,11 +1044,11 @@ namespace ams::fssystem {
/* Make the cache storage. */
auto cache_storage = fssystem::AllocateShared<CacheStorage>(std::move(verification_storage), hash_data.hash_block_size, static_cast<char *>(buffer_hold_storage->GetBuffer()) + hash_buffer_size, cache_buffer_size, CacheBlockCount);
R_UNLESS(cache_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(cache_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Make the aligned storage. */
auto aligned_storage = fssystem::AllocateShared<AlignedStorage>(std::move(cache_storage), hash_data.hash_block_size);
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(aligned_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Set the output. */
*out = std::move(aligned_storage);
@ -1091,7 +1091,7 @@ namespace ams::fssystem {
/* Make the integrity romfs storage. */
auto integrity_storage = fssystem::AllocateShared<fssystem::IntegrityRomFsStorage>();
R_UNLESS(integrity_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(integrity_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the integrity storage. */
R_TRY(integrity_storage->Initialize(level_hash_info, meta_info.master_hash, storage_info, m_buffer_manager, m_hash_generator_factory_selector->GetFactory()));
@ -1126,14 +1126,14 @@ namespace ams::fssystem {
/* If we should, set the output meta storage. */
if (out_meta != nullptr) {
auto meta_storage = fssystem::AllocateShared<fs::SubStorage>(base_storage, table_offset, table_size);
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
*out_meta = std::move(meta_storage);
}
/* Allocate the compressed storage. */
auto compressed_storage = fssystem::AllocateShared<fssystem::CompressedStorage>();
R_UNLESS(compressed_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
R_UNLESS(compressed_storage != nullptr, fs::ResultAllocationMemoryFailedAllocateShared());
/* Initialize the compressed storage. */
R_TRY(compressed_storage->Initialize(allocator, buffer_manager, fs::SubStorage(base_storage, 0, table_offset), fs::SubStorage(base_storage, table_offset, node_size), fs::SubStorage(base_storage, table_offset + node_size, entry_size), header.entry_count, 64_KB, 640_KB, get_decompressor, 16_KB, 16_KB, 32));

View file

@ -65,7 +65,7 @@ namespace ams::fssystem {
/* Create the header storage. */
const u8 header_iv[AesXtsStorageForNcaHeader::IvSize] = {};
std::unique_ptr<fs::IStorage> work_header_storage = std::make_unique<AesXtsStorageForNcaHeader>(base_storage, header_decryption_keys[0], header_decryption_keys[1], AesXtsStorageForNcaHeader::KeySize, header_iv, AesXtsStorageForNcaHeader::IvSize, NcaHeader::XtsBlockSize);
R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationFailureInNcaReaderA());
R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationMemoryFailedInNcaReaderA());
/* Read the header. */
R_TRY(work_header_storage->Read(0, std::addressof(m_header), sizeof(m_header)));
@ -83,7 +83,7 @@ namespace ams::fssystem {
s64 base_storage_size;
R_TRY(base_storage->GetSize(std::addressof(base_storage_size)));
work_header_storage.reset(new fs::SubStorage(base_storage, 0, base_storage_size));
R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationFailureInNcaReaderA());
R_UNLESS(work_header_storage != nullptr, fs::ResultAllocationMemoryFailedInNcaReaderA());
/* Set encryption type as plaintext. */
m_header_encryption_type = NcaHeader::EncryptionType::None;

View file

@ -286,7 +286,7 @@ namespace ams::fssystem {
/* Allocate meta data. */
m_unique_meta_data = std::make_unique<MetaType>();
R_UNLESS(m_unique_meta_data != nullptr, fs::ResultAllocationFailureInPartitionFileSystemA());
R_UNLESS(m_unique_meta_data != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemA());
/* Initialize meta data. */
R_TRY(m_unique_meta_data->Initialize(base_storage, allocator));
@ -382,7 +382,7 @@ namespace ams::fssystem {
/* Create and output the file directory. */
std::unique_ptr file = std::make_unique<PartitionFile>(this, m_meta_data->GetEntry(entry_index), mode);
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInPartitionFileSystemB());
R_UNLESS(file != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemB());
*out_file = std::move(file);
R_SUCCEED();
}
@ -395,7 +395,7 @@ namespace ams::fssystem {
/* Create and output the partition directory. */
std::unique_ptr directory = std::make_unique<PartitionDirectory>(this, mode);
R_UNLESS(directory != nullptr, fs::ResultAllocationFailureInPartitionFileSystemC());
R_UNLESS(directory != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemC());
*out_dir = std::move(directory);
R_SUCCEED();
}

View file

@ -44,7 +44,7 @@ namespace ams::fssystem {
this->DeallocateBuffer();
m_allocator = allocator;
m_buffer = static_cast<char *>(m_allocator->Allocate(m_meta_data_size));
R_UNLESS(m_buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaA());
R_UNLESS(m_buffer != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemMetaA());
/* Perform regular initialization. */
return this->Initialize(storage, m_buffer, m_meta_data_size);
@ -175,7 +175,7 @@ namespace ams::fssystem {
/* Set allocator and allocate buffer. */
m_allocator = allocator;
m_buffer = static_cast<char *>(m_allocator->Allocate(m_meta_data_size));
R_UNLESS(m_buffer != nullptr, fs::ResultAllocationFailureInPartitionFileSystemMetaB());
R_UNLESS(m_buffer != nullptr, fs::ResultAllocationMemoryFailedInPartitionFileSystemMetaB());
/* Read metadata. */
R_TRY(base_storage->Read(0, m_buffer, m_meta_data_size));

View file

@ -233,7 +233,7 @@ namespace ams::fssystem {
/* Set up our storages. */
if (use_cache) {
const size_t needed_size = CalculateRequiredWorkingMemorySize(header);
R_UNLESS(work_size >= needed_size, fs::ResultAllocationFailureInRomFsFileSystemA());
R_UNLESS(work_size >= needed_size, fs::ResultAllocationMemoryFailedInRomFsFileSystemA());
u8 *buf = static_cast<u8 *>(work);
auto dir_bucket_buf = buf; buf += header.directory_bucket_size;
@ -258,10 +258,10 @@ namespace ams::fssystem {
}
/* Ensure we allocated storages successfully. */
R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationFailureInRomFsFileSystemB());
R_UNLESS(m_dir_bucket_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemB());
R_UNLESS(m_dir_entry_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemB());
R_UNLESS(m_file_bucket_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemB());
R_UNLESS(m_file_entry_storage != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemB());
/* Initialize the rom table. */
R_TRY(m_rom_file_table.Initialize(fs::SubStorage(m_dir_bucket_storage.get(), 0, static_cast<u32>(header.directory_bucket_size)),
@ -369,7 +369,7 @@ namespace ams::fssystem {
R_TRY(this->GetFileInfo(std::addressof(file_info), path));
auto file = std::make_unique<RomFsFile>(this, m_entry_size + file_info.offset.Get(), m_entry_size + file_info.offset.Get() + file_info.size.Get());
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInRomFsFileSystemC());
R_UNLESS(file != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemC());
*out_file = std::move(file);
R_SUCCEED();
@ -388,7 +388,7 @@ namespace ams::fssystem {
}, AMS_CURRENT_FUNCTION_NAME));
auto dir = std::make_unique<RomFsDirectory>(this, find, mode);
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInRomFsFileSystemD());
R_UNLESS(dir != nullptr, fs::ResultAllocationMemoryFailedInRomFsFileSystemD());
*out_dir = std::move(dir);
R_SUCCEED();