strat: use m_ for member variables
This commit is contained in:
@@ -21,15 +21,15 @@ namespace ams::fssrv::fscreator {
|
||||
|
||||
class RomFileSystemWithBuffer : public ::ams::fssystem::RomFsFileSystem {
|
||||
private:
|
||||
void *meta_cache_buffer;
|
||||
size_t meta_cache_buffer_size;
|
||||
MemoryResource *allocator;
|
||||
void *m_meta_cache_buffer;
|
||||
size_t m_meta_cache_buffer_size;
|
||||
MemoryResource *m_allocator;
|
||||
public:
|
||||
explicit RomFileSystemWithBuffer(MemoryResource *mr) : meta_cache_buffer(nullptr), allocator(mr) { /* ... */ }
|
||||
explicit RomFileSystemWithBuffer(MemoryResource *mr) : m_meta_cache_buffer(nullptr), m_allocator(mr) { /* ... */ }
|
||||
|
||||
~RomFileSystemWithBuffer() {
|
||||
if (this->meta_cache_buffer != nullptr) {
|
||||
this->allocator->Deallocate(this->meta_cache_buffer, this->meta_cache_buffer_size);
|
||||
if (m_meta_cache_buffer != nullptr) {
|
||||
m_allocator->Deallocate(m_meta_cache_buffer, m_meta_cache_buffer_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,14 +41,14 @@ namespace ams::fssrv::fscreator {
|
||||
}
|
||||
|
||||
/* Allocate a buffer. */
|
||||
this->meta_cache_buffer = this->allocator->Allocate(buffer_size);
|
||||
if (this->meta_cache_buffer == nullptr) {
|
||||
m_meta_cache_buffer = m_allocator->Allocate(buffer_size);
|
||||
if (m_meta_cache_buffer == nullptr) {
|
||||
return RomFsFileSystem::Initialize(std::move(storage), nullptr, 0, false);
|
||||
}
|
||||
|
||||
/* Initialize with cache buffer. */
|
||||
this->meta_cache_buffer_size = buffer_size;
|
||||
return RomFsFileSystem::Initialize(std::move(storage), this->meta_cache_buffer, this->meta_cache_buffer_size, true);
|
||||
m_meta_cache_buffer_size = buffer_size;
|
||||
return RomFsFileSystem::Initialize(std::move(storage), m_meta_cache_buffer, m_meta_cache_buffer_size, true);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace ams::fssrv::fscreator {
|
||||
|
||||
Result RomFileSystemCreator::Create(std::shared_ptr<fs::fsa::IFileSystem> *out, std::shared_ptr<fs::IStorage> storage) {
|
||||
/* Allocate a filesystem. */
|
||||
std::shared_ptr fs = fssystem::AllocateShared<RomFileSystemWithBuffer>(this->allocator);
|
||||
std::shared_ptr fs = fssystem::AllocateShared<RomFileSystemWithBuffer>(m_allocator);
|
||||
R_UNLESS(fs != nullptr, fs::ResultAllocationFailureInRomFileSystemCreatorA());
|
||||
|
||||
/* Initialize the filesystem. */
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace ams::fssrv::fscreator {
|
||||
R_UNLESS(size == sizeof(acid_size), fs::ResultInvalidAcidFileSize());
|
||||
|
||||
/* Allocate memory for the acid. */
|
||||
u8 *acid = static_cast<u8 *>(this->allocator->Allocate(acid_size));
|
||||
u8 *acid = static_cast<u8 *>(m_allocator->Allocate(acid_size));
|
||||
R_UNLESS(acid != nullptr, fs::ResultAllocationFailureInStorageOnNcaCreatorA());
|
||||
ON_SCOPE_EXIT { this->allocator->Deallocate(acid, acid_size); };
|
||||
ON_SCOPE_EXIT { m_allocator->Deallocate(acid, acid_size); };
|
||||
|
||||
/* Read the acid. */
|
||||
R_TRY(file->Read(std::addressof(size), acid_offset, acid, acid_size, fs::ReadOption()));
|
||||
@@ -72,7 +72,7 @@ namespace ams::fssrv::fscreator {
|
||||
{
|
||||
const u8 *sig = acid + AcidSignOffset;
|
||||
const size_t sig_size = static_cast<size_t>(AcidSignSize);
|
||||
const u8 *mod = fssystem::GetAcidSignatureKeyModulus(this->is_prod, acid_signature_key_generation);
|
||||
const u8 *mod = fssystem::GetAcidSignatureKeyModulus(m_is_prod, acid_signature_key_generation);
|
||||
const size_t mod_size = fssystem::AcidSignatureKeyModulusSize;
|
||||
const u8 *exp = fssystem::GetAcidSignatureKeyPublicExponent();
|
||||
const size_t exp_size = fssystem::AcidSignatureKeyPublicExponentSize;
|
||||
@@ -81,7 +81,7 @@ namespace ams::fssrv::fscreator {
|
||||
const bool is_signature_valid = crypto::VerifyRsa2048PssSha256(sig, sig_size, mod, mod_size, exp, exp_size, msg, msg_size);
|
||||
if (!is_signature_valid) {
|
||||
/* If the signature is invalid, then unless program verification is disabled error out. */
|
||||
R_UNLESS(!this->is_enabled_program_verification, fs::ResultAcidVerificationFailed());
|
||||
R_UNLESS(!m_is_enabled_program_verification, fs::ResultAcidVerificationFailed());
|
||||
|
||||
/* If program verification is disabled, then we're fine. */
|
||||
return ResultSuccess();
|
||||
@@ -104,7 +104,7 @@ namespace ams::fssrv::fscreator {
|
||||
|
||||
Result StorageOnNcaCreator::Create(std::shared_ptr<fs::IStorage> *out, fssystem::NcaFsHeaderReader *out_header_reader, std::shared_ptr<fssystem::NcaReader> nca_reader, s32 index, bool verify_header_sign_2) {
|
||||
/* Create a fs driver. */
|
||||
fssystem::NcaFileSystemDriver nca_fs_driver(nca_reader, this->allocator, this->buffer_manager);
|
||||
fssystem::NcaFileSystemDriver nca_fs_driver(nca_reader, m_allocator, m_buffer_manager);
|
||||
|
||||
/* Open the storage. */
|
||||
std::shared_ptr<fs::IStorage> storage;
|
||||
@@ -122,7 +122,7 @@ namespace ams::fssrv::fscreator {
|
||||
|
||||
Result StorageOnNcaCreator::CreateWithPatch(std::shared_ptr<fs::IStorage> *out, fssystem::NcaFsHeaderReader *out_header_reader, std::shared_ptr<fssystem::NcaReader> original_nca_reader, std::shared_ptr<fssystem::NcaReader> current_nca_reader, s32 index, bool verify_header_sign_2) {
|
||||
/* Create a fs driver. */
|
||||
fssystem::NcaFileSystemDriver nca_fs_driver(original_nca_reader, current_nca_reader, this->allocator, this->buffer_manager);
|
||||
fssystem::NcaFileSystemDriver nca_fs_driver(original_nca_reader, current_nca_reader, m_allocator, m_buffer_manager);
|
||||
|
||||
/* Open the storage. */
|
||||
std::shared_ptr<fs::IStorage> storage;
|
||||
@@ -144,7 +144,7 @@ namespace ams::fssrv::fscreator {
|
||||
R_UNLESS(reader != nullptr, fs::ResultAllocationFailureInStorageOnNcaCreatorB());
|
||||
|
||||
/* Initialize the reader. */
|
||||
R_TRY(reader->Initialize(std::move(storage), this->nca_crypto_cfg));
|
||||
R_TRY(reader->Initialize(std::move(storage), m_nca_crypto_cfg));
|
||||
|
||||
/* Set the output. */
|
||||
*out = std::move(reader);
|
||||
@@ -152,8 +152,8 @@ namespace ams::fssrv::fscreator {
|
||||
}
|
||||
|
||||
void StorageOnNcaCreator::SetEnabledProgramVerification(bool en) {
|
||||
if (!this->is_prod) {
|
||||
this->is_enabled_program_verification = en;
|
||||
if (!m_is_prod) {
|
||||
m_is_enabled_program_verification = en;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
FileInterfaceAdapter::FileInterfaceAdapter(std::unique_ptr<fs::fsa::IFile> &&file, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema)
|
||||
: parent_filesystem(parent, true), base_file(std::move(file)), open_count_semaphore(std::move(sema))
|
||||
: m_parent_filesystem(parent, true), m_base_file(std::move(file)), m_open_count_semaphore(std::move(sema))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@@ -30,9 +30,9 @@ namespace ams::fssrv::impl {
|
||||
}
|
||||
|
||||
void FileInterfaceAdapter::InvalidateCache() {
|
||||
AMS_ABORT_UNLESS(this->parent_filesystem->IsDeepRetryEnabled());
|
||||
std::scoped_lock<os::ReaderWriterLock> scoped_write_lock(this->parent_filesystem->GetReaderWriterLockForCacheInvalidation());
|
||||
this->base_file->OperateRange(nullptr, 0, fs::OperationId::Invalidate, 0, std::numeric_limits<s64>::max(), nullptr, 0);
|
||||
AMS_ABORT_UNLESS(m_parent_filesystem->IsDeepRetryEnabled());
|
||||
std::scoped_lock<os::ReaderWriterLock> scoped_write_lock(m_parent_filesystem->GetReaderWriterLockForCacheInvalidation());
|
||||
m_base_file->OperateRange(nullptr, 0, fs::OperationId::Invalidate, 0, std::numeric_limits<s64>::max(), nullptr, 0);
|
||||
}
|
||||
|
||||
Result FileInterfaceAdapter::Read(ams::sf::Out<s64> out, s64 offset, const ams::sf::OutNonSecureBuffer &buffer, s64 size, fs::ReadOption option) {
|
||||
@@ -42,7 +42,7 @@ namespace ams::fssrv::impl {
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
|
||||
size_t read_size = 0;
|
||||
R_TRY(this->base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast<size_t>(size), option));
|
||||
R_TRY(m_base_file->Read(std::addressof(read_size), offset, buffer.GetPointer(), static_cast<size_t>(size), option));
|
||||
|
||||
out.SetValue(read_size);
|
||||
return ResultSuccess();
|
||||
@@ -53,24 +53,24 @@ namespace ams::fssrv::impl {
|
||||
R_UNLESS(offset >= 0, fs::ResultInvalidOffset());
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return this->base_file->Write(offset, buffer.GetPointer(), size, option);
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return m_base_file->Write(offset, buffer.GetPointer(), size, option);
|
||||
}
|
||||
|
||||
Result FileInterfaceAdapter::Flush() {
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return this->base_file->Flush();
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return m_base_file->Flush();
|
||||
}
|
||||
|
||||
Result FileInterfaceAdapter::SetSize(s64 size) {
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return this->base_file->SetSize(size);
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return m_base_file->SetSize(size);
|
||||
}
|
||||
|
||||
Result FileInterfaceAdapter::GetSize(ams::sf::Out<s64> out) {
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return this->base_file->GetSize(out.GetPointer());
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return m_base_file->GetSize(out.GetPointer());
|
||||
}
|
||||
|
||||
Result FileInterfaceAdapter::OperateRange(ams::sf::Out<fs::FileQueryRangeInfo> out, s32 op_id, s64 offset, s64 size) {
|
||||
@@ -79,10 +79,10 @@ namespace ams::fssrv::impl {
|
||||
|
||||
out->Clear();
|
||||
if (op_id == static_cast<s32>(fs::OperationId::QueryRange)) {
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
|
||||
fs::FileQueryRangeInfo info;
|
||||
R_TRY(this->base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
R_TRY(m_base_file->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
out->Merge(info);
|
||||
}
|
||||
|
||||
@@ -105,13 +105,13 @@ namespace ams::fssrv::impl {
|
||||
}
|
||||
|
||||
/* Perform the operation. */
|
||||
R_TRY(this->base_file->OperateRange(out_buf.GetPointer(), out_buf.GetSize(), static_cast<fs::OperationId>(op_id), offset, size, in_buf.GetPointer(), in_buf.GetSize()));
|
||||
R_TRY(m_base_file->OperateRange(out_buf.GetPointer(), out_buf.GetSize(), static_cast<fs::OperationId>(op_id), offset, size, in_buf.GetPointer(), in_buf.GetSize()));
|
||||
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
DirectoryInterfaceAdapter::DirectoryInterfaceAdapter(std::unique_ptr<fs::fsa::IDirectory> &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema)
|
||||
: parent_filesystem(parent, true), base_dir(std::move(dir)), open_count_semaphore(std::move(sema))
|
||||
: m_parent_filesystem(parent, true), m_base_dir(std::move(dir)), m_open_count_semaphore(std::move(sema))
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@@ -121,22 +121,22 @@ namespace ams::fssrv::impl {
|
||||
}
|
||||
|
||||
Result DirectoryInterfaceAdapter::Read(ams::sf::Out<s64> out, const ams::sf::OutBuffer &out_entries) {
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
|
||||
const s64 max_num_entries = out_entries.GetSize() / sizeof(fs::DirectoryEntry);
|
||||
R_UNLESS(max_num_entries >= 0, fs::ResultInvalidSize());
|
||||
|
||||
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
|
||||
return this->base_dir->Read(out.GetPointer(), reinterpret_cast<fs::DirectoryEntry *>(out_entries.GetPointer()), max_num_entries);
|
||||
return m_base_dir->Read(out.GetPointer(), reinterpret_cast<fs::DirectoryEntry *>(out_entries.GetPointer()), max_num_entries);
|
||||
}
|
||||
|
||||
Result DirectoryInterfaceAdapter::GetEntryCount(ams::sf::Out<s64> out) {
|
||||
auto read_lock = this->parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return this->base_dir->GetEntryCount(out.GetPointer());
|
||||
auto read_lock = m_parent_filesystem->AcquireCacheInvalidationReadLock();
|
||||
return m_base_dir->GetEntryCount(out.GetPointer());
|
||||
}
|
||||
|
||||
FileSystemInterfaceAdapter::FileSystemInterfaceAdapter(std::shared_ptr<fs::fsa::IFileSystem> &&fs, bool open_limited)
|
||||
: base_fs(std::move(fs)), open_count_limited(open_limited), deep_retry_enabled(false)
|
||||
: m_base_fs(std::move(fs)), m_open_count_limited(open_limited), m_deep_retry_enabled(false)
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
@@ -146,7 +146,7 @@ namespace ams::fssrv::impl {
|
||||
}
|
||||
|
||||
bool FileSystemInterfaceAdapter::IsDeepRetryEnabled() const {
|
||||
return this->deep_retry_enabled;
|
||||
return m_deep_retry_enabled;
|
||||
}
|
||||
|
||||
bool FileSystemInterfaceAdapter::IsAccessFailureDetectionObserved() const {
|
||||
@@ -156,14 +156,14 @@ namespace ams::fssrv::impl {
|
||||
|
||||
util::optional<std::shared_lock<os::ReaderWriterLock>> FileSystemInterfaceAdapter::AcquireCacheInvalidationReadLock() {
|
||||
util::optional<std::shared_lock<os::ReaderWriterLock>> lock;
|
||||
if (this->deep_retry_enabled) {
|
||||
lock.emplace(this->invalidation_lock);
|
||||
if (m_deep_retry_enabled) {
|
||||
lock.emplace(m_invalidation_lock);
|
||||
}
|
||||
return lock;
|
||||
}
|
||||
|
||||
os::ReaderWriterLock &FileSystemInterfaceAdapter::GetReaderWriterLockForCacheInvalidation() {
|
||||
return this->invalidation_lock;
|
||||
return m_invalidation_lock;
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::CreateFile(const fssrv::sf::Path &path, s64 size, s32 option) {
|
||||
@@ -174,7 +174,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->CreateFile(normalizer.GetPath(), size, option);
|
||||
return m_base_fs->CreateFile(normalizer.GetPath(), size, option);
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::DeleteFile(const fssrv::sf::Path &path) {
|
||||
@@ -183,7 +183,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->DeleteFile(normalizer.GetPath());
|
||||
return m_base_fs->DeleteFile(normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::CreateDirectory(const fssrv::sf::Path &path) {
|
||||
@@ -194,7 +194,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultPathAlreadyExists());
|
||||
|
||||
return this->base_fs->CreateDirectory(normalizer.GetPath());
|
||||
return m_base_fs->CreateDirectory(normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::DeleteDirectory(const fssrv::sf::Path &path) {
|
||||
@@ -205,7 +205,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultDirectoryNotDeletable());
|
||||
|
||||
return this->base_fs->DeleteDirectory(normalizer.GetPath());
|
||||
return m_base_fs->DeleteDirectory(normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::DeleteDirectoryRecursively(const fssrv::sf::Path &path) {
|
||||
@@ -216,7 +216,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
R_UNLESS(strncmp(normalizer.GetPath(), "/", 2) != 0, fs::ResultDirectoryNotDeletable());
|
||||
|
||||
return this->base_fs->DeleteDirectoryRecursively(normalizer.GetPath());
|
||||
return m_base_fs->DeleteDirectoryRecursively(normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::RenameFile(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) {
|
||||
@@ -227,7 +227,7 @@ namespace ams::fssrv::impl {
|
||||
R_UNLESS(old_normalizer.GetPath() != nullptr, old_normalizer.GetResult());
|
||||
R_UNLESS(new_normalizer.GetPath() != nullptr, new_normalizer.GetResult());
|
||||
|
||||
return this->base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath());
|
||||
return m_base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::RenameDirectory(const fssrv::sf::Path &old_path, const fssrv::sf::Path &new_path) {
|
||||
@@ -241,7 +241,7 @@ namespace ams::fssrv::impl {
|
||||
const bool is_subpath = fs::IsSubPath(old_normalizer.GetPath(), new_normalizer.GetPath());
|
||||
R_UNLESS(!is_subpath, fs::ResultDirectoryNotRenamable());
|
||||
|
||||
return this->base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath());
|
||||
return m_base_fs->RenameFile(old_normalizer.GetPath(), new_normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::GetEntryType(ams::sf::Out<u32> out, const fssrv::sf::Path &path) {
|
||||
@@ -251,14 +251,14 @@ namespace ams::fssrv::impl {
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
static_assert(sizeof(*out.GetPointer()) == sizeof(fs::DirectoryEntryType));
|
||||
return this->base_fs->GetEntryType(reinterpret_cast<fs::DirectoryEntryType *>(out.GetPointer()), normalizer.GetPath());
|
||||
return m_base_fs->GetEntryType(reinterpret_cast<fs::DirectoryEntryType *>(out.GetPointer()), normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::OpenFile(ams::sf::Out<ams::sf::SharedPointer<fssrv::sf::IFile>> out, const fssrv::sf::Path &path, u32 mode) {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
|
||||
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
|
||||
if (this->open_count_limited) {
|
||||
if (m_open_count_limited) {
|
||||
/* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
@@ -268,7 +268,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
|
||||
std::unique_ptr<fs::fsa::IFile> file;
|
||||
R_TRY(this->base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
|
||||
R_TRY(m_base_fs->OpenFile(std::addressof(file), normalizer.GetPath(), static_cast<fs::OpenMode>(mode)));
|
||||
|
||||
/* TODO: This is a hack to get the mitm API to work. Better solution? */
|
||||
const auto target_object_id = file->GetDomainObjectId();
|
||||
@@ -286,7 +286,7 @@ namespace ams::fssrv::impl {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
|
||||
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
|
||||
if (this->open_count_limited) {
|
||||
if (m_open_count_limited) {
|
||||
/* TODO: This calls into fssrv::FileSystemProxyImpl, which we don't have yet. */
|
||||
AMS_ABORT_UNLESS(false);
|
||||
}
|
||||
@@ -296,7 +296,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
/* TODO: N retries on fs::ResultDataCorrupted, we may want to eventually. */
|
||||
std::unique_ptr<fs::fsa::IDirectory> dir;
|
||||
R_TRY(this->base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
|
||||
R_TRY(m_base_fs->OpenDirectory(std::addressof(dir), normalizer.GetPath(), static_cast<fs::OpenDirectoryMode>(mode)));
|
||||
|
||||
/* TODO: This is a hack to get the mitm API to work. Better solution? */
|
||||
const auto target_object_id = dir->GetDomainObjectId();
|
||||
@@ -311,7 +311,7 @@ namespace ams::fssrv::impl {
|
||||
Result FileSystemInterfaceAdapter::Commit() {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
|
||||
return this->base_fs->Commit();
|
||||
return m_base_fs->Commit();
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::GetFreeSpaceSize(ams::sf::Out<s64> out, const fssrv::sf::Path &path) {
|
||||
@@ -320,7 +320,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->GetFreeSpaceSize(out.GetPointer(), normalizer.GetPath());
|
||||
return m_base_fs->GetFreeSpaceSize(out.GetPointer(), normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::GetTotalSpaceSize(ams::sf::Out<s64> out, const fssrv::sf::Path &path) {
|
||||
@@ -329,7 +329,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->GetTotalSpaceSize(out.GetPointer(), normalizer.GetPath());
|
||||
return m_base_fs->GetTotalSpaceSize(out.GetPointer(), normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::CleanDirectoryRecursively(const fssrv::sf::Path &path) {
|
||||
@@ -338,7 +338,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->CleanDirectoryRecursively(normalizer.GetPath());
|
||||
return m_base_fs->CleanDirectoryRecursively(normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::GetFileTimeStampRaw(ams::sf::Out<fs::FileTimeStampRaw> out, const fssrv::sf::Path &path) {
|
||||
@@ -347,7 +347,7 @@ namespace ams::fssrv::impl {
|
||||
PathNormalizer normalizer(path.str);
|
||||
R_UNLESS(normalizer.GetPath() != nullptr, normalizer.GetResult());
|
||||
|
||||
return this->base_fs->GetFileTimeStampRaw(out.GetPointer(), normalizer.GetPath());
|
||||
return m_base_fs->GetFileTimeStampRaw(out.GetPointer(), normalizer.GetPath());
|
||||
}
|
||||
|
||||
Result FileSystemInterfaceAdapter::QueryEntry(const ams::sf::OutBuffer &out_buf, const ams::sf::InBuffer &in_buf, s32 query_id, const fssrv::sf::Path &path) {
|
||||
@@ -357,7 +357,7 @@ namespace ams::fssrv::impl {
|
||||
|
||||
char *dst = reinterpret_cast< char *>(out_buf.GetPointer());
|
||||
const char *src = reinterpret_cast<const char *>(in_buf.GetPointer());
|
||||
return this->base_fs->QueryEntry(dst, out_buf.GetSize(), src, in_buf.GetSize(), static_cast<fs::fsa::QueryId>(query_id), path.str);
|
||||
return m_base_fs->QueryEntry(dst, out_buf.GetSize(), src, in_buf.GetSize(), static_cast<fs::fsa::QueryId>(query_id), path.str);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace ams::fssrv {
|
||||
AMS_UNUSED(size);
|
||||
|
||||
if (p != nullptr) {
|
||||
this->current_free_size = GetUsedSize(p);
|
||||
this->peak_free_size = std::min(this->peak_free_size, this->current_free_size);
|
||||
m_current_free_size = GetUsedSize(p);
|
||||
m_peak_free_size = std::min(m_peak_free_size, m_current_free_size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ namespace ams::fssrv {
|
||||
AMS_UNUSED(size);
|
||||
|
||||
if (p != nullptr) {
|
||||
this->current_free_size += GetUsedSize(p);
|
||||
m_current_free_size += GetUsedSize(p);
|
||||
}
|
||||
}
|
||||
|
||||
void *PeakCheckableMemoryResourceFromExpHeap::AllocateImpl(size_t size, size_t align) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
void *p = lmem::AllocateFromExpHeap(this->heap_handle, size, static_cast<s32>(align));
|
||||
void *p = lmem::AllocateFromExpHeap(m_heap_handle, size, static_cast<s32>(align));
|
||||
this->OnAllocate(p, size);
|
||||
return p;
|
||||
}
|
||||
@@ -54,10 +54,10 @@ namespace ams::fssrv {
|
||||
void PeakCheckableMemoryResourceFromExpHeap::DeallocateImpl(void *p, size_t size, size_t align) {
|
||||
AMS_UNUSED(align);
|
||||
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
this->OnDeallocate(p, size);
|
||||
lmem::FreeToExpHeap(this->heap_handle, p);
|
||||
lmem::FreeToExpHeap(m_heap_handle, p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,28 +17,28 @@
|
||||
|
||||
namespace ams::fssrv {
|
||||
|
||||
MemoryResourceFromStandardAllocator::MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator) : allocator(allocator), mutex() {
|
||||
this->current_free_size = this->allocator->GetTotalFreeSize();
|
||||
MemoryResourceFromStandardAllocator::MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator) : m_allocator(allocator), m_mutex() {
|
||||
m_current_free_size = m_allocator->GetTotalFreeSize();
|
||||
this->ClearPeak();
|
||||
}
|
||||
|
||||
void MemoryResourceFromStandardAllocator::ClearPeak() {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
this->peak_free_size = this->current_free_size;
|
||||
this->peak_allocated_size = 0;
|
||||
std::scoped_lock lk(m_mutex);
|
||||
m_peak_free_size = m_current_free_size;
|
||||
m_peak_allocated_size = 0;
|
||||
}
|
||||
|
||||
void *MemoryResourceFromStandardAllocator::AllocateImpl(size_t size, size_t align) {
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
void *p = this->allocator->Allocate(size, align);
|
||||
void *p = m_allocator->Allocate(size, align);
|
||||
|
||||
if (p != nullptr) {
|
||||
this->current_free_size -= this->allocator->GetSizeOf(p);
|
||||
this->peak_free_size = std::min(this->peak_free_size, this->current_free_size);
|
||||
m_current_free_size -= m_allocator->GetSizeOf(p);
|
||||
m_peak_free_size = std::min(m_peak_free_size, m_current_free_size);
|
||||
}
|
||||
|
||||
this->peak_allocated_size = std::max(this->peak_allocated_size, size);
|
||||
m_peak_allocated_size = std::max(m_peak_allocated_size, size);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -46,10 +46,10 @@ namespace ams::fssrv {
|
||||
void MemoryResourceFromStandardAllocator::DeallocateImpl(void *p, size_t size, size_t align) {
|
||||
AMS_UNUSED(size, align);
|
||||
|
||||
std::scoped_lock lk(this->mutex);
|
||||
std::scoped_lock lk(m_mutex);
|
||||
|
||||
this->current_free_size += this->allocator->GetSizeOf(p);
|
||||
this->allocator->Free(p);
|
||||
m_current_free_size += m_allocator->GetSizeOf(p);
|
||||
m_allocator->Free(p);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,15 +18,15 @@
|
||||
|
||||
namespace ams::fssrv::impl {
|
||||
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(fs::IStorage *storage) : base_storage(storage) {
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(fs::IStorage *storage) : m_base_storage(storage) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(std::unique_ptr<fs::IStorage> storage) : base_storage(storage.release()) {
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(std::unique_ptr<fs::IStorage> storage) : m_base_storage(storage.release()) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr<fs::IStorage> storage) : base_storage(std::move(storage)) {
|
||||
StorageInterfaceAdapter::StorageInterfaceAdapter(std::shared_ptr<fs::IStorage> storage) : m_base_storage(std::move(storage)) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ namespace ams::fssrv::impl {
|
||||
|
||||
util::optional<std::shared_lock<os::ReaderWriterLock>> StorageInterfaceAdapter::AcquireCacheInvalidationReadLock() {
|
||||
util::optional<std::shared_lock<os::ReaderWriterLock>> lock;
|
||||
if (this->deep_retry_enabled) {
|
||||
lock.emplace(this->invalidation_lock);
|
||||
if (m_deep_retry_enabled) {
|
||||
lock.emplace(m_invalidation_lock);
|
||||
}
|
||||
return lock;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ namespace ams::fssrv::impl {
|
||||
/* TODO: Deep retry */
|
||||
R_UNLESS(offset >= 0, fs::ResultInvalidOffset());
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
return this->base_storage->Read(offset, buffer.GetPointer(), size);
|
||||
return m_base_storage->Read(offset, buffer.GetPointer(), size);
|
||||
}
|
||||
|
||||
Result StorageInterfaceAdapter::Write(s64 offset, const ams::sf::InNonSecureBuffer &buffer, s64 size) {
|
||||
@@ -56,23 +56,23 @@ namespace ams::fssrv::impl {
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
return this->base_storage->Write(offset, buffer.GetPointer(), size);
|
||||
return m_base_storage->Write(offset, buffer.GetPointer(), size);
|
||||
}
|
||||
|
||||
Result StorageInterfaceAdapter::Flush() {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
return this->base_storage->Flush();
|
||||
return m_base_storage->Flush();
|
||||
}
|
||||
|
||||
Result StorageInterfaceAdapter::SetSize(s64 size) {
|
||||
R_UNLESS(size >= 0, fs::ResultInvalidSize());
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
return this->base_storage->SetSize(size);
|
||||
return m_base_storage->SetSize(size);
|
||||
}
|
||||
|
||||
Result StorageInterfaceAdapter::GetSize(ams::sf::Out<s64> out) {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
return this->base_storage->GetSize(out.GetPointer());
|
||||
return m_base_storage->GetSize(out.GetPointer());
|
||||
}
|
||||
|
||||
Result StorageInterfaceAdapter::OperateRange(ams::sf::Out<fs::StorageQueryRangeInfo> out, s32 op_id, s64 offset, s64 size) {
|
||||
@@ -84,7 +84,7 @@ namespace ams::fssrv::impl {
|
||||
auto read_lock = this->AcquireCacheInvalidationReadLock();
|
||||
|
||||
fs::StorageQueryRangeInfo info;
|
||||
R_TRY(this->base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
R_TRY(m_base_storage->OperateRange(std::addressof(info), sizeof(info), fs::OperationId::QueryRange, offset, size, nullptr, 0));
|
||||
out->Merge(info);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user