strat: use m_ for member variables

This commit is contained in:
Michael Scire
2021-10-10 00:14:06 -07:00
parent ce28591ab2
commit a595c232b9
425 changed files with 8531 additions and 8484 deletions

View File

@@ -56,13 +56,13 @@ namespace ams::fssystem::buffers {
class BufferManagerContext {
private:
bool needs_blocking;
bool m_needs_blocking;
public:
constexpr BufferManagerContext() : needs_blocking(false) { /* ... */ }
constexpr BufferManagerContext() : m_needs_blocking(false) { /* ... */ }
public:
bool IsNeedBlocking() const { return this->needs_blocking; }
bool IsNeedBlocking() const { return m_needs_blocking; }
void SetNeedBlocking(bool need) { this->needs_blocking = need; }
void SetNeedBlocking(bool need) { m_needs_blocking = need; }
};
void RegisterBufferManagerContext(const BufferManagerContext *context);
@@ -71,19 +71,19 @@ namespace ams::fssystem::buffers {
class ScopedBufferManagerContextRegistration {
private:
BufferManagerContext cur_context;
const BufferManagerContext *old_context;
BufferManagerContext m_cur_context;
const BufferManagerContext *m_old_context;
public:
ALWAYS_INLINE explicit ScopedBufferManagerContextRegistration() {
this->old_context = GetBufferManagerContext();
if (this->old_context != nullptr) {
this->cur_context = *this->old_context;
m_old_context = GetBufferManagerContext();
if (m_old_context != nullptr) {
m_cur_context = *m_old_context;
}
RegisterBufferManagerContext(std::addressof(this->cur_context));
RegisterBufferManagerContext(std::addressof(m_cur_context));
}
ALWAYS_INLINE ~ScopedBufferManagerContextRegistration() {
RegisterBufferManagerContext(this->old_context);
RegisterBufferManagerContext(m_old_context);
}
};

View File

@@ -37,31 +37,31 @@ namespace ams::fssystem {
NON_COPYABLE(PageList);
NON_MOVEABLE(PageList);
private:
PageEntry *first_page_entry;
PageEntry *last_page_entry;
s32 entry_count;
PageEntry *m_first_page_entry;
PageEntry *m_last_page_entry;
s32 m_entry_count;
public:
constexpr PageList() : first_page_entry(), last_page_entry(), entry_count() { /* ... */ }
constexpr PageList() : m_first_page_entry(), m_last_page_entry(), m_entry_count() { /* ... */ }
constexpr bool IsEmpty() const { return this->entry_count == 0; }
constexpr s32 GetSize() const { return this->entry_count; }
constexpr bool IsEmpty() const { return m_entry_count == 0; }
constexpr s32 GetSize() const { return m_entry_count; }
constexpr const PageEntry *GetFront() const { return this->first_page_entry; }
constexpr const PageEntry *GetFront() const { return m_first_page_entry; }
public:
PageEntry *PopFront();
void PushBack(PageEntry *page_entry);
bool Remove(PageEntry *page_entry);
};
private:
size_t block_size;
s32 order_max;
uintptr_t heap_start;
size_t heap_size;
size_t m_block_size;
s32 m_order_max;
uintptr_t m_heap_start;
size_t m_heap_size;
PageList *free_lists;
size_t total_free_size;
PageList *external_free_lists;
std::unique_ptr<PageList[]> internal_free_lists;
PageList *m_free_lists;
size_t m_total_free_size;
PageList *m_external_free_lists;
std::unique_ptr<PageList[]> m_internal_free_lists;
public:
static constexpr s32 GetBlockCountFromOrder(s32 order) {
AMS_ASSERT(0 <= order);
@@ -87,7 +87,7 @@ namespace ams::fssystem {
}
public:
constexpr FileSystemBuddyHeap() : block_size(), order_max(), heap_start(), heap_size(), free_lists(), total_free_size(), external_free_lists(), internal_free_lists() { /* ... */ }
constexpr FileSystemBuddyHeap() : m_block_size(), m_order_max(), m_heap_start(), m_heap_size(), m_free_lists(), m_total_free_size(), m_external_free_lists(), m_internal_free_lists() { /* ... */ }
Result Initialize(uintptr_t address, size_t size, size_t block_size, s32 order_max);
@@ -100,7 +100,7 @@ namespace ams::fssystem {
AMS_UNUSED(work_size);
const auto aligned_work = util::AlignUp(reinterpret_cast<uintptr_t>(work), alignof(PageList));
this->external_free_lists = reinterpret_cast<PageList *>(aligned_work);
m_external_free_lists = reinterpret_cast<PageList *>(aligned_work);
return this->Initialize(address, size, block_size, order_max);
}
@@ -118,34 +118,34 @@ namespace ams::fssystem {
void Dump() const;
s32 GetOrderFromBytes(size_t size) const {
AMS_ASSERT(this->free_lists != nullptr);
AMS_ASSERT(m_free_lists != nullptr);
return this->GetOrderFromBlockCount(this->GetBlockCountFromSize(size));
}
size_t GetBytesFromOrder(s32 order) const {
AMS_ASSERT(this->free_lists != nullptr);
AMS_ASSERT(m_free_lists != nullptr);
AMS_ASSERT(0 <= order);
AMS_ASSERT(order < this->GetOrderMax());
return (this->GetBlockSize() << order);
}
s32 GetOrderMax() const {
AMS_ASSERT(this->free_lists != nullptr);
return this->order_max;
AMS_ASSERT(m_free_lists != nullptr);
return m_order_max;
}
size_t GetBlockSize() const {
AMS_ASSERT(this->free_lists != nullptr);
return this->block_size;
AMS_ASSERT(m_free_lists != nullptr);
return m_block_size;
}
s32 GetPageBlockCountMax() const {
AMS_ASSERT(this->free_lists != nullptr);
AMS_ASSERT(m_free_lists != nullptr);
return 1 << this->GetOrderMax();
}
size_t GetPageSizeMax() const {
AMS_ASSERT(this->free_lists != nullptr);
AMS_ASSERT(m_free_lists != nullptr);
return this->GetPageBlockCountMax() * this->GetBlockSize();
}
private:
@@ -163,24 +163,24 @@ namespace ams::fssystem {
uintptr_t GetAddressFromPageEntry(const PageEntry &page_entry) const {
const uintptr_t address = reinterpret_cast<uintptr_t>(std::addressof(page_entry));
AMS_ASSERT(this->heap_start <= address);
AMS_ASSERT(address < this->heap_start + this->heap_size);
AMS_ASSERT(util::IsAligned(address - this->heap_start, this->GetBlockSize()));
AMS_ASSERT(m_heap_start <= address);
AMS_ASSERT(address < m_heap_start + m_heap_size);
AMS_ASSERT(util::IsAligned(address - m_heap_start, this->GetBlockSize()));
return address;
}
PageEntry *GetPageEntryFromAddress(uintptr_t address) const {
AMS_ASSERT(this->heap_start <= address);
AMS_ASSERT(address < this->heap_start + this->heap_size);
return reinterpret_cast<PageEntry *>(this->heap_start + util::AlignDown(address - this->heap_start, this->GetBlockSize()));
AMS_ASSERT(m_heap_start <= address);
AMS_ASSERT(address < m_heap_start + m_heap_size);
return reinterpret_cast<PageEntry *>(m_heap_start + util::AlignDown(address - m_heap_start, this->GetBlockSize()));
}
s32 GetIndexFromPageEntry(const PageEntry &page_entry) const {
const uintptr_t address = reinterpret_cast<uintptr_t>(std::addressof(page_entry));
AMS_ASSERT(this->heap_start <= address);
AMS_ASSERT(address < this->heap_start + this->heap_size);
AMS_ASSERT(util::IsAligned(address - this->heap_start, this->GetBlockSize()));
return static_cast<s32>((address - this->heap_start) / this->GetBlockSize());
AMS_ASSERT(m_heap_start <= address);
AMS_ASSERT(address < m_heap_start + m_heap_size);
AMS_ASSERT(util::IsAligned(address - m_heap_start, this->GetBlockSize()));
return static_cast<s32>((address - m_heap_start) / this->GetBlockSize());
}
bool IsAlignedToOrder(const PageEntry *page_entry, s32 order) const {

View File

@@ -34,32 +34,32 @@ namespace ams::fssystem {
private:
class Entry {
private:
CacheHandle handle;
uintptr_t address;
size_t size;
BufferAttribute attr;
CacheHandle m_handle;
uintptr_t m_address;
size_t m_size;
BufferAttribute m_attr;
public:
constexpr void Initialize(CacheHandle h, uintptr_t a, size_t sz, BufferAttribute t) {
this->handle = h;
this->address = a;
this->size = sz;
this->attr = t;
m_handle = h;
m_address = a;
m_size = sz;
m_attr = t;
}
constexpr CacheHandle GetHandle() const {
return this->handle;
return m_handle;
}
constexpr uintptr_t GetAddress() const {
return this->address;
return m_address;
}
constexpr size_t GetSize() const {
return this->size;
return m_size;
}
constexpr BufferAttribute GetBufferAttribute() const {
return this->attr;
return m_attr;
}
};
@@ -67,41 +67,41 @@ namespace ams::fssystem {
NON_COPYABLE(AttrInfo);
NON_MOVEABLE(AttrInfo);
private:
s32 level;
s32 cache_count;
size_t cache_size;
s32 m_level;
s32 m_cache_count;
size_t m_cache_size;
public:
constexpr AttrInfo(s32 l, s32 cc, size_t cs) : level(l), cache_count(cc), cache_size(cs) {
constexpr AttrInfo(s32 l, s32 cc, size_t cs) : m_level(l), m_cache_count(cc), m_cache_size(cs) {
/* ... */
}
constexpr s32 GetLevel() const {
return this->level;
return m_level;
}
constexpr s32 GetCacheCount() const {
return this->cache_count;
return m_cache_count;
}
constexpr void IncrementCacheCount() {
++this->cache_count;
++m_cache_count;
}
constexpr void DecrementCacheCount() {
--this->cache_count;
--m_cache_count;
}
constexpr size_t GetCacheSize() const {
return this->cache_size;
return m_cache_size;
}
constexpr void AddCacheSize(size_t diff) {
this->cache_size += diff;
m_cache_size += diff;
}
constexpr void SubtractCacheSize(size_t diff) {
AMS_ASSERT(this->cache_size >= diff);
this->cache_size -= diff;
AMS_ASSERT(m_cache_size >= diff);
m_cache_size -= diff;
}
using Newable::operator new;
@@ -114,19 +114,19 @@ namespace ams::fssystem {
using AttrListTraits = util::IntrusiveListBaseTraits<AttrInfo>;
using AttrList = typename AttrListTraits::ListType;
private:
std::unique_ptr<char[], ::ams::fs::impl::Deleter> internal_entry_buffer;
char *external_entry_buffer;
size_t entry_buffer_size;
Entry *entries;
s32 entry_count;
s32 entry_count_max;
AttrList attr_list;
char *external_attr_info_buffer;
s32 external_attr_info_count;
s32 cache_count_min;
size_t cache_size_min;
size_t total_cache_size;
CacheHandle current_handle;
std::unique_ptr<char[], ::ams::fs::impl::Deleter> m_internal_entry_buffer;
char *m_external_entry_buffer;
size_t m_entry_buffer_size;
Entry *m_entries;
s32 m_entry_count;
s32 m_entry_count_max;
AttrList m_attr_list;
char *m_external_attr_info_buffer;
s32 m_external_attr_info_count;
s32 m_cache_count_min;
size_t m_cache_size_min;
size_t m_total_cache_size;
CacheHandle m_current_handle;
public:
static constexpr size_t QueryWorkBufferSize(s32 max_cache_count) {
AMS_ASSERT(max_cache_count > 0);
@@ -135,7 +135,7 @@ namespace ams::fssystem {
return util::AlignUp(entry_size + attr_list_size + alignof(Entry) + alignof(AttrInfo), 8);
}
public:
CacheHandleTable() : internal_entry_buffer(), external_entry_buffer(), entry_buffer_size(), entries(), entry_count(), entry_count_max(), attr_list(), external_attr_info_buffer(), external_attr_info_count(), cache_count_min(), cache_size_min(), total_cache_size(), current_handle() {
CacheHandleTable() : m_internal_entry_buffer(), m_external_entry_buffer(), m_entry_buffer_size(), m_entries(), m_entry_count(), m_entry_count_max(), m_attr_list(), m_external_attr_info_buffer(), m_external_attr_info_count(), m_cache_count_min(), m_cache_size_min(), m_total_cache_size(), m_current_handle() {
/* ... */
}
@@ -146,13 +146,13 @@ namespace ams::fssystem {
Result Initialize(s32 max_cache_count);
Result Initialize(s32 max_cache_count, void *work, size_t work_size) {
const auto aligned_entry_buf = util::AlignUp(reinterpret_cast<uintptr_t>(work), alignof(Entry));
this->external_entry_buffer = reinterpret_cast<char *>(aligned_entry_buf);
this->entry_buffer_size = sizeof(Entry) * max_cache_count;
m_external_entry_buffer = reinterpret_cast<char *>(aligned_entry_buf);
m_entry_buffer_size = sizeof(Entry) * max_cache_count;
const auto aligned_attr_info_buf = util::AlignUp(reinterpret_cast<uintptr_t>(this->external_entry_buffer + this->entry_buffer_size), alignof(AttrInfo));
const auto aligned_attr_info_buf = util::AlignUp(reinterpret_cast<uintptr_t>(m_external_entry_buffer + m_entry_buffer_size), alignof(AttrInfo));
const auto work_end = reinterpret_cast<uintptr_t>(work) + work_size;
this->external_attr_info_buffer = reinterpret_cast<char *>(aligned_attr_info_buf);
this->external_attr_info_count = static_cast<s32>((work_end - aligned_attr_info_buf) / sizeof(AttrInfo));
m_external_attr_info_buffer = reinterpret_cast<char *>(aligned_attr_info_buf);
m_external_attr_info_count = static_cast<s32>((work_end - aligned_attr_info_buf) / sizeof(AttrInfo));
return ResultSuccess();
}
@@ -179,22 +179,22 @@ namespace ams::fssystem {
s32 GetCacheCountMin(const BufferAttribute &attr) {
AMS_UNUSED(attr);
return this->cache_count_min;
return m_cache_count_min;
}
size_t GetCacheSizeMin(const BufferAttribute &attr) {
AMS_UNUSED(attr);
return this->cache_size_min;
return m_cache_size_min;
}
};
private:
BuddyHeap buddy_heap;
CacheHandleTable cache_handle_table;
size_t total_size;
size_t peak_free_size;
size_t peak_total_allocatable_size;
size_t retried_count;
mutable os::SdkRecursiveMutex mutex;
BuddyHeap m_buddy_heap;
CacheHandleTable m_cache_handle_table;
size_t m_total_size;
size_t m_peak_free_size;
size_t m_peak_total_allocatable_size;
size_t m_retried_count;
mutable os::SdkRecursiveMutex m_mutex;
public:
static constexpr size_t QueryWorkBufferSize(s32 max_cache_count, s32 max_order) {
const auto buddy_size = FileSystemBuddyHeap::QueryWorkBufferSize(max_order);
@@ -202,30 +202,30 @@ namespace ams::fssystem {
return buddy_size + table_size;
}
public:
FileSystemBufferManager() : total_size(), peak_free_size(), peak_total_allocatable_size(), retried_count(), mutex() { /* ... */ }
FileSystemBufferManager() : m_total_size(), m_peak_free_size(), m_peak_total_allocatable_size(), m_retried_count(), m_mutex() { /* ... */ }
virtual ~FileSystemBufferManager() { /* ... */ }
Result Initialize(s32 max_cache_count, uintptr_t address, size_t buffer_size, size_t block_size) {
AMS_ASSERT(buffer_size > 0);
R_TRY(this->cache_handle_table.Initialize(max_cache_count));
R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size));
R_TRY(m_cache_handle_table.Initialize(max_cache_count));
R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size));
this->total_size = this->buddy_heap.GetTotalFreeSize();
this->peak_free_size = this->total_size;
this->peak_total_allocatable_size = this->total_size;
m_total_size = m_buddy_heap.GetTotalFreeSize();
m_peak_free_size = m_total_size;
m_peak_total_allocatable_size = m_total_size;
return ResultSuccess();
}
Result Initialize(s32 max_cache_count, uintptr_t address, size_t buffer_size, size_t block_size, s32 max_order) {
AMS_ASSERT(buffer_size > 0);
R_TRY(this->cache_handle_table.Initialize(max_cache_count));
R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, max_order));
R_TRY(m_cache_handle_table.Initialize(max_cache_count));
R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, max_order));
this->total_size = this->buddy_heap.GetTotalFreeSize();
this->peak_free_size = this->total_size;
this->peak_total_allocatable_size = this->total_size;
m_total_size = m_buddy_heap.GetTotalFreeSize();
m_peak_free_size = m_total_size;
m_peak_total_allocatable_size = m_total_size;
return ResultSuccess();
}
@@ -237,12 +237,12 @@ namespace ams::fssystem {
const auto table_buffer = static_cast<char *>(work);
const auto buddy_buffer = table_buffer + table_size;
R_TRY(this->cache_handle_table.Initialize(max_cache_count, table_buffer, table_size));
R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, buddy_buffer, buddy_size));
R_TRY(m_cache_handle_table.Initialize(max_cache_count, table_buffer, table_size));
R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, buddy_buffer, buddy_size));
this->total_size = this->buddy_heap.GetTotalFreeSize();
this->peak_free_size = this->total_size;
this->peak_total_allocatable_size = this->total_size;
m_total_size = m_buddy_heap.GetTotalFreeSize();
m_peak_free_size = m_total_size;
m_peak_total_allocatable_size = m_total_size;
return ResultSuccess();
}
@@ -254,19 +254,19 @@ namespace ams::fssystem {
const auto table_buffer = static_cast<char *>(work);
const auto buddy_buffer = table_buffer + table_size;
R_TRY(this->cache_handle_table.Initialize(max_cache_count, table_buffer, table_size));
R_TRY(this->buddy_heap.Initialize(address, buffer_size, block_size, max_order, buddy_buffer, buddy_size));
R_TRY(m_cache_handle_table.Initialize(max_cache_count, table_buffer, table_size));
R_TRY(m_buddy_heap.Initialize(address, buffer_size, block_size, max_order, buddy_buffer, buddy_size));
this->total_size = this->buddy_heap.GetTotalFreeSize();
this->peak_free_size = this->total_size;
this->peak_total_allocatable_size = this->total_size;
m_total_size = m_buddy_heap.GetTotalFreeSize();
m_peak_free_size = m_total_size;
m_peak_total_allocatable_size = m_total_size;
return ResultSuccess();
}
void Finalize() {
this->buddy_heap.Finalize();
this->cache_handle_table.Finalize();
m_buddy_heap.Finalize();
m_cache_handle_table.Finalize();
}
private:
virtual const std::pair<uintptr_t, size_t> AllocateBufferImpl(size_t size, const BufferAttribute &attr) override;

View File

@@ -22,12 +22,12 @@ namespace ams::fssystem {
public:
class BufferAttribute {
private:
s32 level;
s32 m_level;
public:
constexpr BufferAttribute() : level(0) { /* ... */ }
constexpr explicit BufferAttribute(s32 l) : level(l) { /* ... */ }
constexpr BufferAttribute() : m_level(0) { /* ... */ }
constexpr explicit BufferAttribute(s32 l) : m_level(l) { /* ... */ }
constexpr s32 GetLevel() const { return this->level; }
constexpr s32 GetLevel() const { return m_level; }
};
using CacheHandle = s64;

View File

@@ -74,27 +74,27 @@ namespace ams::fssystem {
static Result CreateExternalDecryptor(std::unique_ptr<IDecryptor> *out, DecryptFunction func, s32 key_index);
static Result CreateSoftwareDecryptor(std::unique_ptr<IDecryptor> *out);
private:
BucketTree table;
fs::SubStorage data_storage;
u8 key[KeySize];
u32 secure_value;
s64 counter_offset;
std::unique_ptr<IDecryptor> decryptor;
BucketTree m_table;
fs::SubStorage m_data_storage;
u8 m_key[KeySize];
u32 m_secure_value;
s64 m_counter_offset;
std::unique_ptr<IDecryptor> m_decryptor;
public:
AesCtrCounterExtendedStorage() : table(), data_storage(), secure_value(), counter_offset(), decryptor() { /* ... */ }
AesCtrCounterExtendedStorage() : m_table(), m_data_storage(), m_secure_value(), m_counter_offset(), m_decryptor() { /* ... */ }
virtual ~AesCtrCounterExtendedStorage() { this->Finalize(); }
Result Initialize(IAllocator *allocator, const void *key, size_t key_size, u32 secure_value, s64 counter_offset, fs::SubStorage data_storage, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count, std::unique_ptr<IDecryptor> &&decryptor);
void Finalize();
bool IsInitialized() const { return this->table.IsInitialized(); }
bool IsInitialized() const { return m_table.IsInitialized(); }
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override;
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
*out = this->table.GetSize();
*out = m_table.GetSize();
return ResultSuccess();
}

View File

@@ -28,9 +28,9 @@ namespace ams::fssystem {
static constexpr size_t KeySize = crypto::Aes128CtrEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128CtrEncryptor::IvSize;
private:
IStorage * const base_storage;
char key[KeySize];
char iv[IvSize];
IStorage * const m_base_storage;
char m_key[KeySize];
char m_iv[IvSize];
public:
static void MakeIv(void *dst, size_t dst_size, u64 upper, s64 offset);
public:

View File

@@ -29,11 +29,11 @@ namespace ams::fssystem {
static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize;
private:
IStorage * const base_storage;
char key[2][KeySize];
char iv[IvSize];
const size_t block_size;
os::SdkMutex mutex;
IStorage * const m_base_storage;
char m_key[2][KeySize];
char m_iv[IvSize];
const size_t m_block_size;
os::SdkMutex m_mutex;
public:
AesXtsStorage(IStorage *base, const void *key1, const void *key2, size_t key_size, const void *iv, size_t iv_size, size_t block_size);

View File

@@ -35,16 +35,16 @@ namespace ams::fssystem {
static_assert(util::IsPowerOfTwo(DataAlign));
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
std::shared_ptr<fs::IStorage> shared_base_storage;
fs::IStorage * const base_storage;
s64 base_storage_size;
bool is_base_storage_size_dirty;
std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const m_base_storage;
s64 m_base_storage_size;
bool m_is_base_storage_size_dirty;
public:
explicit AlignmentMatchingStorage(fs::IStorage *bs) : base_storage(bs), is_base_storage_size_dirty(true) {
explicit AlignmentMatchingStorage(fs::IStorage *bs) : m_base_storage(bs), m_is_base_storage_size_dirty(true) {
/* ... */
}
explicit AlignmentMatchingStorage(std::shared_ptr<fs::IStorage> bs) : shared_base_storage(bs), base_storage(shared_base_storage.get()), is_base_storage_size_dirty(true) {
explicit AlignmentMatchingStorage(std::shared_ptr<fs::IStorage> bs) : m_shared_base_storage(bs), m_base_storage(m_shared_base_storage.get()), m_is_base_storage_size_dirty(true) {
/* ... */
}
@@ -63,7 +63,7 @@ namespace ams::fssystem {
R_TRY(this->GetSize(std::addressof(bs_size)));
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange());
return AlignmentMatchingStorageImpl::Read(this->base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<char *>(buffer), size);
return AlignmentMatchingStorageImpl::Read(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<char *>(buffer), size);
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
@@ -81,30 +81,30 @@ namespace ams::fssystem {
R_TRY(this->GetSize(std::addressof(bs_size)));
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange());
return AlignmentMatchingStorageImpl::Write(this->base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<const char *>(buffer), size);
return AlignmentMatchingStorageImpl::Write(m_base_storage, work_buf, sizeof(work_buf), DataAlign, BufferAlign, offset, static_cast<const char *>(buffer), size);
}
virtual Result Flush() override {
return this->base_storage->Flush();
return m_base_storage->Flush();
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; };
return this->base_storage->SetSize(util::AlignUp(size, DataAlign));
ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
return m_base_storage->SetSize(util::AlignUp(size, DataAlign));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (this->is_base_storage_size_dirty) {
if (m_is_base_storage_size_dirty) {
s64 size;
R_TRY(this->base_storage->GetSize(std::addressof(size)));
R_TRY(m_base_storage->GetSize(std::addressof(size)));
this->base_storage_size = size;
this->is_base_storage_size_dirty = false;
m_base_storage_size = size;
m_is_base_storage_size_dirty = false;
}
*out = this->base_storage_size;
*out = m_base_storage_size;
return ResultSuccess();
}
@@ -123,7 +123,7 @@ namespace ams::fssystem {
const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign);
const auto aligned_size = aligned_offset_end - aligned_offset;
return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
}
};
@@ -136,12 +136,12 @@ namespace ams::fssystem {
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
fs::IStorage * const base_storage;
s64 base_storage_size;
size_t data_align;
bool is_base_storage_size_dirty;
fs::IStorage * const m_base_storage;
s64 m_base_storage_size;
size_t m_data_align;
bool m_is_base_storage_size_dirty;
public:
explicit AlignmentMatchingStoragePooledBuffer(fs::IStorage *bs, size_t da) : base_storage(bs), data_align(da), is_base_storage_size_dirty(true) {
explicit AlignmentMatchingStoragePooledBuffer(fs::IStorage *bs, size_t da) : m_base_storage(bs), m_data_align(da), m_is_base_storage_size_dirty(true) {
AMS_ASSERT(util::IsPowerOfTwo(da));
}
@@ -158,9 +158,9 @@ namespace ams::fssystem {
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer;
pooled_buffer.AllocateParticularlyLarge(this->data_align, this->data_align);
pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align);
return AlignmentMatchingStorageImpl::Read(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast<char *>(buffer), size);
return AlignmentMatchingStorageImpl::Read(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<char *>(buffer), size);
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
@@ -176,32 +176,32 @@ namespace ams::fssystem {
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer;
pooled_buffer.AllocateParticularlyLarge(this->data_align, this->data_align);
pooled_buffer.AllocateParticularlyLarge(m_data_align, m_data_align);
return AlignmentMatchingStorageImpl::Write(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast<const char *>(buffer), size);
return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<const char *>(buffer), size);
}
virtual Result Flush() override {
return this->base_storage->Flush();
return m_base_storage->Flush();
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; };
return this->base_storage->SetSize(util::AlignUp(size, this->data_align));
ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
return m_base_storage->SetSize(util::AlignUp(size, m_data_align));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (this->is_base_storage_size_dirty) {
if (m_is_base_storage_size_dirty) {
s64 size;
R_TRY(this->base_storage->GetSize(std::addressof(size)));
R_TRY(m_base_storage->GetSize(std::addressof(size)));
this->base_storage_size = size;
this->is_base_storage_size_dirty = false;
m_base_storage_size = size;
m_is_base_storage_size_dirty = false;
}
*out = this->base_storage_size;
*out = m_base_storage_size;
return ResultSuccess();
}
@@ -216,11 +216,11 @@ namespace ams::fssystem {
/* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, this->data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align);
const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset;
return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
}
};
@@ -233,16 +233,16 @@ namespace ams::fssystem {
static_assert(util::IsPowerOfTwo(BufferAlign));
private:
std::shared_ptr<fs::IStorage> shared_base_storage;
fs::IStorage * const base_storage;
s64 base_storage_size;
size_t data_align;
std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const m_base_storage;
s64 m_base_storage_size;
size_t m_data_align;
public:
explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : shared_base_storage(), base_storage(bs), base_storage_size(-1), data_align(da) {
AMS_ASSERT(util::IsPowerOfTwo(this->data_align));
explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : m_shared_base_storage(), m_base_storage(bs), m_base_storage_size(-1), m_data_align(da) {
AMS_ASSERT(util::IsPowerOfTwo(m_data_align));
}
explicit AlignmentMatchingStorageInBulkRead(std::shared_ptr<fs::IStorage> bs, size_t da) : shared_base_storage(bs), base_storage(shared_base_storage.get()), base_storage_size(-1), data_align(da) {
explicit AlignmentMatchingStorageInBulkRead(std::shared_ptr<fs::IStorage> bs, size_t da) : m_shared_base_storage(bs), m_base_storage(m_shared_base_storage.get()), m_base_storage_size(-1), m_data_align(da) {
AMS_ASSERT(util::IsPowerOfTwo(da));
}
@@ -260,30 +260,30 @@ namespace ams::fssystem {
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange());
/* Allocate a pooled buffer. */
PooledBuffer pooled_buffer(this->data_align, this->data_align);
return AlignmentMatchingStorageImpl::Write(this->base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), this->data_align, BufferAlign, offset, static_cast<const char *>(buffer), size);
PooledBuffer pooled_buffer(m_data_align, m_data_align);
return AlignmentMatchingStorageImpl::Write(m_base_storage, pooled_buffer.GetBuffer(), pooled_buffer.GetSize(), m_data_align, BufferAlign, offset, static_cast<const char *>(buffer), size);
}
virtual Result Flush() override {
return this->base_storage->Flush();
return m_base_storage->Flush();
}
virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->base_storage_size = -1; };
return this->base_storage->SetSize(util::AlignUp(size, this->data_align));
ON_SCOPE_EXIT { m_base_storage_size = -1; };
return m_base_storage->SetSize(util::AlignUp(size, m_data_align));
}
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
if (this->base_storage_size < 0) {
if (m_base_storage_size < 0) {
s64 size;
R_TRY(this->base_storage->GetSize(std::addressof(size)));
R_TRY(m_base_storage->GetSize(std::addressof(size)));
this->base_storage_size = size;
m_base_storage_size = size;
}
*out = this->base_storage_size;
*out = m_base_storage_size;
return ResultSuccess();
}
@@ -298,11 +298,11 @@ namespace ams::fssystem {
/* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, this->data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align);
const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset;
return this->base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
return m_base_storage->OperateRange(dst, dst_size, op_id, aligned_offset, aligned_size, src, src_size);
}
};

View File

@@ -55,24 +55,24 @@ namespace ams::fssystem {
class ContinuousReadingInfo {
private:
size_t read_size;
s32 skip_count;
bool done;
size_t m_read_size;
s32 m_skip_count;
bool m_done;
public:
constexpr ContinuousReadingInfo() : read_size(), skip_count(), done() { /* ... */ }
constexpr ContinuousReadingInfo() : m_read_size(), m_skip_count(), m_done() { /* ... */ }
constexpr void Reset() { this->read_size = 0; this->skip_count = 0; this->done = false; }
constexpr void Reset() { m_read_size = 0; m_skip_count = 0; m_done = false; }
constexpr void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); this->skip_count = count; }
constexpr s32 GetSkipCount() const { return this->skip_count; }
constexpr bool CheckNeedScan() { return (--this->skip_count) <= 0; }
constexpr void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); m_skip_count = count; }
constexpr s32 GetSkipCount() const { return m_skip_count; }
constexpr bool CheckNeedScan() { return (--m_skip_count) <= 0; }
constexpr void Done() { this->read_size = 0; this->done = true; }
constexpr bool IsDone() const { return this->done; }
constexpr void Done() { m_read_size = 0; m_done = true; }
constexpr bool IsDone() const { return m_done; }
constexpr void SetReadSize(size_t size) { this->read_size = size; }
constexpr size_t GetReadSize() const { return this->read_size; }
constexpr bool CanDo() const { return this->read_size > 0; }
constexpr void SetReadSize(size_t size) { m_read_size = size; }
constexpr size_t GetReadSize() const { return m_read_size; }
constexpr bool CanDo() const { return m_read_size > 0; }
};
using IAllocator = MemoryResource;
@@ -80,60 +80,60 @@ namespace ams::fssystem {
class NodeBuffer {
NON_COPYABLE(NodeBuffer);
private:
IAllocator *allocator;
void *header;
IAllocator *m_allocator;
void *m_header;
public:
NodeBuffer() : allocator(), header() { /* ... */ }
NodeBuffer() : m_allocator(), m_header() { /* ... */ }
~NodeBuffer() {
AMS_ASSERT(this->header == nullptr);
AMS_ASSERT(m_header == nullptr);
}
NodeBuffer(NodeBuffer &&rhs) : allocator(rhs.allocator), header(rhs.allocator) {
rhs.allocator = nullptr;
rhs.header = nullptr;
NodeBuffer(NodeBuffer &&rhs) : m_allocator(rhs.m_allocator), m_header(rhs.m_allocator) {
rhs.m_allocator = nullptr;
rhs.m_header = nullptr;
}
NodeBuffer &operator=(NodeBuffer &&rhs) {
if (this != std::addressof(rhs)) {
AMS_ASSERT(this->header == nullptr);
AMS_ASSERT(m_header == nullptr);
this->allocator = rhs.allocator;
this->header = rhs.header;
m_allocator = rhs.m_allocator;
m_header = rhs.m_header;
rhs.allocator = nullptr;
rhs.header = nullptr;
rhs.m_allocator = nullptr;
rhs.m_header = nullptr;
}
return *this;
}
bool Allocate(IAllocator *allocator, size_t node_size) {
AMS_ASSERT(this->header == nullptr);
AMS_ASSERT(m_header == nullptr);
this->allocator = allocator;
this->header = allocator->Allocate(node_size, sizeof(s64));
m_allocator = allocator;
m_header = allocator->Allocate(node_size, sizeof(s64));
AMS_ASSERT(util::IsAligned(this->header, sizeof(s64)));
AMS_ASSERT(util::IsAligned(m_header, sizeof(s64)));
return this->header != nullptr;
return m_header != nullptr;
}
void Free(size_t node_size) {
if (this->header) {
this->allocator->Deallocate(this->header, node_size);
this->header = nullptr;
if (m_header) {
m_allocator->Deallocate(m_header, node_size);
m_header = nullptr;
}
this->allocator = nullptr;
m_allocator = nullptr;
}
void FillZero(size_t node_size) const {
if (this->header) {
std::memset(this->header, 0, node_size);
if (m_header) {
std::memset(m_header, 0, node_size);
}
}
NodeHeader *Get() const {
return reinterpret_cast<NodeHeader *>(this->header);
return reinterpret_cast<NodeHeader *>(m_header);
}
NodeHeader *operator->() const { return this->Get(); }
@@ -142,11 +142,11 @@ namespace ams::fssystem {
T *Get() const {
static_assert(util::is_pod<T>::value);
static_assert(sizeof(T) == sizeof(NodeHeader));
return reinterpret_cast<T *>(this->header);
return reinterpret_cast<T *>(m_header);
}
IAllocator *GetAllocator() const {
return this->allocator;
return m_allocator;
}
};
private:
@@ -205,43 +205,43 @@ namespace ams::fssystem {
return GetEntrySetCount(node_size, entry_size, entry_count) * static_cast<s64>(node_size);
}
private:
mutable fs::SubStorage node_storage;
mutable fs::SubStorage entry_storage;
NodeBuffer node_l1;
size_t node_size;
size_t entry_size;
s32 entry_count;
s32 offset_count;
s32 entry_set_count;
s64 start_offset;
s64 end_offset;
mutable fs::SubStorage m_node_storage;
mutable fs::SubStorage m_entry_storage;
NodeBuffer m_node_l1;
size_t m_node_size;
size_t m_entry_size;
s32 m_entry_count;
s32 m_offset_count;
s32 m_entry_set_count;
s64 m_start_offset;
s64 m_end_offset;
public:
BucketTree() : node_storage(), entry_storage(), node_l1(), node_size(), entry_size(), entry_count(), offset_count(), entry_set_count(), start_offset(), end_offset() { /* ... */ }
BucketTree() : m_node_storage(), m_entry_storage(), m_node_l1(), m_node_size(), m_entry_size(), m_entry_count(), m_offset_count(), m_entry_set_count(), m_start_offset(), m_end_offset() { /* ... */ }
~BucketTree() { this->Finalize(); }
Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, size_t node_size, size_t entry_size, s32 entry_count);
void Initialize(size_t node_size, s64 end_offset);
void Finalize();
bool IsInitialized() const { return this->node_size > 0; }
bool IsEmpty() const { return this->entry_size == 0; }
bool IsInitialized() const { return m_node_size > 0; }
bool IsEmpty() const { return m_entry_size == 0; }
Result Find(Visitor *visitor, s64 virtual_address) const;
Result InvalidateCache();
s32 GetEntryCount() const { return this->entry_count; }
IAllocator *GetAllocator() const { return this->node_l1.GetAllocator(); }
s32 GetEntryCount() const { return m_entry_count; }
IAllocator *GetAllocator() const { return m_node_l1.GetAllocator(); }
s64 GetStart() const { return this->start_offset; }
s64 GetEnd() const { return this->end_offset; }
s64 GetSize() const { return this->end_offset - this->start_offset; }
s64 GetStart() const { return m_start_offset; }
s64 GetEnd() const { return m_end_offset; }
s64 GetSize() const { return m_end_offset - m_start_offset; }
bool Includes(s64 offset) const {
return this->start_offset <= offset && offset < this->end_offset;
return m_start_offset <= offset && offset < m_end_offset;
}
bool Includes(s64 offset, s64 size) const {
return size > 0 && this->start_offset <= offset && size <= this->end_offset - offset;
return size > 0 && m_start_offset <= offset && size <= m_end_offset - offset;
}
private:
template<typename EntryType>
@@ -256,11 +256,11 @@ namespace ams::fssystem {
template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam<EntryType> &param) const;
bool IsExistL2() const { return this->offset_count < this->entry_set_count; }
bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && this->node_l1->count < this->offset_count; }
bool IsExistL2() const { return m_offset_count < m_entry_set_count; }
bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && m_node_l1->count < m_offset_count; }
s64 GetEntrySetIndex(s32 node_index, s32 offset_index) const {
return (this->offset_count - this->node_l1->count) + (this->offset_count * node_index) + offset_index;
return (m_offset_count - m_node_l1->count) + (m_offset_count * node_index) + offset_index;
}
};
@@ -282,24 +282,24 @@ namespace ams::fssystem {
};
static_assert(util::is_pod<EntrySetHeader>::value);
private:
const BucketTree *tree;
void *entry;
s32 entry_index;
s32 entry_set_count;
EntrySetHeader entry_set;
const BucketTree *m_tree;
void *m_entry;
s32 m_entry_index;
s32 m_entry_set_count;
EntrySetHeader m_entry_set;
public:
constexpr Visitor() : tree(), entry(), entry_index(-1), entry_set_count(), entry_set{} { /* ... */ }
constexpr Visitor() : m_tree(), m_entry(), m_entry_index(-1), m_entry_set_count(), m_entry_set{} { /* ... */ }
~Visitor() {
if (this->entry != nullptr) {
this->tree->GetAllocator()->Deallocate(this->entry, this->tree->entry_size);
this->tree = nullptr;
this->entry = nullptr;
if (m_entry != nullptr) {
m_tree->GetAllocator()->Deallocate(m_entry, m_tree->m_entry_size);
m_tree = nullptr;
m_entry = nullptr;
}
}
bool IsValid() const { return this->entry_index >= 0; }
bool CanMoveNext() const { return this->IsValid() && (this->entry_index + 1 < this->entry_set.info.count || this->entry_set.info.index + 1 < this->entry_set_count); }
bool CanMovePrevious() const { return this->IsValid() && (this->entry_index > 0 || this->entry_set.info.index > 0); }
bool IsValid() const { return m_entry_index >= 0; }
bool CanMoveNext() const { return this->IsValid() && (m_entry_index + 1 < m_entry_set.info.count || m_entry_set.info.index + 1 < m_entry_set_count); }
bool CanMovePrevious() const { return this->IsValid() && (m_entry_index > 0 || m_entry_set.info.index > 0); }
Result MoveNext();
Result MovePrevious();
@@ -307,12 +307,12 @@ namespace ams::fssystem {
template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, s64 offset, size_t size) const;
const void *Get() const { AMS_ASSERT(this->IsValid()); return this->entry; }
const void *Get() const { AMS_ASSERT(this->IsValid()); return m_entry; }
template<typename T>
const T *Get() const { AMS_ASSERT(this->IsValid()); return reinterpret_cast<const T *>(this->entry); }
const T *Get() const { AMS_ASSERT(this->IsValid()); return reinterpret_cast<const T *>(m_entry); }
const BucketTree *GetTree() const { return this->tree; }
const BucketTree *GetTree() const { return m_tree; }
private:
Result Initialize(const BucketTree *tree);

View File

@@ -27,7 +27,7 @@ namespace ams::fssystem {
/* Validate our preconditions. */
AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(out_info != nullptr);
AMS_ASSERT(this->entry_size == sizeof(EntryType));
AMS_ASSERT(m_entry_size == sizeof(EntryType));
/* Reset the output. */
out_info->Reset();
@@ -44,14 +44,14 @@ namespace ams::fssystem {
R_UNLESS(entry.GetVirtualOffset() <= cur_offset, fs::ResultOutOfRange());
/* Create a pooled buffer for our scan. */
PooledBuffer pool(this->node_size, 1);
PooledBuffer pool(m_node_size, 1);
char *buffer = nullptr;
/* Read the node. */
if (this->node_size <= pool.GetSize()) {
if (m_node_size <= pool.GetSize()) {
buffer = pool.GetBuffer();
const auto ofs = param.entry_set.index * static_cast<s64>(this->node_size);
R_TRY(this->entry_storage.Read(ofs, buffer, this->node_size));
const auto ofs = param.entry_set.index * static_cast<s64>(m_node_size);
R_TRY(m_entry_storage.Read(ofs, buffer, m_node_size));
}
/* Calculate extents. */
@@ -81,11 +81,11 @@ namespace ams::fssystem {
if (entry_index + 1 < entry_count) {
if (buffer != nullptr) {
const auto ofs = impl::GetBucketTreeEntryOffset(0, this->entry_size, entry_index + 1);
std::memcpy(std::addressof(next_entry), buffer + ofs, this->entry_size);
const auto ofs = impl::GetBucketTreeEntryOffset(0, m_entry_size, entry_index + 1);
std::memcpy(std::addressof(next_entry), buffer + ofs, m_entry_size);
} else {
const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, this->node_size, this->entry_size, entry_index + 1);
R_TRY(this->entry_storage.Read(ofs, std::addressof(next_entry), this->entry_size));
const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, m_node_size, m_entry_size, entry_index + 1);
R_TRY(m_entry_storage.Read(ofs, std::addressof(next_entry), m_entry_size));
}
next_entry_offset = next_entry.GetVirtualOffset();
@@ -154,12 +154,12 @@ namespace ams::fssystem {
/* Create our parameters. */
ContinuousReadingParam<EntryType> param = {
offset, size, this->entry_set.header, this->entry_index
offset, size, m_entry_set.header, m_entry_index
};
std::memcpy(std::addressof(param.entry), this->entry, sizeof(EntryType));
std::memcpy(std::addressof(param.entry), m_entry, sizeof(EntryType));
/* Scan. */
return this->tree->ScanContinuousReading<EntryType>(out_info, param);
return m_tree->ScanContinuousReading<EntryType>(out_info, param);
}
}

View File

@@ -24,10 +24,10 @@ namespace ams::fssystem {
using PathResolutionFileSystem = impl::IPathResolutionFileSystem<DirectoryRedirectionFileSystem>;
friend class impl::IPathResolutionFileSystem<DirectoryRedirectionFileSystem>;
private:
char *before_dir;
size_t before_dir_len;
char *after_dir;
size_t after_dir_len;
char *m_before_dir;
size_t m_before_dir_len;
char *m_after_dir;
size_t m_after_dir_len;
public:
DirectoryRedirectionFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, const char *before, const char *after, bool unc = false);
DirectoryRedirectionFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, const char *before, const char *after, bool unc = false);

View File

@@ -24,8 +24,8 @@ namespace ams::fssystem {
using PathResolutionFileSystem = impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
friend class impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
private:
os::SdkMutex accessor_mutex;
s32 open_writable_files;
os::SdkMutex m_accessor_mutex;
s32 m_open_writable_files;
public:
DirectorySaveDataFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs);
DirectorySaveDataFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs);
@@ -35,7 +35,7 @@ namespace ams::fssystem {
protected:
inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() {
/* We have a real accessor lock that we want to use. */
return util::make_optional<std::scoped_lock<os::SdkMutex>>(this->accessor_mutex);
return util::make_optional<std::scoped_lock<os::SdkMutex>>(m_accessor_mutex);
}
private:
Result AllocateWorkBuffer(std::unique_ptr<u8[]> *out, size_t *out_size, size_t ideal_size);

View File

@@ -100,30 +100,30 @@ namespace ams::fssystem {
return BucketTree::QueryEntryStorageSize(NodeSize, sizeof(Entry), entry_count);
}
private:
BucketTree table;
fs::SubStorage data_storage[StorageCount];
BucketTree m_table;
fs::SubStorage m_data_storage[StorageCount];
public:
IndirectStorage() : table(), data_storage() { /* ... */ }
IndirectStorage() : m_table(), m_data_storage() { /* ... */ }
virtual ~IndirectStorage() { this->Finalize(); }
Result Initialize(IAllocator *allocator, fs::SubStorage table_storage);
void Finalize();
bool IsInitialized() const { return this->table.IsInitialized(); }
bool IsInitialized() const { return m_table.IsInitialized(); }
Result Initialize(IAllocator *allocator, fs::SubStorage node_storage, fs::SubStorage entry_storage, s32 entry_count) {
return this->table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count);
return m_table.Initialize(allocator, node_storage, entry_storage, NodeSize, sizeof(Entry), entry_count);
}
void SetStorage(s32 idx, fs::SubStorage storage) {
AMS_ASSERT(0 <= idx && idx < StorageCount);
this->data_storage[idx] = storage;
m_data_storage[idx] = storage;
}
template<typename T>
void SetStorage(s32 idx, T storage, s64 offset, s64 size) {
AMS_ASSERT(0 <= idx && idx < StorageCount);
this->data_storage[idx] = fs::SubStorage(storage, offset, size);
m_data_storage[idx] = fs::SubStorage(storage, offset, size);
}
Result GetEntryList(Entry *out_entries, s32 *out_entry_count, s32 entry_count, s64 offset, s64 size);
@@ -133,7 +133,7 @@ namespace ams::fssystem {
virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr);
*out = this->table.GetEnd();
*out = m_table.GetEnd();
return ResultSuccess();
}
@@ -151,11 +151,11 @@ namespace ams::fssystem {
return fs::ResultUnsupportedOperationInIndirectStorageB();
}
protected:
BucketTree &GetEntryTable() { return this->table; }
BucketTree &GetEntryTable() { return m_table; }
fs::SubStorage &GetDataStorage(s32 index) {
AMS_ASSERT(0 <= index && index < StorageCount);
return this->data_storage[index];
return m_data_storage[index];
}
template<bool ContinuousCheck, typename F>

View File

@@ -29,14 +29,14 @@ namespace ams::fssystem {
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(this->table.Includes(offset, size), fs::ResultOutOfRange());
R_UNLESS(m_table.Includes(offset, size), fs::ResultOutOfRange());
/* Find the offset in our tree. */
BucketTree::Visitor visitor;
R_TRY(this->table.Find(std::addressof(visitor), offset));
R_TRY(m_table.Find(std::addressof(visitor), offset));
{
const auto entry_offset = visitor.Get<Entry>()->GetVirtualOffset();
R_UNLESS(0 <= entry_offset && this->table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset());
R_UNLESS(0 <= entry_offset && m_table.Includes(entry_offset), fs::ResultInvalidIndirectEntryOffset());
}
/* Prepare to operate in chunks. */
@@ -69,7 +69,7 @@ namespace ams::fssystem {
/* Get the current data storage's size. */
s64 cur_data_storage_size;
R_TRY(this->data_storage[0].GetSize(std::addressof(cur_data_storage_size)));
R_TRY(m_data_storage[0].GetSize(std::addressof(cur_data_storage_size)));
/* Ensure that we remain within range. */
const auto data_offset = cur_offset - cur_entry_offset;
@@ -79,7 +79,7 @@ namespace ams::fssystem {
R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultInvalidIndirectStorageSize());
/* Operate. */
R_TRY(func(std::addressof(this->data_storage[0]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
R_TRY(func(std::addressof(m_data_storage[0]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
/* Mark as done. */
cr_info.Done();
@@ -91,9 +91,9 @@ namespace ams::fssystem {
if (visitor.CanMoveNext()) {
R_TRY(visitor.MoveNext());
next_entry_offset = visitor.Get<Entry>()->GetVirtualOffset();
R_UNLESS(this->table.Includes(next_entry_offset), fs::ResultInvalidIndirectEntryOffset());
R_UNLESS(m_table.Includes(next_entry_offset), fs::ResultInvalidIndirectEntryOffset());
} else {
next_entry_offset = this->table.GetEnd();
next_entry_offset = m_table.GetEnd();
}
R_UNLESS(cur_offset < next_entry_offset, fs::ResultInvalidIndirectEntryOffset());
@@ -118,14 +118,14 @@ namespace ams::fssystem {
if (needs_operate) {
/* Get the current data storage's size. */
s64 cur_data_storage_size;
R_TRY(this->data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size)));
R_TRY(m_data_storage[cur_entry.storage_index].GetSize(std::addressof(cur_data_storage_size)));
/* Ensure that we remain within range. */
const auto cur_entry_phys_offset = cur_entry.GetPhysicalOffset();
R_UNLESS(0 <= cur_entry_phys_offset && cur_entry_phys_offset <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
R_UNLESS(cur_entry_phys_offset + data_offset + cur_size <= cur_data_storage_size, fs::ResultIndirectStorageCorrupted());
R_TRY(func(std::addressof(this->data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
R_TRY(func(std::addressof(m_data_storage[cur_entry.storage_index]), cur_entry_phys_offset + data_offset, cur_offset, cur_size));
}
cur_offset += cur_size;

View File

@@ -28,46 +28,46 @@ namespace ams::fssystem {
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
save::HierarchicalIntegrityVerificationStorage integrity_storage;
save::FileSystemBufferManagerSet buffers;
os::SdkRecursiveMutex mutex;
Hash master_hash;
std::unique_ptr<fs::MemoryStorage> master_hash_storage;
save::HierarchicalIntegrityVerificationStorage m_integrity_storage;
save::FileSystemBufferManagerSet m_buffers;
os::SdkRecursiveMutex m_mutex;
Hash m_master_hash;
std::unique_ptr<fs::MemoryStorage> m_master_hash_storage;
public:
IntegrityRomFsStorage() : mutex() { /* ... */ }
IntegrityRomFsStorage() : m_mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override {
return this->integrity_storage.Read(offset, buffer, size);
return m_integrity_storage.Read(offset, buffer, size);
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
return this->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 GetSize(s64 *out) override {
return this->integrity_storage.GetSize(out);
return m_integrity_storage.GetSize(out);
}
virtual Result Flush() override {
return this->integrity_storage.Flush();
return m_integrity_storage.Flush();
}
virtual Result OperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
return this->integrity_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
return m_integrity_storage.OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
}
Result Commit() {
return this->integrity_storage.Commit();
return m_integrity_storage.Commit();
}
save::FileSystemBufferManagerSet *GetBuffers() {
return this->integrity_storage.GetBuffers();
return m_integrity_storage.GetBuffers();
}
};

View File

@@ -85,16 +85,16 @@ namespace ams::fssystem {
NON_COPYABLE(NcaReader);
NON_MOVEABLE(NcaReader);
private:
NcaHeader header;
u8 decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize];
std::shared_ptr<fs::IStorage> shared_base_storage;
std::unique_ptr<fs::IStorage> header_storage;
fs::IStorage *body_storage;
u8 external_decryption_key[NcaCryptoConfiguration::Aes128KeySize];
DecryptAesCtrFunction decrypt_aes_ctr;
DecryptAesCtrFunction decrypt_aes_ctr_external;
bool is_software_aes_prioritized;
NcaHeader::EncryptionType header_encryption_type;
NcaHeader m_header;
u8 m_decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize];
std::shared_ptr<fs::IStorage> m_shared_base_storage;
std::unique_ptr<fs::IStorage> m_header_storage;
fs::IStorage *m_body_storage;
u8 m_external_decryption_key[NcaCryptoConfiguration::Aes128KeySize];
DecryptAesCtrFunction m_decrypt_aes_ctr;
DecryptAesCtrFunction m_decrypt_aes_ctr_external;
bool m_is_software_aes_prioritized;
NcaHeader::EncryptionType m_header_encryption_type;
public:
NcaReader();
~NcaReader();
@@ -143,18 +143,18 @@ namespace ams::fssystem {
NON_COPYABLE(NcaFsHeaderReader);
NON_MOVEABLE(NcaFsHeaderReader);
private:
NcaFsHeader data;
s32 fs_index;
NcaFsHeader m_data;
s32 m_fs_index;
public:
NcaFsHeaderReader() : fs_index(-1) {
std::memset(std::addressof(this->data), 0, sizeof(this->data));
NcaFsHeaderReader() : m_fs_index(-1) {
std::memset(std::addressof(m_data), 0, sizeof(m_data));
}
Result Initialize(const NcaReader &reader, s32 index);
bool IsInitialized() const { return this->fs_index >= 0; }
bool IsInitialized() const { return m_fs_index >= 0; }
NcaFsHeader &GetData() { return this->data; }
const NcaFsHeader &GetData() const { return this->data; }
NcaFsHeader &GetData() { return m_data; }
const NcaFsHeader &GetData() const { return m_data; }
void GetRawData(void *dst, size_t dst_size) const;
NcaFsHeader::HashData &GetHashData();
@@ -179,19 +179,19 @@ namespace ams::fssystem {
class StorageOption;
class StorageOptionWithHeaderReader;
private:
std::shared_ptr<NcaReader> original_reader;
std::shared_ptr<NcaReader> reader;
MemoryResource * const allocator;
fssystem::IBufferManager * const buffer_manager;
std::shared_ptr<NcaReader> m_original_reader;
std::shared_ptr<NcaReader> m_reader;
MemoryResource * const m_allocator;
fssystem::IBufferManager * const m_buffer_manager;
public:
static Result SetupFsHeaderReader(NcaFsHeaderReader *out, const NcaReader &reader, s32 fs_index);
public:
NcaFileSystemDriver(std::shared_ptr<NcaReader> reader, MemoryResource *allocator, IBufferManager *buffer_manager) : original_reader(), reader(reader), allocator(allocator), buffer_manager(buffer_manager) {
AMS_ASSERT(this->reader != nullptr);
NcaFileSystemDriver(std::shared_ptr<NcaReader> reader, MemoryResource *allocator, IBufferManager *buffer_manager) : m_original_reader(), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager) {
AMS_ASSERT(m_reader != nullptr);
}
NcaFileSystemDriver(std::shared_ptr<NcaReader> original_reader, std::shared_ptr<NcaReader> reader, MemoryResource *allocator, IBufferManager *buffer_manager) : original_reader(original_reader), reader(reader), allocator(allocator), buffer_manager(buffer_manager) {
AMS_ASSERT(this->reader != nullptr);
NcaFileSystemDriver(std::shared_ptr<NcaReader> original_reader, std::shared_ptr<NcaReader> reader, MemoryResource *allocator, IBufferManager *buffer_manager) : m_original_reader(original_reader), m_reader(reader), m_allocator(allocator), m_buffer_manager(buffer_manager) {
AMS_ASSERT(m_reader != nullptr);
}
Result OpenRawStorage(std::shared_ptr<fs::IStorage> *out, s32 fs_index);

View File

@@ -24,126 +24,126 @@ namespace ams::fssystem {
private:
friend class NcaFileSystemDriver;
private:
const s32 fs_index;
NcaFsHeaderReader * const header_reader;
fs::IStorage *data_storage;
s64 data_storage_size;
fs::IStorage *aes_ctr_ex_table_storage;
AesCtrCounterExtendedStorage *aes_ctr_ex_storage_raw;
fs::IStorage *aes_ctr_ex_storage;
IndirectStorage *indirect_storage;
SparseStorage *sparse_storage;
const s32 m_fs_index;
NcaFsHeaderReader * const m_header_reader;
fs::IStorage *m_data_storage;
s64 m_data_storage_size;
fs::IStorage *m_aes_ctr_ex_table_storage;
AesCtrCounterExtendedStorage *m_aes_ctr_ex_storage_raw;
fs::IStorage *m_aes_ctr_ex_storage;
IndirectStorage *m_indirect_storage;
SparseStorage *m_sparse_storage;
public:
explicit StorageOption(NcaFsHeaderReader *reader) : fs_index(reader->GetFsIndex()), header_reader(reader), data_storage(), data_storage_size(), aes_ctr_ex_table_storage(), aes_ctr_ex_storage_raw(), aes_ctr_ex_storage(), indirect_storage(), sparse_storage() {
AMS_ASSERT(this->header_reader != nullptr);
explicit StorageOption(NcaFsHeaderReader *reader) : m_fs_index(reader->GetFsIndex()), m_header_reader(reader), m_data_storage(), m_data_storage_size(), m_aes_ctr_ex_table_storage(), m_aes_ctr_ex_storage_raw(), m_aes_ctr_ex_storage(), m_indirect_storage(), m_sparse_storage() {
AMS_ASSERT(m_header_reader != nullptr);
}
StorageOption(NcaFsHeaderReader *reader, s32 index) : fs_index(index), header_reader(reader), data_storage(), data_storage_size(), aes_ctr_ex_table_storage(), aes_ctr_ex_storage_raw(), aes_ctr_ex_storage(), indirect_storage(), sparse_storage() {
AMS_ASSERT(this->header_reader != nullptr);
StorageOption(NcaFsHeaderReader *reader, s32 index) : m_fs_index(index), m_header_reader(reader), m_data_storage(), m_data_storage_size(), m_aes_ctr_ex_table_storage(), m_aes_ctr_ex_storage_raw(), m_aes_ctr_ex_storage(), m_indirect_storage(), m_sparse_storage() {
AMS_ASSERT(m_header_reader != nullptr);
AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax);
}
s32 GetFsIndex() const { return this->fs_index; }
NcaFsHeaderReader &GetHeaderReader() { return *this->header_reader; }
const NcaFsHeaderReader &GetHeaderReader() const { return *this->header_reader; }
fs::SubStorage GetDataStorage() const { return fs::SubStorage(this->data_storage, 0, this->data_storage_size); }
fs::IStorage *GetAesCtrExTableStorage() const { return this->aes_ctr_ex_table_storage; }
fs::IStorage *GetAesCtrExStorage() const { return this->aes_ctr_ex_storage; }
AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return this->aes_ctr_ex_storage_raw; }
IndirectStorage *GetIndirectStorage() const { return this->indirect_storage; }
SparseStorage *GetSparseStorage() const { return this->sparse_storage; }
s32 GetFsIndex() const { return m_fs_index; }
NcaFsHeaderReader &GetHeaderReader() { return *m_header_reader; }
const NcaFsHeaderReader &GetHeaderReader() const { return *m_header_reader; }
fs::SubStorage GetDataStorage() const { return fs::SubStorage(m_data_storage, 0, m_data_storage_size); }
fs::IStorage *GetAesCtrExTableStorage() const { return m_aes_ctr_ex_table_storage; }
fs::IStorage *GetAesCtrExStorage() const { return m_aes_ctr_ex_storage; }
AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return m_aes_ctr_ex_storage_raw; }
IndirectStorage *GetIndirectStorage() const { return m_indirect_storage; }
SparseStorage *GetSparseStorage() const { return m_sparse_storage; }
private:
void SetDataStorage(fs::IStorage *storage, s64 size) {
AMS_ASSERT(storage != nullptr);
AMS_ASSERT(size >= 0);
this->data_storage = storage;
this->data_storage_size = size;
m_data_storage = storage;
m_data_storage_size = size;
}
void SetAesCtrExTableStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_table_storage = storage; }
void SetAesCtrExStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_storage = storage; }
void SetAesCtrExStorageRaw(AesCtrCounterExtendedStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_storage_raw = storage; }
void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); this->indirect_storage = storage; }
void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); this->sparse_storage = storage; }
void SetAesCtrExTableStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_table_storage = storage; }
void SetAesCtrExStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_storage = storage; }
void SetAesCtrExStorageRaw(AesCtrCounterExtendedStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_storage_raw = storage; }
void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); m_indirect_storage = storage; }
void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); m_sparse_storage = storage; }
};
class NcaFileSystemDriver::StorageOptionWithHeaderReader : public NcaFileSystemDriver::StorageOption {
private:
NcaFsHeaderReader header_reader_data;
NcaFsHeaderReader m_header_reader_data;
public:
explicit StorageOptionWithHeaderReader(s32 index) : StorageOption(std::addressof(header_reader_data), index) { /* ... */ }
explicit StorageOptionWithHeaderReader(s32 index) : StorageOption(std::addressof(m_header_reader_data), index) { /* ... */ }
};
class NcaFileSystemDriver::BaseStorage {
private:
std::unique_ptr<fs::IStorage> storage;
fs::SubStorage sub_storage;
s64 storage_offset;
NcaAesCtrUpperIv aes_ctr_upper_iv;
std::unique_ptr<fs::IStorage> m_storage;
fs::SubStorage m_sub_storage;
s64 m_storage_offset;
NcaAesCtrUpperIv m_aes_ctr_upper_iv;
public:
BaseStorage() : storage(), sub_storage(), storage_offset(0) {
this->aes_ctr_upper_iv.value = 0;
BaseStorage() : m_storage(), m_sub_storage(), m_storage_offset(0) {
m_aes_ctr_upper_iv.value = 0;
}
explicit BaseStorage(const fs::SubStorage &ss) : storage(), sub_storage(ss), storage_offset(0) {
this->aes_ctr_upper_iv.value = 0;
explicit BaseStorage(const fs::SubStorage &ss) : m_storage(), m_sub_storage(ss), m_storage_offset(0) {
m_aes_ctr_upper_iv.value = 0;
}
template<typename T>
BaseStorage(T s, s64 offset, s64 size) : storage(), sub_storage(s, offset, size), storage_offset(0) {
this->aes_ctr_upper_iv.value = 0;
BaseStorage(T s, s64 offset, s64 size) : m_storage(), m_sub_storage(s, offset, size), m_storage_offset(0) {
m_aes_ctr_upper_iv.value = 0;
}
void SetStorage(std::unique_ptr<fs::IStorage> &&storage) {
this->storage = std::move(storage);
m_storage = std::move(storage);
}
template<typename T>
void SetStorage(T storage, s64 offset, s64 size) {
this->sub_storage = fs::SubStorage(storage, offset, size);
m_sub_storage = fs::SubStorage(storage, offset, size);
}
std::unique_ptr<fs::IStorage> MakeStorage() {
if (this->storage != nullptr) {
return std::move(this->storage);
if (m_storage != nullptr) {
return std::move(m_storage);
}
return std::make_unique<fs::SubStorage>(this->sub_storage);
return std::make_unique<fs::SubStorage>(m_sub_storage);
}
std::unique_ptr<fs::IStorage> GetStorage() {
return std::move(this->storage);
return std::move(m_storage);
}
Result GetSubStorage(fs::SubStorage *out, s64 offset, s64 size) {
s64 storage_size = 0;
if (this->storage != nullptr) {
R_TRY(this->storage->GetSize(std::addressof(storage_size)));
if (m_storage != nullptr) {
R_TRY(m_storage->GetSize(std::addressof(storage_size)));
R_UNLESS(offset + size <= storage_size, fs::ResultNcaBaseStorageOutOfRangeA());
*out = fs::SubStorage(this->storage.get(), offset, size);
*out = fs::SubStorage(m_storage.get(), offset, size);
} else {
R_TRY(this->sub_storage.GetSize(std::addressof(storage_size)));
R_TRY(m_sub_storage.GetSize(std::addressof(storage_size)));
R_UNLESS(offset + size <= storage_size, fs::ResultNcaBaseStorageOutOfRangeA());
*out = fs::SubStorage(std::addressof(this->sub_storage), offset, size);
*out = fs::SubStorage(std::addressof(m_sub_storage), offset, size);
}
return ResultSuccess();
}
void SetStorageOffset(s64 offset) {
this->storage_offset = offset;
m_storage_offset = offset;
}
s64 GetStorageOffset() const {
return this->storage_offset;
return m_storage_offset;
}
void SetAesCtrUpperIv(NcaAesCtrUpperIv v) {
this->aes_ctr_upper_iv = v;
m_aes_ctr_upper_iv = v;
}
const NcaAesCtrUpperIv GetAesCtrUpperIv() const {
return this->aes_ctr_upper_iv;
return m_aes_ctr_upper_iv;
}
};

View File

@@ -29,12 +29,12 @@ namespace ams::fssystem {
class PartitionFile;
class PartitionDirectory;
private:
fs::IStorage *base_storage;
MetaType *meta_data;
bool initialized;
size_t meta_data_size;
std::unique_ptr<MetaType> unique_meta_data;
std::shared_ptr<fs::IStorage> shared_storage;
fs::IStorage *m_base_storage;
MetaType *m_meta_data;
bool m_initialized;
size_t m_meta_data_size;
std::unique_ptr<MetaType> m_unique_meta_data;
std::shared_ptr<fs::IStorage> m_shared_storage;
private:
Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator);
public:

View File

@@ -76,15 +76,15 @@ namespace ams::fssystem {
using PartitionEntry = typename Format::PartitionEntry;
protected:
bool initialized;
PartitionFileSystemHeader *header;
PartitionEntry *entries;
char *name_table;
size_t meta_data_size;
MemoryResource *allocator;
char *buffer;
bool m_initialized;
PartitionFileSystemHeader *m_header;
PartitionEntry *m_entries;
char *m_name_table;
size_t m_meta_data_size;
MemoryResource *m_allocator;
char *m_buffer;
public:
PartitionFileSystemMetaCore() : initialized(false), allocator(nullptr), buffer(nullptr) { /* ... */ }
PartitionFileSystemMetaCore() : m_initialized(false), m_allocator(nullptr), m_buffer(nullptr) { /* ... */ }
~PartitionFileSystemMetaCore();
Result Initialize(fs::IStorage *storage, MemoryResource *allocator);

View File

@@ -25,8 +25,8 @@ namespace ams::fssystem {
class PooledBuffer {
NON_COPYABLE(PooledBuffer);
private:
char *buffer;
size_t size;
char *m_buffer;
size_t m_size;
private:
static size_t GetAllocatableSizeMaxCore(bool large);
public:
@@ -34,14 +34,14 @@ namespace ams::fssystem {
static size_t GetAllocatableParticularlyLargeSizeMax() { return GetAllocatableSizeMaxCore(true); }
private:
void Swap(PooledBuffer &rhs) {
std::swap(this->buffer, rhs.buffer);
std::swap(this->size, rhs.size);
std::swap(m_buffer, rhs.m_buffer);
std::swap(m_size, rhs.m_size);
}
public:
/* Constructor/Destructor. */
constexpr PooledBuffer() : buffer(), size() { /* ... */ }
constexpr PooledBuffer() : m_buffer(), m_size() { /* ... */ }
PooledBuffer(size_t ideal_size, size_t required_size) : buffer(), size() {
PooledBuffer(size_t ideal_size, size_t required_size) : m_buffer(), m_size() {
this->Allocate(ideal_size, required_size);
}
@@ -50,9 +50,9 @@ namespace ams::fssystem {
}
/* Move and assignment. */
explicit PooledBuffer(PooledBuffer &&rhs) : buffer(rhs.buffer), size(rhs.size) {
rhs.buffer = nullptr;
rhs.size = 0;
explicit PooledBuffer(PooledBuffer &&rhs) : m_buffer(rhs.m_buffer), m_size(rhs.m_size) {
rhs.m_buffer = nullptr;
rhs.m_size = 0;
}
PooledBuffer &operator=(PooledBuffer &&rhs) {
@@ -74,17 +74,17 @@ namespace ams::fssystem {
void Deallocate() {
/* Shrink the buffer to empty. */
this->Shrink(0);
AMS_ASSERT(this->buffer == nullptr);
AMS_ASSERT(m_buffer == nullptr);
}
char *GetBuffer() const {
AMS_ASSERT(this->buffer != nullptr);
return this->buffer;
AMS_ASSERT(m_buffer != nullptr);
return m_buffer;
}
size_t GetSize() const {
AMS_ASSERT(this->buffer != nullptr);
return this->size;
AMS_ASSERT(m_buffer != nullptr);
return m_size;
}
private:
void AllocateCore(size_t ideal_size, size_t required_size, bool large);

View File

@@ -27,14 +27,14 @@ namespace ams::fssystem {
public:
using RomFileTable = fs::HierarchicalRomFileTable;
private:
RomFileTable rom_file_table;
fs::IStorage *base_storage;
std::shared_ptr<fs::IStorage> shared_storage;
std::unique_ptr<fs::IStorage> dir_bucket_storage;
std::unique_ptr<fs::IStorage> dir_entry_storage;
std::unique_ptr<fs::IStorage> file_bucket_storage;
std::unique_ptr<fs::IStorage> file_entry_storage;
s64 entry_size;
RomFileTable m_rom_file_table;
fs::IStorage *m_base_storage;
std::shared_ptr<fs::IStorage> m_shared_storage;
std::unique_ptr<fs::IStorage> m_dir_bucket_storage;
std::unique_ptr<fs::IStorage> m_dir_entry_storage;
std::unique_ptr<fs::IStorage> m_file_bucket_storage;
std::unique_ptr<fs::IStorage> m_file_entry_storage;
s64 m_entry_size;
private:
Result GetFileInfo(RomFileTable::FileInfo *out, const char *path);
public:

View File

@@ -65,9 +65,9 @@ namespace ams::fssystem {
}
};
private:
ZeroStorage zero_storage;
ZeroStorage m_zero_storage;
public:
SparseStorage() : IndirectStorage(), zero_storage() { /* ... */ }
SparseStorage() : IndirectStorage(), m_zero_storage() { /* ... */ }
virtual ~SparseStorage() { /* ... */ }
using IndirectStorage::Initialize;
@@ -95,7 +95,7 @@ namespace ams::fssystem {
virtual Result Read(s64 offset, void *buffer, size_t size) override;
private:
void SetZeroStorage() {
return this->SetStorage(1, std::addressof(this->zero_storage), 0, std::numeric_limits<s64>::max());
return this->SetStorage(1, std::addressof(m_zero_storage), 0, std::numeric_limits<s64>::max());
}
};

View File

@@ -24,8 +24,8 @@ namespace ams::fssystem {
using PathResolutionFileSystem = impl::IPathResolutionFileSystem<SubDirectoryFileSystem>;
friend class impl::IPathResolutionFileSystem<SubDirectoryFileSystem>;
private:
char *base_path;
size_t base_path_len;
char *m_base_path;
size_t m_base_path_len;
public:
SubDirectoryFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, const char *bp, bool unc = false);
SubDirectoryFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, const char *bp, bool unc = false);

View File

@@ -48,9 +48,9 @@ namespace ams::fssystem {
private:
static s32 GetThreadPriorityByAccessPriority(AccessMode mode);
private:
ScopedThreadPriorityChanger scoped_changer;
ScopedThreadPriorityChanger m_scoped_changer;
public:
ALWAYS_INLINE explicit ScopedThreadPriorityChangerByAccessPriority(AccessMode mode) : scoped_changer(GetThreadPriorityByAccessPriority(mode), ScopedThreadPriorityChanger::Mode::Absolute) {
ALWAYS_INLINE explicit ScopedThreadPriorityChangerByAccessPriority(AccessMode mode) : m_scoped_changer(GetThreadPriorityByAccessPriority(mode), ScopedThreadPriorityChanger::Mode::Absolute) {
/* ... */
}
};

View File

@@ -26,24 +26,24 @@ namespace ams::fssystem::impl {
class IPathResolutionFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(IPathResolutionFileSystem);
private:
std::shared_ptr<fs::fsa::IFileSystem> shared_fs;
std::unique_ptr<fs::fsa::IFileSystem> unique_fs;
bool unc_preserved;
std::shared_ptr<fs::fsa::IFileSystem> m_shared_fs;
std::unique_ptr<fs::fsa::IFileSystem> m_unique_fs;
bool m_unc_preserved;
protected:
fs::fsa::IFileSystem * const base_fs;
fs::fsa::IFileSystem * const m_base_fs;
public:
IPathResolutionFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, bool unc = false) : shared_fs(std::move(fs)), unc_preserved(unc), base_fs(shared_fs.get()) {
IPathResolutionFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, bool unc = false) : m_shared_fs(std::move(fs)), m_unc_preserved(unc), m_base_fs(m_shared_fs.get()) {
/* ... */
}
IPathResolutionFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, bool unc = false) : unique_fs(std::move(fs)), unc_preserved(unc), base_fs(unique_fs.get()) {
IPathResolutionFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, bool unc = false) : m_unique_fs(std::move(fs)), m_unc_preserved(unc), m_base_fs(m_unique_fs.get()) {
/* ... */
}
virtual ~IPathResolutionFileSystem() { /* ... */ }
protected:
constexpr inline bool IsUncPreserved() const {
return this->unc_preserved;
return m_unc_preserved;
}
public:
virtual Result DoCreateFile(const char *path, s64 size, int option) override {
@@ -51,7 +51,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->CreateFile(full_path, size, option);
return m_base_fs->CreateFile(full_path, size, option);
}
virtual Result DoDeleteFile(const char *path) override {
@@ -59,7 +59,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->DeleteFile(full_path);
return m_base_fs->DeleteFile(full_path);
}
virtual Result DoCreateDirectory(const char *path) override {
@@ -67,7 +67,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->CreateDirectory(full_path);
return m_base_fs->CreateDirectory(full_path);
}
virtual Result DoDeleteDirectory(const char *path) override {
@@ -75,7 +75,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->DeleteDirectory(full_path);
return m_base_fs->DeleteDirectory(full_path);
}
virtual Result DoDeleteDirectoryRecursively(const char *path) override {
@@ -83,7 +83,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->DeleteDirectoryRecursively(full_path);
return m_base_fs->DeleteDirectoryRecursively(full_path);
}
virtual Result DoRenameFile(const char *old_path, const char *new_path) override {
@@ -93,7 +93,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->RenameFile(old_full_path, new_full_path);
return m_base_fs->RenameFile(old_full_path, new_full_path);
}
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override {
@@ -103,7 +103,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(new_full_path, sizeof(new_full_path), new_path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->RenameDirectory(old_full_path, new_full_path);
return m_base_fs->RenameDirectory(old_full_path, new_full_path);
}
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override {
@@ -111,7 +111,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->GetEntryType(out, full_path);
return m_base_fs->GetEntryType(out, full_path);
}
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const char *path, fs::OpenMode mode) override {
@@ -119,7 +119,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->OpenFile(out_file, full_path, mode);
return m_base_fs->OpenFile(out_file, full_path, mode);
}
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const char *path, fs::OpenDirectoryMode mode) override {
@@ -127,12 +127,12 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->OpenDirectory(out_dir, full_path, mode);
return m_base_fs->OpenDirectory(out_dir, full_path, mode);
}
virtual Result DoCommit() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->Commit();
return m_base_fs->Commit();
}
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override {
@@ -140,7 +140,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->GetFreeSpaceSize(out, full_path);
return m_base_fs->GetFreeSpaceSize(out, full_path);
}
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override {
@@ -148,7 +148,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->GetTotalSpaceSize(out, full_path);
return m_base_fs->GetTotalSpaceSize(out, full_path);
}
virtual Result DoCleanDirectoryRecursively(const char *path) override {
@@ -156,7 +156,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->CleanDirectoryRecursively(full_path);
return m_base_fs->CleanDirectoryRecursively(full_path);
}
virtual Result DoGetFileTimeStampRaw(fs::FileTimeStampRaw *out, const char *path) override {
@@ -164,7 +164,7 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->GetFileTimeStampRaw(out, full_path);
return m_base_fs->GetFileTimeStampRaw(out, full_path);
}
virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fs::fsa::QueryId query, const char *path) override {
@@ -172,23 +172,23 @@ namespace ams::fssystem::impl {
R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path);
return m_base_fs->QueryEntry(dst, dst_size, src, src_size, query, full_path);
}
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->CommitProvisionally(counter);
return m_base_fs->CommitProvisionally(counter);
}
virtual Result DoRollback() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->Rollback();
return m_base_fs->Rollback();
}
virtual Result DoFlush() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->Flush();
return m_base_fs->Flush();
}
};

View File

@@ -61,19 +61,19 @@ namespace ams::fssystem::save {
Flag_RealData = (1 << 10),
};
private:
IBufferManager *buffer_manager;
os::SdkRecursiveMutex *mutex;
std::unique_ptr<CacheEntry[], ::ams::fs::impl::Deleter> entries;
IStorage *data_storage;
Result last_result;
s64 data_size;
size_t verification_block_size;
size_t verification_block_shift;
CacheIndex invalidate_index;
s32 max_cache_entry_count;
s32 flags;
s32 buffer_level;
fs::StorageType storage_type;
IBufferManager *m_buffer_manager;
os::SdkRecursiveMutex *m_mutex;
std::unique_ptr<CacheEntry[], ::ams::fs::impl::Deleter> m_entries;
IStorage *m_data_storage;
Result m_last_result;
s64 m_data_size;
size_t m_verification_block_size;
size_t m_verification_block_shift;
CacheIndex m_invalidate_index;
s32 m_max_cache_entry_count;
s32 m_flags;
s32 m_buffer_level;
fs::StorageType m_storage_type;
public:
BlockCacheBufferedStorage();
virtual ~BlockCacheBufferedStorage() override;
@@ -96,31 +96,31 @@ namespace ams::fssystem::save {
Result OnRollback();
bool IsEnabledKeepBurstMode() const {
return (this->flags & Flag_KeepBurstMode) != 0;
return (m_flags & Flag_KeepBurstMode) != 0;
}
bool IsRealDataCache() const {
return (this->flags & Flag_RealData) != 0;
return (m_flags & Flag_RealData) != 0;
}
void SetKeepBurstMode(bool en) {
if (en) {
this->flags |= Flag_KeepBurstMode;
m_flags |= Flag_KeepBurstMode;
} else {
this->flags &= ~Flag_KeepBurstMode;
m_flags &= ~Flag_KeepBurstMode;
}
}
void SetRealDataCache(bool en) {
if (en) {
this->flags |= Flag_RealData;
m_flags |= Flag_RealData;
} else {
this->flags &= ~Flag_RealData;
m_flags &= ~Flag_RealData;
}
}
private:
s32 GetMaxCacheEntryCount() const {
return this->max_cache_entry_count;
return m_max_cache_entry_count;
}
Result ClearImpl(s64 offset, s64 size);

View File

@@ -30,16 +30,16 @@ namespace ams::fssystem::save {
class UniqueCache;
class SharedCache;
private:
fs::SubStorage base_storage;
IBufferManager *buffer_manager;
size_t block_size;
s64 base_storage_size;
std::unique_ptr<Cache[]> caches;
s32 cache_count;
Cache *next_acquire_cache;
Cache *next_fetch_cache;
os::SdkMutex mutex;
bool bulk_read_enabled;
fs::SubStorage m_base_storage;
IBufferManager *m_buffer_manager;
size_t m_block_size;
s64 m_base_storage_size;
std::unique_ptr<Cache[]> m_caches;
s32 m_cache_count;
Cache *m_next_acquire_cache;
Cache *m_next_fetch_cache;
os::SdkMutex m_mutex;
bool m_bulk_read_enabled;
public:
BufferedStorage();
virtual ~BufferedStorage();
@@ -47,7 +47,7 @@ namespace ams::fssystem::save {
Result Initialize(fs::SubStorage base_storage, IBufferManager *buffer_manager, size_t block_size, s32 buffer_count);
void Finalize();
bool IsInitialized() const { return this->caches != nullptr; }
bool IsInitialized() const { return m_caches != nullptr; }
virtual Result Read(s64 offset, void *buffer, size_t size) override;
virtual Result Write(s64 offset, const void *buffer, size_t size) override;
@@ -61,9 +61,9 @@ namespace ams::fssystem::save {
void InvalidateCaches();
IBufferManager *GetBufferManager() const { return this->buffer_manager; }
IBufferManager *GetBufferManager() const { return m_buffer_manager; }
void EnableBulkRead() { this->bulk_read_enabled = true; }
void EnableBulkRead() { m_bulk_read_enabled = true; }
private:
Result PrepareAllocation();
Result ControlDirtiness();

View File

@@ -82,8 +82,8 @@ namespace ams::fssystem::save {
};
static_assert(util::is_pod<InputParam>::value);
private:
fs::SubStorage storage;
HierarchicalIntegrityVerificationMetaInformation meta;
fs::SubStorage m_storage;
HierarchicalIntegrityVerificationMetaInformation m_meta;
public:
static Result QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size);
/* TODO Format */
@@ -94,10 +94,10 @@ namespace ams::fssystem::save {
Result Initialize(fs::SubStorage meta_storage);
void Finalize();
u32 GetMasterHashSize() const { return this->meta.master_hash_size; }
u32 GetMasterHashSize() const { return m_meta.master_hash_size; }
void GetLevelHashInfo(HierarchicalIntegrityVerificationInformation *out) {
AMS_ASSERT(out != nullptr);
*out = this->meta.level_hash_info;
*out = m_meta.level_hash_info;
}
};
@@ -124,19 +124,19 @@ namespace ams::fssystem::save {
DataStorage = 6,
};
private:
fs::SubStorage storages[DataStorage + 1];
fs::SubStorage m_storages[DataStorage + 1];
public:
void SetMasterHashStorage(fs::SubStorage s) { this->storages[MasterStorage] = s; }
void SetLayer1HashStorage(fs::SubStorage s) { this->storages[Layer1Storage] = s; }
void SetLayer2HashStorage(fs::SubStorage s) { this->storages[Layer2Storage] = s; }
void SetLayer3HashStorage(fs::SubStorage s) { this->storages[Layer3Storage] = s; }
void SetLayer4HashStorage(fs::SubStorage s) { this->storages[Layer4Storage] = s; }
void SetLayer5HashStorage(fs::SubStorage s) { this->storages[Layer5Storage] = s; }
void SetDataStorage(fs::SubStorage s) { this->storages[DataStorage] = s; }
void SetMasterHashStorage(fs::SubStorage s) { m_storages[MasterStorage] = s; }
void SetLayer1HashStorage(fs::SubStorage s) { m_storages[Layer1Storage] = s; }
void SetLayer2HashStorage(fs::SubStorage s) { m_storages[Layer2Storage] = s; }
void SetLayer3HashStorage(fs::SubStorage s) { m_storages[Layer3Storage] = s; }
void SetLayer4HashStorage(fs::SubStorage s) { m_storages[Layer4Storage] = s; }
void SetLayer5HashStorage(fs::SubStorage s) { m_storages[Layer5Storage] = s; }
void SetDataStorage(fs::SubStorage s) { m_storages[DataStorage] = s; }
fs::SubStorage &operator[](s32 index) {
AMS_ASSERT(MasterStorage <= index && index <= DataStorage);
return this->storages[index];
return m_storages[index];
}
};
private:
@@ -146,15 +146,15 @@ namespace ams::fssystem::save {
s_generate_random = func;
}
private:
FileSystemBufferManagerSet *buffers;
os::SdkRecursiveMutex *mutex;
IntegrityVerificationStorage verify_storages[MaxLayers - 1];
BlockCacheBufferedStorage buffer_storages[MaxLayers - 1];
s64 data_size;
s32 max_layers;
bool is_written_for_rollback;
FileSystemBufferManagerSet *m_buffers;
os::SdkRecursiveMutex *m_mutex;
IntegrityVerificationStorage m_verify_storages[MaxLayers - 1];
BlockCacheBufferedStorage m_buffer_storages[MaxLayers - 1];
s64 m_data_size;
s32 m_max_layers;
bool m_is_written_for_rollback;
public:
HierarchicalIntegrityVerificationStorage() : buffers(nullptr), mutex(nullptr), data_size(-1), is_written_for_rollback(false) { /* ... */ }
HierarchicalIntegrityVerificationStorage() : m_buffers(nullptr), m_mutex(nullptr), m_data_size(-1), m_is_written_for_rollback(false) { /* ... */ }
virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type);
@@ -175,30 +175,30 @@ namespace ams::fssystem::save {
Result OnRollback();
bool IsInitialized() const {
return this->data_size >= 0;
return m_data_size >= 0;
}
bool IsWrittenForRollback() const {
return this->is_written_for_rollback;
return m_is_written_for_rollback;
}
FileSystemBufferManagerSet *GetBuffers() {
return this->buffers;
return m_buffers;
}
void GetParameters(HierarchicalIntegrityVerificationStorageControlArea::InputParam *out) const {
AMS_ASSERT(out != nullptr);
for (auto level = 0; level <= this->max_layers - 2; ++level) {
out->level_block_size[level] = static_cast<size_t>(this->verify_storages[level].GetBlockSize());
for (auto level = 0; level <= m_max_layers - 2; ++level) {
out->level_block_size[level] = static_cast<size_t>(m_verify_storages[level].GetBlockSize());
}
}
s64 GetL1HashVerificationBlockSize() const {
return this->verify_storages[this->max_layers - 2].GetBlockSize();
return m_verify_storages[m_max_layers - 2].GetBlockSize();
}
fs::SubStorage GetL1HashStorage() {
return fs::SubStorage(std::addressof(this->buffer_storages[this->max_layers - 3]), 0, util::DivideUp(this->data_size, this->GetL1HashVerificationBlockSize()));
return fs::SubStorage(std::addressof(m_buffer_storages[m_max_layers - 3]), 0, util::DivideUp(m_data_size, this->GetL1HashVerificationBlockSize()));
}
};

View File

@@ -37,18 +37,18 @@ namespace ams::fssystem::save {
};
static_assert(util::is_pod<BlockHash>::value);
private:
fs::SubStorage hash_storage;
fs::SubStorage data_storage;
s64 verification_block_size;
s64 verification_block_order;
s64 upper_layer_verification_block_size;
s64 upper_layer_verification_block_order;
IBufferManager *buffer_manager;
fs::HashSalt salt;
bool is_real_data;
fs::StorageType storage_type;
fs::SubStorage m_hash_storage;
fs::SubStorage m_data_storage;
s64 m_verification_block_size;
s64 m_verification_block_order;
s64 m_upper_layer_verification_block_size;
s64 m_upper_layer_verification_block_order;
IBufferManager *m_buffer_manager;
fs::HashSalt m_salt;
bool m_is_real_data;
fs::StorageType m_storage_type;
public:
IntegrityVerificationStorage() : verification_block_size(0), verification_block_order(0), upper_layer_verification_block_size(0), upper_layer_verification_block_order(0), buffer_manager(nullptr) { /* ... */ }
IntegrityVerificationStorage() : m_verification_block_size(0), m_verification_block_order(0), m_upper_layer_verification_block_size(0), m_upper_layer_verification_block_order(0), m_buffer_manager(nullptr) { /* ... */ }
virtual ~IntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, IBufferManager *bm, const fs::HashSalt &salt, bool is_real_data, fs::StorageType storage_type);
@@ -68,7 +68,7 @@ namespace ams::fssystem::save {
void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size) const;
s64 GetBlockSize() const {
return this->verification_block_size;
return m_verification_block_size;
}
private:
Result ReadBlockSignature(void *dst, size_t dst_size, s64 offset, size_t size);
@@ -76,7 +76,7 @@ namespace ams::fssystem::save {
Result VerifyHash(const void *buf, BlockHash *hash);
void CalcBlockHash(BlockHash *out, const void *buffer) const {
return this->CalcBlockHash(out, buffer, static_cast<size_t>(this->verification_block_size));
return this->CalcBlockHash(out, buffer, static_cast<size_t>(m_verification_block_size));
}
Result IsCleared(bool *is_cleared, const BlockHash &hash);