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

@ -24,23 +24,23 @@ namespace ams::ddsf {
NON_COPYABLE(DeviceCodeEntry);
NON_MOVEABLE(DeviceCodeEntry);
private:
ams::DeviceCode device_code = ams::InvalidDeviceCode;
IDevice *device = nullptr;
ams::DeviceCode m_device_code = ams::InvalidDeviceCode;
IDevice *m_device = nullptr;
public:
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : device_code(dc), device(dev) {
constexpr DeviceCodeEntry(ams::DeviceCode dc, IDevice *dev) : m_device_code(dc), m_device(dev) {
AMS_ASSERT(dev != nullptr);
}
constexpr ams::DeviceCode GetDeviceCode() const {
return this->device_code;
return m_device_code;
}
constexpr IDevice &GetDevice() {
return *this->device;
return *m_device;
}
constexpr const IDevice &GetDevice() const {
return *this->device;
return *m_device;
}
};
@ -48,15 +48,15 @@ namespace ams::ddsf {
NON_COPYABLE(DeviceCodeEntryHolder);
NON_MOVEABLE(DeviceCodeEntryHolder);
private:
util::IntrusiveListNode list_node;
util::TypedStorage<DeviceCodeEntry> entry_storage;
bool is_constructed;
util::IntrusiveListNode m_list_node;
util::TypedStorage<DeviceCodeEntry> m_entry_storage;
bool m_is_constructed;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::list_node>>;
friend class util::IntrusiveList<DeviceCodeEntryHolder, util::IntrusiveListMemberTraitsDeferredAssert<&DeviceCodeEntryHolder::m_list_node>>;
public:
DeviceCodeEntryHolder() : list_node(), entry_storage(), is_constructed(false) {
DeviceCodeEntryHolder() : m_list_node(), m_entry_storage(), m_is_constructed(false) {
/* ... */
}
@ -75,34 +75,34 @@ namespace ams::ddsf {
}
bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}
DeviceCodeEntry &Construct(DeviceCode dc, IDevice *dev) {
AMS_ASSERT(!this->IsConstructed());
DeviceCodeEntry *entry = util::ConstructAt(this->entry_storage, dc, dev);
this->is_constructed = true;
DeviceCodeEntry *entry = util::ConstructAt(m_entry_storage, dc, dev);
m_is_constructed = true;
return *entry;
}
bool IsConstructed() const {
return this->is_constructed;
return m_is_constructed;
}
void Destroy() {
AMS_ASSERT(this->IsConstructed());
util::DestroyAt(this->entry_storage);
this->is_constructed = false;
util::DestroyAt(m_entry_storage);
m_is_constructed = false;
}
DeviceCodeEntry &Get() {
AMS_ASSERT(this->IsConstructed());
return GetReference(this->entry_storage);
return GetReference(m_entry_storage);
}
const DeviceCodeEntry &Get() const {
AMS_ASSERT(this->IsConstructed());
return GetReference(this->entry_storage);
return GetReference(m_entry_storage);
}
};
static_assert(DeviceCodeEntryHolder::ListTraits::IsValid());

View file

@ -25,33 +25,33 @@ namespace ams::ddsf {
class DeviceCodeEntryManager {
private:
ams::MemoryResource *memory_resource;
ddsf::DeviceCodeEntryHolder::List entry_list;
mutable os::SdkMutex entry_list_lock;
ams::MemoryResource *m_memory_resource;
ddsf::DeviceCodeEntryHolder::List m_entry_list;
mutable os::SdkMutex m_entry_list_lock;
private:
void DestroyAllEntries() {
auto it = this->entry_list.begin();
while (it != this->entry_list.end()) {
auto it = m_entry_list.begin();
while (it != m_entry_list.end()) {
ddsf::DeviceCodeEntryHolder *entry = std::addressof(*it);
it = this->entry_list.erase(it);
it = m_entry_list.erase(it);
AMS_ASSERT(entry->IsConstructed());
if (entry->IsConstructed()) {
entry->Destroy();
}
this->memory_resource->Deallocate(entry, sizeof(*entry));
m_memory_resource->Deallocate(entry, sizeof(*entry));
}
}
public:
DeviceCodeEntryManager(ams::MemoryResource *mr) : memory_resource(mr), entry_list(), entry_list_lock() { /* ... */ }
DeviceCodeEntryManager(ams::MemoryResource *mr) : m_memory_resource(mr), m_entry_list(), m_entry_list_lock() { /* ... */ }
~DeviceCodeEntryManager() {
this->DestroyAllEntries();
}
void Reset() {
std::scoped_lock lk(this->entry_list_lock);
std::scoped_lock lk(m_entry_list_lock);
this->DestroyAllEntries();
}
@ -66,7 +66,7 @@ namespace ams::ddsf {
template<typename F>
int ForEachEntry(F f) {
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](DeviceCodeEntryHolder &holder) -> bool {
AMS_ASSERT(holder.IsConstructed());
return f(holder.Get());
});
@ -74,7 +74,7 @@ namespace ams::ddsf {
template<typename F>
int ForEachEntry(F f) const {
return impl::ForEach(this->entry_list_lock, this->entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
return impl::ForEach(m_entry_list_lock, m_entry_list, [&](const DeviceCodeEntryHolder &holder) -> bool {
AMS_ASSERT(holder.IsConstructed());
return f(holder.Get());
});

View file

@ -28,41 +28,41 @@ namespace ams::ddsf {
private:
struct LoopControlCommandParameters;
private:
bool is_initialized;
bool is_looping;
os::SdkConditionVariable is_looping_cv;
os::MultiWaitType multi_wait;
os::ThreadType *loop_thread;
os::Event loop_control_event;
os::MultiWaitHolderType loop_control_event_holder;
LoopControlCommandParameters *loop_control_command_params;
os::LightEvent loop_control_command_done_event;
os::SdkMutex loop_control_lock;
bool m_is_initialized;
bool m_is_looping;
os::SdkConditionVariable m_is_looping_cv;
os::MultiWaitType m_multi_wait;
os::ThreadType *m_loop_thread;
os::Event m_loop_control_event;
os::MultiWaitHolderType m_loop_control_event_holder;
LoopControlCommandParameters *m_loop_control_command_params;
os::LightEvent m_loop_control_command_done_event;
os::SdkMutex m_loop_control_lock;
private:
void ProcessControlCommand(LoopControlCommandParameters *params);
void ProcessControlCommandImpl(LoopControlCommandParameters *params);
public:
EventHandlerManager()
: is_initialized(false), is_looping(false), is_looping_cv(), multi_wait(),
loop_thread(), loop_control_event(os::EventClearMode_AutoClear), loop_control_event_holder(),
loop_control_command_params(), loop_control_command_done_event(os::EventClearMode_AutoClear),
loop_control_lock()
: m_is_initialized(false), m_is_looping(false), m_is_looping_cv(), m_multi_wait(),
m_loop_thread(), m_loop_control_event(os::EventClearMode_AutoClear), m_loop_control_event_holder(),
m_loop_control_command_params(), m_loop_control_command_done_event(os::EventClearMode_AutoClear),
m_loop_control_lock()
{
this->Initialize();
}
~EventHandlerManager() {
if (this->is_looping) {
if (m_is_looping) {
AMS_ASSERT(!this->IsRunningOnLoopThread());
this->RequestStop();
}
if (this->is_initialized) {
if (m_is_initialized) {
this->Finalize();
}
}
bool IsRunningOnLoopThread() const { return this->loop_thread == os::GetCurrentThread(); }
bool IsLooping() const { return this->is_looping; }
bool IsRunningOnLoopThread() const { return m_loop_thread == os::GetCurrentThread(); }
bool IsLooping() const { return m_is_looping; }
void Initialize();
void Finalize();

View file

@ -32,57 +32,57 @@ namespace ams::ddsf {
public:
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice);
private:
util::IntrusiveListNode list_node;
IDriver *driver;
ISession::List session_list;
mutable os::SdkMutex session_list_lock;
bool is_exclusive_write;
util::IntrusiveListNode m_list_node;
IDriver *m_driver;
ISession::List m_session_list;
mutable os::SdkMutex m_session_list_lock;
bool m_is_exclusive_write;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::list_node>>;
friend class util::IntrusiveList<IDevice, util::IntrusiveListMemberTraitsDeferredAssert<&IDevice::m_list_node>>;
private:
Result AttachSession(ISession *session) {
AMS_ASSERT(session != nullptr);
std::scoped_lock lk(this->session_list_lock);
std::scoped_lock lk(m_session_list_lock);
/* Check if we're allowed to attach the session. */
if (this->is_exclusive_write && session->CheckExclusiveWrite()) {
for (const auto &attached : this->session_list) {
if (m_is_exclusive_write && session->CheckExclusiveWrite()) {
for (const auto &attached : m_session_list) {
R_UNLESS(!attached.CheckAccess(AccessMode_Write), ddsf::ResultAccessModeDenied());
}
}
/* Attach the session. */
this->session_list.push_back(*session);
m_session_list.push_back(*session);
return ResultSuccess();
}
void DetachSession(ISession *session) {
AMS_ASSERT(session != nullptr);
std::scoped_lock lk(this->session_list_lock);
this->session_list.erase(this->session_list.iterator_to(*session));
std::scoped_lock lk(m_session_list_lock);
m_session_list.erase(m_session_list.iterator_to(*session));
}
void AttachDriver(IDriver *drv) {
AMS_ASSERT(drv != nullptr);
AMS_ASSERT(!this->IsDriverAttached());
this->driver = drv;
m_driver = drv;
AMS_ASSERT(this->IsDriverAttached());
}
void DetachDriver() {
AMS_ASSERT(this->IsDriverAttached());
this->driver = nullptr;
m_driver = nullptr;
AMS_ASSERT(!this->IsDriverAttached());
}
public:
IDevice(bool exclusive_write) : list_node(), driver(nullptr), session_list(), session_list_lock(), is_exclusive_write(exclusive_write) {
this->session_list.clear();
IDevice(bool exclusive_write) : m_list_node(), m_driver(nullptr), m_session_list(), m_session_list_lock(), m_is_exclusive_write(exclusive_write) {
m_session_list.clear();
}
protected:
~IDevice() {
this->session_list.clear();
m_session_list.clear();
}
public:
void AddTo(List &list) {
@ -94,45 +94,45 @@ namespace ams::ddsf {
}
bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}
IDriver &GetDriver() {
AMS_ASSERT(this->IsDriverAttached());
return *this->driver;
return *m_driver;
}
const IDriver &GetDriver() const {
AMS_ASSERT(this->IsDriverAttached());
return *this->driver;
return *m_driver;
}
bool IsDriverAttached() const {
return this->driver != nullptr;
return m_driver != nullptr;
}
template<typename F>
Result ForEachSession(F f, bool return_on_fail) {
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
}
template<typename F>
Result ForEachSession(F f, bool return_on_fail) const {
return impl::ForEach(this->session_list_lock, this->session_list, f, return_on_fail);
return impl::ForEach(m_session_list_lock, m_session_list, f, return_on_fail);
}
template<typename F>
int ForEachSession(F f) {
return impl::ForEach(this->session_list_lock, this->session_list, f);
return impl::ForEach(m_session_list_lock, m_session_list, f);
}
template<typename F>
int ForEachSession(F f) const {
return impl::ForEach(this->session_list_lock, this->session_list, f);
return impl::ForEach(m_session_list_lock, m_session_list, f);
}
bool HasAnyOpenSession() const {
return !this->session_list.empty();
return !m_session_list.empty();
}
};
static_assert(IDevice::ListTraits::IsValid());

View file

@ -27,21 +27,21 @@ namespace ams::ddsf {
public:
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDriver);
private:
util::IntrusiveListNode list_node;
IDevice::List device_list;
mutable os::SdkMutex device_list_lock;
util::IntrusiveListNode m_list_node;
IDevice::List m_device_list;
mutable os::SdkMutex m_device_list_lock;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<IDriver, util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::list_node>>;
friend class util::IntrusiveList<IDriver, util::IntrusiveListMemberTraitsDeferredAssert<&IDriver::m_list_node>>;
private:
public:
IDriver() : list_node(), device_list(), device_list_lock() {
this->device_list.clear();
IDriver() : m_list_node(), m_device_list(), m_device_list_lock() {
m_device_list.clear();
}
protected:
~IDriver() {
this->device_list.clear();
m_device_list.clear();
}
public:
void AddTo(List &list) {
@ -53,45 +53,45 @@ namespace ams::ddsf {
}
bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}
bool HasAnyDevice() const {
return !this->device_list.empty();
return !m_device_list.empty();
}
void RegisterDevice(IDevice *dev) {
AMS_ASSERT(dev != nullptr);
std::scoped_lock lk(this->device_list_lock);
std::scoped_lock lk(m_device_list_lock);
dev->AttachDriver(this);
this->device_list.push_back(*dev);
m_device_list.push_back(*dev);
}
void UnregisterDevice(IDevice *dev) {
AMS_ASSERT(dev != nullptr);
std::scoped_lock lk(this->device_list_lock);
this->device_list.erase(this->device_list.iterator_to(*dev));
std::scoped_lock lk(m_device_list_lock);
m_device_list.erase(m_device_list.iterator_to(*dev));
dev->DetachDriver();
}
template<typename F>
Result ForEachDevice(F f, bool return_on_fail) {
return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail);
return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail);
}
template<typename F>
Result ForEachDevice(F f, bool return_on_fail) const {
return impl::ForEach(this->device_list_lock, this->device_list, f, return_on_fail);
return impl::ForEach(m_device_list_lock, m_device_list, f, return_on_fail);
}
template<typename F>
int ForEachDevice(F f) {
return impl::ForEach(this->device_list_lock, this->device_list, f);
return impl::ForEach(m_device_list_lock, m_device_list, f);
}
template<typename F>
int ForEachDevice(F f) const {
return impl::ForEach(this->device_list_lock, this->device_list, f);
return impl::ForEach(m_device_list_lock, m_device_list, f);
}
};
static_assert(IDriver::ListTraits::IsValid());

View file

@ -26,22 +26,22 @@ namespace ams::ddsf {
NON_MOVEABLE(IEventHandler);
friend class EventHandlerManager;
private:
os::MultiWaitHolderType holder;
uintptr_t user_data;
bool is_initialized;
bool is_registered;
os::MultiWaitHolderType m_holder;
uintptr_t m_user_data;
bool m_is_initialized;
bool m_is_registered;
private:
void Link(os::MultiWaitType *multi_wait) {
AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(!this->IsRegistered());
AMS_ASSERT(multi_wait != nullptr);
os::LinkMultiWaitHolder(multi_wait, std::addressof(this->holder));
os::LinkMultiWaitHolder(multi_wait, std::addressof(m_holder));
}
void Unlink() {
AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(this->IsRegistered());
os::UnlinkMultiWaitHolder(std::addressof(this->holder));
os::UnlinkMultiWaitHolder(std::addressof(m_holder));
}
static IEventHandler &ToEventHandler(os::MultiWaitHolderType *holder) {
@ -51,7 +51,7 @@ namespace ams::ddsf {
return event_handler;
}
public:
IEventHandler() : holder(), user_data(0), is_initialized(false), is_registered(false) { /* ... */ }
IEventHandler() : m_holder(), m_user_data(0), m_is_initialized(false), m_is_registered(false) { /* ... */ }
~IEventHandler() {
if (this->IsRegistered()) {
@ -62,28 +62,28 @@ namespace ams::ddsf {
}
}
bool IsInitialized() const { return this->is_initialized; }
bool IsRegistered() const { return this->is_registered; }
bool IsInitialized() const { return m_is_initialized; }
bool IsRegistered() const { return m_is_registered; }
uintptr_t GetUserData() const { return this->user_data; }
void SetUserData(uintptr_t d) { this->user_data = d; }
uintptr_t GetUserData() const { return m_user_data; }
void SetUserData(uintptr_t d) { m_user_data = d; }
template<typename T>
void Initialize(T *object) {
AMS_ASSERT(object != nullptr);
AMS_ASSERT(!this->IsInitialized());
os::InitializeMultiWaitHolder(std::addressof(this->holder), object);
os::SetMultiWaitHolderUserData(std::addressof(this->holder), reinterpret_cast<uintptr_t>(this));
this->is_initialized = true;
this->is_registered = false;
os::InitializeMultiWaitHolder(std::addressof(m_holder), object);
os::SetMultiWaitHolderUserData(std::addressof(m_holder), reinterpret_cast<uintptr_t>(this));
m_is_initialized = true;
m_is_registered = false;
}
void Finalize() {
AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(!this->IsRegistered());
os::FinalizeMultiWaitHolder(std::addressof(this->holder));
this->is_initialized = false;
this->is_registered = false;
os::FinalizeMultiWaitHolder(std::addressof(m_holder));
m_is_initialized = false;
m_is_registered = false;
}
protected:
virtual void HandleEvent() = 0;

View file

@ -33,30 +33,30 @@ namespace ams::ddsf {
public:
AMS_DDSF_CASTABLE_ROOT_TRAITS(ams::ddsf::IDevice);
private:
util::IntrusiveListNode list_node;
IDevice *device;
AccessMode access_mode;
util::IntrusiveListNode m_list_node;
IDevice *m_device;
AccessMode m_access_mode;
public:
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::list_node>;
using ListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&ISession::m_list_node>;
using List = typename ListTraits::ListType;
friend class util::IntrusiveList<ISession, util::IntrusiveListMemberTraitsDeferredAssert<&ISession::list_node>>;
friend class util::IntrusiveList<ISession, util::IntrusiveListMemberTraitsDeferredAssert<&ISession::m_list_node>>;
private:
void AttachDevice(IDevice *dev, AccessMode mode) {
AMS_ASSERT(dev != nullptr);
AMS_ASSERT(!this->IsOpen());
this->device = dev;
this->access_mode = mode;
m_device = dev;
m_access_mode = mode;
AMS_ASSERT(this->IsOpen());
}
void DetachDevice() {
AMS_ASSERT(this->IsOpen());
this->device = nullptr;
this->access_mode = AccessMode_None;
m_device = nullptr;
m_access_mode = AccessMode_None;
AMS_ASSERT(!this->IsOpen());
}
public:
ISession() : list_node(), device(nullptr), access_mode() { /* ... */ }
ISession() : m_list_node(), m_device(nullptr), m_access_mode() { /* ... */ }
protected:
~ISession() { this->DetachDevice(); AMS_ASSERT(!this->IsOpen()); }
public:
@ -69,26 +69,26 @@ namespace ams::ddsf {
}
bool IsLinkedToList() const {
return this->list_node.IsLinked();
return m_list_node.IsLinked();
}
IDevice &GetDevice() {
AMS_ASSERT(this->IsOpen());
return *this->device;
return *m_device;
}
const IDevice &GetDevice() const {
AMS_ASSERT(this->IsOpen());
return *this->device;
return *m_device;
}
bool IsOpen() const {
return this->device != nullptr;
return m_device != nullptr;
}
bool CheckAccess(AccessMode mode) const {
AMS_ASSERT(this->IsOpen());
return ((~this->access_mode) & mode) == 0;
return ((~m_access_mode) & mode) == 0;
}
bool CheckExclusiveWrite() const {

View file

@ -37,21 +37,21 @@ namespace ams::ddsf::impl {
class TypeTag {
private:
const char * const class_name;
const TypeTag * const base;
const char * const m_class_name;
const TypeTag * const m_base;
public:
#if !(defined(AMS_BUILD_FOR_DEBUGGING) || defined(AMS_BUILD_FOR_AUDITING))
constexpr TypeTag() : class_name(nullptr), base(nullptr) { /* ... */}
constexpr TypeTag(const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_ASSERT(this != this->base); }
constexpr TypeTag() : m_class_name(nullptr), m_base(nullptr) { /* ... */}
constexpr TypeTag(const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); }
constexpr TypeTag(const char *c) : class_name(nullptr), base(nullptr) { AMS_UNUSED(c); }
constexpr TypeTag(const char *c, const TypeTag &b) : class_name(nullptr), base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != this->base); }
constexpr TypeTag(const char *c) : m_class_name(nullptr), m_base(nullptr) { AMS_UNUSED(c); }
constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(nullptr), m_base(std::addressof(b)) { AMS_UNUSED(c); AMS_ASSERT(this != m_base); }
#else
constexpr TypeTag(const char *c) : class_name(c), base(nullptr) { /* ... */ }
constexpr TypeTag(const char *c, const TypeTag &b) : class_name(c), base(std::addressof(b)) { AMS_ASSERT(this != this->base); }
constexpr TypeTag(const char *c) : m_class_name(c), m_base(nullptr) { /* ... */ }
constexpr TypeTag(const char *c, const TypeTag &b) : m_class_name(c), m_base(std::addressof(b)) { AMS_ASSERT(this != m_base); }
#endif
constexpr const char * GetClassName() const { return this->class_name; }
constexpr const char * GetClassName() const { return m_class_name; }
constexpr bool Is(const TypeTag &rhs) const { return this == std::addressof(rhs); }
@ -61,7 +61,7 @@ namespace ams::ddsf::impl {
if (cur == std::addressof(rhs)) {
return true;
}
cur = cur->base;
cur = cur->m_base;
}
return false;
}

View file

@ -135,8 +135,8 @@ namespace ams::fs {
using DirectoryEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomDirectoryEntry>;
using FileEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomFileEntry>;
private:
DirectoryEntryMapTable dir_table;
FileEntryMapTable file_table;
DirectoryEntryMapTable m_dir_table;
FileEntryMapTable m_file_table;
public:
static s64 QueryDirectoryEntryBucketStorageSize(s64 count);
static size_t QueryDirectoryEntrySize(size_t aux_size);
@ -148,11 +148,11 @@ namespace ams::fs {
HierarchicalRomFileTable();
constexpr u32 GetDirectoryEntryCount() const {
return this->dir_table.GetEntryCount();
return m_dir_table.GetEntryCount();
}
constexpr u32 GetFileEntryCount() const {
return this->file_table.GetEntryCount();
return m_file_table.GetEntryCount();
}
Result Initialize(SubStorage dir_bucket, SubStorage dir_entry, SubStorage file_bucket, SubStorage file_entry);

View file

@ -43,11 +43,11 @@ namespace ams::fs {
};
static_assert(util::is_pod<Element>::value);
private:
s64 bucket_count;
SubStorage bucket_storage;
SubStorage kv_storage;
s64 total_entry_size;
u32 entry_count;
s64 m_bucket_count;
SubStorage m_bucket_storage;
SubStorage m_kv_storage;
s64 m_total_entry_size;
u32 m_entry_count;
public:
static constexpr s64 QueryBucketStorageSize(s64 num) {
return num * sizeof(Position);
@ -69,42 +69,42 @@ namespace ams::fs {
return ResultSuccess();
}
public:
KeyValueRomStorageTemplate() : bucket_count(), bucket_storage(), kv_storage(), total_entry_size(), entry_count() { /* ... */ }
KeyValueRomStorageTemplate() : m_bucket_count(), m_bucket_storage(), m_kv_storage(), m_total_entry_size(), m_entry_count() { /* ... */ }
Result Initialize(const SubStorage &bucket, s64 count, const SubStorage &kv) {
AMS_ASSERT(count > 0);
this->bucket_storage = bucket;
this->bucket_count = count;
this->kv_storage = kv;
m_bucket_storage = bucket;
m_bucket_count = count;
m_kv_storage = kv;
return ResultSuccess();
}
void Finalize() {
this->bucket_storage = SubStorage();
this->kv_storage = SubStorage();
this->bucket_count = 0;
m_bucket_storage = SubStorage();
m_kv_storage = SubStorage();
m_bucket_count = 0;
}
s64 GetTotalEntrySize() const {
return this->total_entry_size;
return m_total_entry_size;
}
Result GetFreeSize(s64 *out) {
AMS_ASSERT(out != nullptr);
s64 kv_size = 0;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
*out = kv_size - this->total_entry_size;
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
*out = kv_size - m_total_entry_size;
return ResultSuccess();
}
constexpr u32 GetEntryCount() const {
return this->entry_count;
return m_entry_count;
}
protected:
Result AddInternal(Position *out, const Key &key, u32 hash_key, const void *aux, size_t aux_size, const Value &value) {
AMS_ASSERT(out != nullptr);
AMS_ASSERT(aux != nullptr || aux_size == 0);
AMS_ASSERT(this->bucket_count > 0);
AMS_ASSERT(m_bucket_count > 0);
{
Position pos, prev_pos;
@ -125,7 +125,7 @@ namespace ams::fs {
R_TRY(this->WriteKeyValue(std::addressof(elem), pos, aux, aux_size));
*out = pos;
this->entry_count++;
m_entry_count++;
return ResultSuccess();
}
@ -178,7 +178,7 @@ namespace ams::fs {
}
private:
BucketIndex HashToBucket(u32 hash_key) const {
return hash_key % this->bucket_count;
return hash_key % m_bucket_count;
}
Result FindInternal(Position *out_pos, Position *out_prev, Element *out_elem, const Key &key, u32 hash_key, const void *aux, size_t aux_size) {
@ -186,7 +186,7 @@ namespace ams::fs {
AMS_ASSERT(out_prev != nullptr);
AMS_ASSERT(out_elem != nullptr);
AMS_ASSERT(aux != nullptr || aux_size == 0);
AMS_ASSERT(this->bucket_count > 0);
AMS_ASSERT(m_bucket_count > 0);
*out_pos = 0;
*out_prev = 0;
@ -197,7 +197,7 @@ namespace ams::fs {
R_TRY(this->ReadBucket(std::addressof(cur), ind));
s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
AMS_ASSERT(cur == InvalidPosition || cur < kv_size);
R_UNLESS(cur != InvalidPosition, fs::ResultDbmKeyNotFound());
@ -225,13 +225,13 @@ namespace ams::fs {
AMS_ASSERT(out != nullptr);
s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
const size_t end_pos = this->total_entry_size + sizeof(Element) + aux_size;
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
const size_t end_pos = m_total_entry_size + sizeof(Element) + aux_size;
R_UNLESS(end_pos <= static_cast<size_t>(kv_size), fs::ResultDbmKeyFull());
*out = static_cast<Position>(this->total_entry_size);
*out = static_cast<Position>(m_total_entry_size);
this->total_entry_size = util::AlignUp(static_cast<s64>(end_pos), alignof(Position));
m_total_entry_size = util::AlignUp(static_cast<s64>(end_pos), alignof(Position));
return ResultSuccess();
}
@ -244,7 +244,7 @@ namespace ams::fs {
R_TRY(this->ReadBucket(std::addressof(next), ind));
s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
AMS_ASSERT(next == InvalidPosition || next < kv_size);
R_TRY(this->WriteBucket(pos, ind));
@ -255,27 +255,27 @@ namespace ams::fs {
Result ReadBucket(Position *out, BucketIndex ind) {
AMS_ASSERT(out != nullptr);
AMS_ASSERT(ind < this->bucket_count);
AMS_ASSERT(ind < m_bucket_count);
const s64 offset = ind * sizeof(Position);
return this->bucket_storage.Read(offset, out, sizeof(*out));
return m_bucket_storage.Read(offset, out, sizeof(*out));
}
Result WriteBucket(Position pos, BucketIndex ind) {
AMS_ASSERT(ind < this->bucket_count);
AMS_ASSERT(ind < m_bucket_count);
const s64 offset = ind * sizeof(Position);
return this->bucket_storage.Write(offset, std::addressof(pos), sizeof(pos));
return m_bucket_storage.Write(offset, std::addressof(pos), sizeof(pos));
}
Result ReadKeyValue(Element *out, Position pos) {
AMS_ASSERT(out != nullptr);
s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
AMS_ASSERT(pos < kv_size);
return this->kv_storage.Read(pos, out, sizeof(*out));
return m_kv_storage.Read(pos, out, sizeof(*out));
}
Result ReadKeyValue(Element *out, void *out_aux, size_t *out_aux_size, Position pos) {
@ -287,7 +287,7 @@ namespace ams::fs {
*out_aux_size = out->size;
if (out->size > 0) {
R_TRY(this->kv_storage.Read(pos + sizeof(*out), out_aux, out->size));
R_TRY(m_kv_storage.Read(pos + sizeof(*out), out_aux, out->size));
}
return ResultSuccess();
@ -298,13 +298,13 @@ namespace ams::fs {
AMS_ASSERT(aux != nullptr);
s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size)));
R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
AMS_ASSERT(pos < kv_size);
R_TRY(this->kv_storage.Write(pos, elem, sizeof(*elem)));
R_TRY(m_kv_storage.Write(pos, elem, sizeof(*elem)));
if (aux != nullptr && aux_size > 0) {
R_TRY(this->kv_storage.Write(pos + sizeof(*elem), aux, aux_size));
R_TRY(m_kv_storage.Write(pos + sizeof(*elem), aux, aux_size));
}
return ResultSuccess();

View file

@ -81,12 +81,12 @@ namespace ams::fs::RomPathTool {
class PathParser {
private:
const RomPathChar *prev_path_start;
const RomPathChar *prev_path_end;
const RomPathChar *next_path;
bool finished;
const RomPathChar *m_prev_path_start;
const RomPathChar *m_prev_path_end;
const RomPathChar *m_next_path;
bool m_finished;
public:
constexpr PathParser() : prev_path_start(), prev_path_end(), next_path(), finished() { /* ... */ }
constexpr PathParser() : m_prev_path_start(), m_prev_path_end(), m_next_path(), m_finished() { /* ... */ }
Result Initialize(const RomPathChar *path);
void Finalize();

View file

@ -28,42 +28,42 @@ namespace ams::fs {
private:
static constexpr s64 InvalidSize = -1;
private:
std::unique_ptr<fsa::IFile> unique_file;
std::shared_ptr<fsa::IFile> shared_file;
fsa::IFile *base_file;
s64 size;
std::unique_ptr<fsa::IFile> m_unique_file;
std::shared_ptr<fsa::IFile> m_shared_file;
fsa::IFile *m_base_file;
s64 m_size;
public:
FileStorage(fsa::IFile *f) : unique_file(f), size(InvalidSize) {
this->base_file = this->unique_file.get();
FileStorage(fsa::IFile *f) : m_unique_file(f), m_size(InvalidSize) {
m_base_file = m_unique_file.get();
}
FileStorage(std::unique_ptr<fsa::IFile> f) : unique_file(std::move(f)), size(InvalidSize) {
this->base_file = this->unique_file.get();
FileStorage(std::unique_ptr<fsa::IFile> f) : m_unique_file(std::move(f)), m_size(InvalidSize) {
m_base_file = m_unique_file.get();
}
FileStorage(std::shared_ptr<fsa::IFile> f) : shared_file(f), size(InvalidSize) {
this->base_file = this->shared_file.get();
FileStorage(std::shared_ptr<fsa::IFile> f) : m_shared_file(f), m_size(InvalidSize) {
m_base_file = m_shared_file.get();
}
virtual ~FileStorage() { /* ... */ }
private:
Result UpdateSize();
protected:
constexpr FileStorage() : unique_file(), shared_file(), base_file(nullptr), size(InvalidSize) { /* ... */ }
constexpr FileStorage() : m_unique_file(), m_shared_file(), m_base_file(nullptr), m_size(InvalidSize) { /* ... */ }
void SetFile(fs::fsa::IFile *file) {
AMS_ASSERT(file != nullptr);
AMS_ASSERT(this->base_file == nullptr);
this->base_file = file;
AMS_ASSERT(m_base_file == nullptr);
m_base_file = file;
}
void SetFile(std::unique_ptr<fs::fsa::IFile> &&file) {
AMS_ASSERT(file != nullptr);
AMS_ASSERT(this->base_file == nullptr);
AMS_ASSERT(this->unique_file == nullptr);
AMS_ASSERT(m_base_file == nullptr);
AMS_ASSERT(m_unique_file == nullptr);
this->unique_file = std::move(file);
this->base_file = this->unique_file.get();
m_unique_file = std::move(file);
m_base_file = m_unique_file.get();
}
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override;
@ -78,9 +78,9 @@ namespace ams::fs {
NON_COPYABLE(FileStorageBasedFileSystem);
NON_MOVEABLE(FileStorageBasedFileSystem);
private:
std::shared_ptr<fs::fsa::IFileSystem> base_file_system;
std::shared_ptr<fs::fsa::IFileSystem> m_base_file_system;
public:
constexpr FileStorageBasedFileSystem() : FileStorage(), base_file_system(nullptr) { /* ... */ }
constexpr FileStorageBasedFileSystem() : FileStorage(), m_base_file_system(nullptr) { /* ... */ }
Result Initialize(std::shared_ptr<fs::fsa::IFileSystem> base_file_system, const char *path, fs::OpenMode mode);
};
@ -89,17 +89,17 @@ namespace ams::fs {
private:
static constexpr s64 InvalidSize = -1;
private:
FileHandle handle;
bool close_file;
s64 size;
os::SdkMutex mutex;
FileHandle m_handle;
bool m_close_file;
s64 m_size;
os::SdkMutex m_mutex;
public:
constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : handle(handle), close_file(close_file), size(InvalidSize), mutex() { /* ... */ }
constexpr explicit FileHandleStorage(FileHandle handle, bool close_file) : m_handle(handle), m_close_file(close_file), m_size(InvalidSize), m_mutex() { /* ... */ }
constexpr explicit FileHandleStorage(FileHandle handle) : FileHandleStorage(handle, false) { /* ... */ }
virtual ~FileHandleStorage() override {
if (this->close_file) {
CloseFile(this->handle);
if (m_close_file) {
CloseFile(m_handle);
}
}
protected:

View file

@ -28,13 +28,13 @@ namespace ams::fs {
class FsContext {
private:
ResultHandler handler;
ResultHandler m_handler;
public:
constexpr explicit FsContext(ResultHandler h) : handler(h) { /* ... */ }
constexpr explicit FsContext(ResultHandler h) : m_handler(h) { /* ... */ }
constexpr void SetHandler(ResultHandler h) { this->handler = h; }
constexpr void SetHandler(ResultHandler h) { m_handler = h; }
constexpr AbortSpecifier HandleResult(Result result) const { return this->handler(result); }
constexpr AbortSpecifier HandleResult(Result result) const { return m_handler(result); }
};
void SetDefaultFsContextResultHandler(const ResultHandler handler);
@ -44,24 +44,24 @@ namespace ams::fs {
class ScopedFsContext {
private:
const FsContext * const prev_context;
const FsContext * const m_prev_context;
public:
ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : prev_context(GetCurrentThreadFsContext()) {
ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : m_prev_context(GetCurrentThreadFsContext()) {
SetCurrentThreadFsContext(std::addressof(ctx));
}
ALWAYS_INLINE ~ScopedFsContext() {
SetCurrentThreadFsContext(this->prev_context);
SetCurrentThreadFsContext(m_prev_context);
}
};
class ScopedAutoAbortDisabler {
private:
const FsContext * const prev_context;
const FsContext * const m_prev_context;
public:
ScopedAutoAbortDisabler();
ALWAYS_INLINE ~ScopedAutoAbortDisabler() {
SetCurrentThreadFsContext(this->prev_context);
SetCurrentThreadFsContext(m_prev_context);
}
};

View file

@ -19,7 +19,7 @@
namespace ams::fs {
struct ReadOption {
u32 value;
u32 _value;
static const ReadOption None;
};
@ -27,7 +27,7 @@ namespace ams::fs {
inline constexpr const ReadOption ReadOption::None = {FsReadOption_None};
inline constexpr bool operator==(const ReadOption &lhs, const ReadOption &rhs) {
return lhs.value == rhs.value;
return lhs._value == rhs._value;
}
inline constexpr bool operator!=(const ReadOption &lhs, const ReadOption &rhs) {
@ -37,10 +37,10 @@ namespace ams::fs {
static_assert(util::is_pod<ReadOption>::value && sizeof(ReadOption) == sizeof(u32));
struct WriteOption {
u32 value;
u32 _value;
constexpr inline bool HasFlushFlag() const {
return this->value & FsWriteOption_Flush;
return _value & FsWriteOption_Flush;
}
static const WriteOption None;
@ -51,7 +51,7 @@ namespace ams::fs {
inline constexpr const WriteOption WriteOption::Flush = {FsWriteOption_Flush};
inline constexpr bool operator==(const WriteOption &lhs, const WriteOption &rhs) {
return lhs.value == rhs.value;
return lhs._value == rhs._value;
}
inline constexpr bool operator!=(const WriteOption &lhs, const WriteOption &rhs) {

View file

@ -64,36 +64,36 @@ namespace ams::fs {
class ReadOnlyStorageAdapter : public IStorage {
private:
std::shared_ptr<IStorage> shared_storage;
std::unique_ptr<IStorage> unique_storage;
IStorage *storage;
std::shared_ptr<IStorage> m_shared_storage;
std::unique_ptr<IStorage> m_unique_storage;
IStorage *m_storage;
public:
ReadOnlyStorageAdapter(IStorage *s) : unique_storage(s) {
this->storage = this->unique_storage.get();
ReadOnlyStorageAdapter(IStorage *s) : m_unique_storage(s) {
m_storage = m_unique_storage.get();
}
ReadOnlyStorageAdapter(std::shared_ptr<IStorage> s) : shared_storage(s) {
this->storage = this->shared_storage.get();
ReadOnlyStorageAdapter(std::shared_ptr<IStorage> s) : m_shared_storage(s) {
m_storage = m_shared_storage.get();
}
ReadOnlyStorageAdapter(std::unique_ptr<IStorage> s) : unique_storage(std::move(s)) {
this->storage = this->unique_storage.get();
ReadOnlyStorageAdapter(std::unique_ptr<IStorage> s) : m_unique_storage(std::move(s)) {
m_storage = m_unique_storage.get();
}
virtual ~ReadOnlyStorageAdapter() { /* ... */ }
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
return this->storage->Read(offset, buffer, size);
return m_storage->Read(offset, buffer, size);
}
virtual Result Flush() override {
return this->storage->Flush();
return m_storage->Flush();
}
virtual Result GetSize(s64 *out) override {
return this->storage->GetSize(out);
return m_storage->GetSize(out);
}
virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {
return this->storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
return m_storage->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override {

View file

@ -30,13 +30,13 @@ namespace ams::fs {
class Deleter {
private:
size_t size;
size_t m_size;
public:
Deleter() : size() { /* ... */ }
explicit Deleter(size_t sz) : size(sz) { /* ... */ }
Deleter() : m_size() { /* ... */ }
explicit Deleter(size_t sz) : m_size(sz) { /* ... */ }
void operator()(void *ptr) const {
::ams::fs::impl::Deallocate(ptr, this->size);
::ams::fs::impl::Deallocate(ptr, m_size);
}
};

View file

@ -22,21 +22,21 @@ namespace ams::fs {
class MemoryStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
u8 * const buf;
const s64 size;
u8 * const m_buf;
const s64 m_size;
public:
MemoryStorage(void *b, s64 sz) : buf(static_cast<u8 *>(b)), size(sz) { /* .. */ }
MemoryStorage(void *b, s64 sz) : m_buf(static_cast<u8 *>(b)), m_size(sz) { /* .. */ }
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
/* Succeed immediately on zero-sized read. */
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange());
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
/* Copy from memory. */
std::memcpy(buffer, this->buf + offset, size);
std::memcpy(buffer, m_buf + offset, size);
return ResultSuccess();
}
@ -45,11 +45,11 @@ namespace ams::fs {
R_SUCCEED_IF(size == 0);
/* Validate arguments. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange());
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
/* Copy to memory. */
std::memcpy(this->buf + offset, buffer, size);
std::memcpy(m_buf + offset, buffer, size);
return ResultSuccess();
}
@ -58,7 +58,7 @@ namespace ams::fs {
}
virtual Result GetSize(s64 *out) override {
*out = this->size;
*out = m_size;
return ResultSuccess();
}

View file

@ -28,17 +28,17 @@ namespace ams::fs {
NON_COPYABLE(ReadOnlyFile);
NON_MOVEABLE(ReadOnlyFile);
private:
std::unique_ptr<fsa::IFile> base_file;
std::unique_ptr<fsa::IFile> m_base_file;
public:
explicit ReadOnlyFile(std::unique_ptr<fsa::IFile> &&f) : base_file(std::move(f)) { /* ... */ }
explicit ReadOnlyFile(std::unique_ptr<fsa::IFile> &&f) : m_base_file(std::move(f)) { /* ... */ }
virtual ~ReadOnlyFile() { /* ... */ }
private:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final {
return this->base_file->Read(out, offset, buffer, size, option);
return m_base_file->Read(out, offset, buffer, size, option);
}
virtual Result DoGetSize(s64 *out) override final {
return this->base_file->GetSize(out);
return m_base_file->GetSize(out);
}
virtual Result DoFlush() override final {
@ -59,14 +59,14 @@ namespace ams::fs {
switch (op_id) {
case OperationId::Invalidate:
case OperationId::QueryRange:
return this->base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
return m_base_file->OperateRange(dst, dst_size, op_id, offset, size, src, src_size);
default:
return fs::ResultUnsupportedOperationInReadOnlyFileB();
}
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override {
return this->base_file->GetDomainObjectId();
return m_base_file->GetDomainObjectId();
}
};
@ -77,9 +77,9 @@ namespace ams::fs {
NON_COPYABLE(ReadOnlyFileSystemTemplate);
NON_MOVEABLE(ReadOnlyFileSystemTemplate);
private:
T base_fs;
T m_base_fs;
public:
explicit ReadOnlyFileSystemTemplate(T &&fs) : base_fs(std::move(fs)) { /* ... */ }
explicit ReadOnlyFileSystemTemplate(T &&fs) : m_base_fs(std::move(fs)) { /* ... */ }
virtual ~ReadOnlyFileSystemTemplate() { /* ... */ }
private:
virtual Result DoOpenFile(std::unique_ptr<fsa::IFile> *out_file, const char *path, OpenMode mode) override final {
@ -87,7 +87,7 @@ namespace ams::fs {
R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode());
std::unique_ptr<fsa::IFile> base_file;
R_TRY(this->base_fs->OpenFile(std::addressof(base_file), path, mode));
R_TRY(m_base_fs->OpenFile(std::addressof(base_file), path, mode));
auto read_only_file = std::make_unique<ReadOnlyFile>(std::move(base_file));
R_UNLESS(read_only_file != nullptr, fs::ResultAllocationFailureInReadOnlyFileSystemA());
@ -97,11 +97,11 @@ namespace ams::fs {
}
virtual Result DoOpenDirectory(std::unique_ptr<fsa::IDirectory> *out_dir, const char *path, OpenDirectoryMode mode) override final {
return this->base_fs->OpenDirectory(out_dir, path, mode);
return m_base_fs->OpenDirectory(out_dir, path, mode);
}
virtual Result DoGetEntryType(DirectoryEntryType *out, const char *path) override final {
return this->base_fs->GetEntryType(out, path);
return m_base_fs->GetEntryType(out, path);
}
virtual Result DoCommit() override final {

View file

@ -26,30 +26,30 @@ namespace ams::fs {
class RemoteFile : public fsa::IFile, public impl::Newable {
private:
::FsFile base_file;
::FsFile m_base_file;
public:
RemoteFile(const ::FsFile &f) : base_file(f) { /* ... */ }
RemoteFile(const ::FsFile &f) : m_base_file(f) { /* ... */ }
virtual ~RemoteFile() { fsFileClose(std::addressof(this->base_file)); }
virtual ~RemoteFile() { fsFileClose(std::addressof(m_base_file)); }
public:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final {
return fsFileRead(std::addressof(this->base_file), offset, buffer, size, option.value, out);
return fsFileRead(std::addressof(m_base_file), offset, buffer, size, option._value, out);
}
virtual Result DoGetSize(s64 *out) override final {
return fsFileGetSize(std::addressof(this->base_file), out);
return fsFileGetSize(std::addressof(m_base_file), out);
}
virtual Result DoFlush() override final {
return fsFileFlush(std::addressof(this->base_file));
return fsFileFlush(std::addressof(m_base_file));
}
virtual Result DoWrite(s64 offset, const void *buffer, size_t size, const fs::WriteOption &option) override final {
return fsFileWrite(std::addressof(this->base_file), offset, buffer, size, option.value);
return fsFileWrite(std::addressof(m_base_file), offset, buffer, size, option._value);
}
virtual Result DoSetSize(s64 size) override final {
return fsFileSetSize(std::addressof(this->base_file), size);
return fsFileSetSize(std::addressof(m_base_file), size);
}
virtual Result DoOperateRange(void *dst, size_t dst_size, fs::OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override final {
@ -58,42 +58,42 @@ namespace ams::fs {
R_UNLESS(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperationInFileServiceObjectAdapterA());
R_UNLESS(dst_size == sizeof(FileQueryRangeInfo), fs::ResultInvalidSize());
return fsFileOperateRange(std::addressof(this->base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst));
return fsFileOperateRange(std::addressof(m_base_file), static_cast<::FsOperationId>(op_id), offset, size, reinterpret_cast<::FsRangeInfo *>(dst));
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override {
return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(this->base_file.s)))};
return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(m_base_file.s)))};
}
};
class RemoteDirectory : public fsa::IDirectory, public impl::Newable {
private:
::FsDir base_dir;
::FsDir m_base_dir;
public:
RemoteDirectory(const ::FsDir &d) : base_dir(d) { /* ... */ }
RemoteDirectory(const ::FsDir &d) : m_base_dir(d) { /* ... */ }
virtual ~RemoteDirectory() { fsDirClose(std::addressof(this->base_dir)); }
virtual ~RemoteDirectory() { fsDirClose(std::addressof(m_base_dir)); }
public:
virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final {
return fsDirRead(std::addressof(this->base_dir), out_count, max_entries, out_entries);
return fsDirRead(std::addressof(m_base_dir), out_count, max_entries, out_entries);
}
virtual Result DoGetEntryCount(s64 *out) override final {
return fsDirGetEntryCount(std::addressof(this->base_dir), out);
return fsDirGetEntryCount(std::addressof(m_base_dir), out);
}
public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override {
return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(this->base_dir.s)))};
return sf::cmif::DomainObjectId{serviceGetObjectId(const_cast<::Service *>(std::addressof(m_base_dir.s)))};
}
};
class RemoteFileSystem : public fsa::IFileSystem, public impl::Newable {
private:
::FsFileSystem base_fs;
::FsFileSystem m_base_fs;
public:
RemoteFileSystem(const ::FsFileSystem &fs) : base_fs(fs) { /* ... */ }
RemoteFileSystem(const ::FsFileSystem &fs) : m_base_fs(fs) { /* ... */ }
virtual ~RemoteFileSystem() { fsFsClose(std::addressof(this->base_fs)); }
virtual ~RemoteFileSystem() { fsFsClose(std::addressof(m_base_fs)); }
private:
Result GetPathForServiceObject(fssrv::sf::Path *out_path, const char *path) {
/* Copy and null terminate. */
@ -113,31 +113,31 @@ namespace ams::fs {
virtual Result DoCreateFile(const char *path, s64 size, int flags) override final {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsCreateFile(std::addressof(this->base_fs), sf_path.str, size, flags);
return fsFsCreateFile(std::addressof(m_base_fs), sf_path.str, size, flags);
}
virtual Result DoDeleteFile(const char *path) override final {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsDeleteFile(std::addressof(this->base_fs), sf_path.str);
return fsFsDeleteFile(std::addressof(m_base_fs), sf_path.str);
}
virtual Result DoCreateDirectory(const char *path) override final {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsCreateDirectory(std::addressof(this->base_fs), sf_path.str);
return fsFsCreateDirectory(std::addressof(m_base_fs), sf_path.str);
}
virtual Result DoDeleteDirectory(const char *path) override final {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsDeleteDirectory(std::addressof(this->base_fs), sf_path.str);
return fsFsDeleteDirectory(std::addressof(m_base_fs), sf_path.str);
}
virtual Result DoDeleteDirectoryRecursively(const char *path) override final {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsDeleteDirectoryRecursively(std::addressof(this->base_fs), sf_path.str);
return fsFsDeleteDirectoryRecursively(std::addressof(m_base_fs), sf_path.str);
}
virtual Result DoRenameFile(const char *old_path, const char *new_path) override final {
@ -145,7 +145,7 @@ namespace ams::fs {
fssrv::sf::Path new_sf_path;
R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path));
R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path));
return fsFsRenameFile(std::addressof(this->base_fs), old_sf_path.str, new_sf_path.str);
return fsFsRenameFile(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str);
}
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override final {
@ -153,7 +153,7 @@ namespace ams::fs {
fssrv::sf::Path new_sf_path;
R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path));
R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_path));
return fsFsRenameDirectory(std::addressof(this->base_fs), old_sf_path.str, new_sf_path.str);
return fsFsRenameDirectory(std::addressof(m_base_fs), old_sf_path.str, new_sf_path.str);
}
virtual Result DoGetEntryType(DirectoryEntryType *out, const char *path) override final {
@ -161,7 +161,7 @@ namespace ams::fs {
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
static_assert(sizeof(::FsDirEntryType) == sizeof(DirectoryEntryType));
return fsFsGetEntryType(std::addressof(this->base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out));
return fsFsGetEntryType(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsDirEntryType *>(out));
}
virtual Result DoOpenFile(std::unique_ptr<fsa::IFile> *out_file, const char *path, OpenMode mode) override final {
@ -169,7 +169,7 @@ namespace ams::fs {
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
FsFile f;
R_TRY(fsFsOpenFile(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(f)));
R_TRY(fsFsOpenFile(std::addressof(m_base_fs), sf_path.str, mode, std::addressof(f)));
auto file = std::make_unique<RemoteFile>(f);
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew());
@ -183,7 +183,7 @@ namespace ams::fs {
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
FsDir d;
R_TRY(fsFsOpenDirectory(std::addressof(this->base_fs), sf_path.str, mode, std::addressof(d)));
R_TRY(fsFsOpenDirectory(std::addressof(m_base_fs), sf_path.str, mode, std::addressof(d)));
auto dir = std::make_unique<RemoteDirectory>(d);
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew());
@ -193,39 +193,39 @@ namespace ams::fs {
}
virtual Result DoCommit() override final {
return fsFsCommit(std::addressof(this->base_fs));
return fsFsCommit(std::addressof(m_base_fs));
}
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsGetFreeSpace(std::addressof(this->base_fs), sf_path.str, out);
return fsFsGetFreeSpace(std::addressof(m_base_fs), sf_path.str, out);
}
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsGetTotalSpace(std::addressof(this->base_fs), sf_path.str, out);
return fsFsGetTotalSpace(std::addressof(m_base_fs), sf_path.str, out);
}
virtual Result DoCleanDirectoryRecursively(const char *path) {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsCleanDirectoryRecursively(std::addressof(this->base_fs), sf_path.str);
return fsFsCleanDirectoryRecursively(std::addressof(m_base_fs), sf_path.str);
}
virtual Result DoGetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
static_assert(sizeof(FileTimeStampRaw) == sizeof(::FsTimeStampRaw));
return fsFsGetFileTimeStampRaw(std::addressof(this->base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out));
return fsFsGetFileTimeStampRaw(std::addressof(m_base_fs), sf_path.str, reinterpret_cast<::FsTimeStampRaw *>(out));
}
virtual Result DoQueryEntry(char *dst, size_t dst_size, const char *src, size_t src_size, fsa::QueryId query, const char *path) {
fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
return fsFsQueryEntry(std::addressof(this->base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast<FsFileSystemQueryId>(query));
return fsFsQueryEntry(std::addressof(m_base_fs), dst, dst_size, src, src_size, sf_path.str, static_cast<FsFileSystemQueryId>(query));
}
};

View file

@ -22,33 +22,33 @@ namespace ams::fs {
class RemoteStorage : public IStorage, public impl::Newable {
private:
std::unique_ptr<::FsStorage, impl::Deleter> base_storage;
std::unique_ptr<::FsStorage, impl::Deleter> m_base_storage;
public:
RemoteStorage(::FsStorage &s) {
this->base_storage = impl::MakeUnique<::FsStorage>();
*this->base_storage = s;
m_base_storage = impl::MakeUnique<::FsStorage>();
*m_base_storage = s;
}
virtual ~RemoteStorage() { fsStorageClose(this->base_storage.get()); }
virtual ~RemoteStorage() { fsStorageClose(m_base_storage.get()); }
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
return fsStorageRead(this->base_storage.get(), offset, buffer, size);
return fsStorageRead(m_base_storage.get(), offset, buffer, size);
};
virtual Result Write(s64 offset, const void *buffer, size_t size) override {
return fsStorageWrite(this->base_storage.get(), offset, buffer, size);
return fsStorageWrite(m_base_storage.get(), offset, buffer, size);
};
virtual Result Flush() override {
return fsStorageFlush(this->base_storage.get());
return fsStorageFlush(m_base_storage.get());
};
virtual Result GetSize(s64 *out_size) override {
return fsStorageGetSize(this->base_storage.get(), out_size);
return fsStorageGetSize(m_base_storage.get(), out_size);
};
virtual Result SetSize(s64 size) override {
return fsStorageSetSize(this->base_storage.get(), size);
return fsStorageSetSize(m_base_storage.get(), size);
};
virtual Result OperateRange(void *dst, size_t dst_size, OperationId op_id, s64 offset, s64 size, const void *src, size_t src_size) override {

View file

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

View file

@ -26,29 +26,29 @@ namespace ams::fs {
NON_COPYABLE(SharedFileSystemHolder);
NON_MOVEABLE(SharedFileSystemHolder);
private:
std::shared_ptr<fsa::IFileSystem> fs;
std::shared_ptr<fsa::IFileSystem> m_fs;
public:
SharedFileSystemHolder(std::shared_ptr<fsa::IFileSystem> f) : fs(std::move(f)) { /* ... */ }
SharedFileSystemHolder(std::shared_ptr<fsa::IFileSystem> f) : m_fs(std::move(f)) { /* ... */ }
public:
virtual Result DoCreateFile(const char *path, s64 size, int flags) override { return this->fs->CreateFile(path, size, flags); }
virtual Result DoDeleteFile(const char *path) override { return this->fs->DeleteFile(path); }
virtual Result DoCreateDirectory(const char *path) override { return this->fs->CreateDirectory(path); }
virtual Result DoDeleteDirectory(const char *path) override { return this->fs->DeleteDirectory(path); }
virtual Result DoDeleteDirectoryRecursively(const char *path) override { return this->fs->DeleteDirectoryRecursively(path); }
virtual Result DoRenameFile(const char *old_path, const char *new_path) override { return this->fs->RenameFile(old_path, new_path); }
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override { return this->fs->RenameDirectory(old_path, new_path); }
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override { return this->fs->GetEntryType(out, path); }
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const char *path, fs::OpenMode mode) override { return this->fs->OpenFile(out_file, path, mode); }
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const char *path, fs::OpenDirectoryMode mode) override { return this->fs->OpenDirectory(out_dir, path, mode); }
virtual Result DoCommit() override { return this->fs->Commit(); }
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { return this->fs->GetFreeSpaceSize(out, path); }
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override { return this->fs->GetTotalSpaceSize(out, path); }
virtual Result DoCleanDirectoryRecursively(const char *path) override { return this->fs->CleanDirectoryRecursively(path); }
virtual Result DoCreateFile(const char *path, s64 size, int flags) override { return m_fs->CreateFile(path, size, flags); }
virtual Result DoDeleteFile(const char *path) override { return m_fs->DeleteFile(path); }
virtual Result DoCreateDirectory(const char *path) override { return m_fs->CreateDirectory(path); }
virtual Result DoDeleteDirectory(const char *path) override { return m_fs->DeleteDirectory(path); }
virtual Result DoDeleteDirectoryRecursively(const char *path) override { return m_fs->DeleteDirectoryRecursively(path); }
virtual Result DoRenameFile(const char *old_path, const char *new_path) override { return m_fs->RenameFile(old_path, new_path); }
virtual Result DoRenameDirectory(const char *old_path, const char *new_path) override { return m_fs->RenameDirectory(old_path, new_path); }
virtual Result DoGetEntryType(fs::DirectoryEntryType *out, const char *path) override { return m_fs->GetEntryType(out, path); }
virtual Result DoOpenFile(std::unique_ptr<fs::fsa::IFile> *out_file, const char *path, fs::OpenMode mode) override { return m_fs->OpenFile(out_file, path, mode); }
virtual Result DoOpenDirectory(std::unique_ptr<fs::fsa::IDirectory> *out_dir, const char *path, fs::OpenDirectoryMode mode) override { return m_fs->OpenDirectory(out_dir, path, mode); }
virtual Result DoCommit() override { return m_fs->Commit(); }
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { return m_fs->GetFreeSpaceSize(out, path); }
virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) override { return m_fs->GetTotalSpaceSize(out, path); }
virtual Result DoCleanDirectoryRecursively(const char *path) override { return m_fs->CleanDirectoryRecursively(path); }
/* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override { return this->fs->CommitProvisionally(counter); }
virtual Result DoRollback() override { return this->fs->Rollback(); }
virtual Result DoFlush() override { return this->fs->Flush(); }
virtual Result DoCommitProvisionally(s64 counter) override { return m_fs->CommitProvisionally(counter); }
virtual Result DoRollback() override { return m_fs->Rollback(); }
virtual Result DoFlush() override { return m_fs->Flush(); }
};
}

View file

@ -21,51 +21,51 @@ namespace ams::fs {
class SubStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
std::shared_ptr<IStorage> shared_base_storage;
fs::IStorage *base_storage;
s64 offset;
s64 size;
bool resizable;
std::shared_ptr<IStorage> m_shared_base_storage;
fs::IStorage *m_base_storage;
s64 m_offset;
s64 m_size;
bool m_resizable;
private:
constexpr bool IsValid() const {
return this->base_storage != nullptr;
return m_base_storage != nullptr;
}
public:
SubStorage() : shared_base_storage(), base_storage(nullptr), offset(0), size(0), resizable(false) { /* ... */ }
SubStorage() : m_shared_base_storage(), m_base_storage(nullptr), m_offset(0), m_size(0), m_resizable(false) { /* ... */ }
SubStorage(const SubStorage &rhs) : shared_base_storage(), base_storage(rhs.base_storage), offset(rhs.offset), size(rhs.size), resizable(rhs.resizable) { /* ... */}
SubStorage(const SubStorage &rhs) : m_shared_base_storage(), m_base_storage(rhs.m_base_storage), m_offset(rhs.m_offset), m_size(rhs.m_size), m_resizable(rhs.m_resizable) { /* ... */}
SubStorage &operator=(const SubStorage &rhs) {
if (this != std::addressof(rhs)) {
this->base_storage = rhs.base_storage;
this->offset = rhs.offset;
this->size = rhs.size;
this->resizable = rhs.resizable;
m_base_storage = rhs.m_base_storage;
m_offset = rhs.m_offset;
m_size = rhs.m_size;
m_resizable = rhs.m_resizable;
}
return *this;
}
SubStorage(IStorage *storage, s64 o, s64 sz) : shared_base_storage(), base_storage(storage), offset(o), size(sz), resizable(false) {
SubStorage(IStorage *storage, s64 o, s64 sz) : m_shared_base_storage(), m_base_storage(storage), m_offset(o), m_size(sz), m_resizable(false) {
AMS_ABORT_UNLESS(this->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0);
AMS_ABORT_UNLESS(this->size >= 0);
AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(m_size >= 0);
}
SubStorage(std::shared_ptr<IStorage> storage, s64 o, s64 sz) : shared_base_storage(storage), base_storage(storage.get()), offset(o), size(sz), resizable(false) {
SubStorage(std::shared_ptr<IStorage> storage, s64 o, s64 sz) : m_shared_base_storage(storage), m_base_storage(storage.get()), m_offset(o), m_size(sz), m_resizable(false) {
AMS_ABORT_UNLESS(this->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0);
AMS_ABORT_UNLESS(this->size >= 0);
AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(m_size >= 0);
}
SubStorage(SubStorage *sub, s64 o, s64 sz) : shared_base_storage(), base_storage(sub->base_storage), offset(o + sub->offset), size(sz), resizable(false) {
SubStorage(SubStorage *sub, s64 o, s64 sz) : m_shared_base_storage(), m_base_storage(sub->m_base_storage), m_offset(o + sub->m_offset), m_size(sz), m_resizable(false) {
AMS_ABORT_UNLESS(this->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0);
AMS_ABORT_UNLESS(this->size >= 0);
AMS_ABORT_UNLESS(sub->size >= o + sz);
AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(m_size >= 0);
AMS_ABORT_UNLESS(sub->m_size >= o + sz);
}
public:
void SetResizable(bool rsz) {
this->resizable = rsz;
m_resizable = rsz;
}
public:
virtual Result Read(s64 offset, void *buffer, size_t size) override {
@ -77,9 +77,9 @@ namespace ams::fs {
/* Validate arguments and read. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange());
return this->base_storage->Read(this->offset + offset, buffer, size);
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
return m_base_storage->Read(m_offset + offset, buffer, size);
}
virtual Result Write(s64 offset, const void *buffer, size_t size) override{
@ -90,31 +90,31 @@ namespace ams::fs {
R_SUCCEED_IF(size == 0);
/* Validate arguments and write. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange());
return this->base_storage->Write(this->offset + offset, buffer, size);
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
return m_base_storage->Write(m_offset + offset, buffer, size);
}
virtual Result Flush() override {
R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
return this->base_storage->Flush();
return m_base_storage->Flush();
}
virtual Result SetSize(s64 size) override {
/* Ensure we're initialized and validate arguments. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
R_UNLESS(this->resizable, fs::ResultUnsupportedOperationInSubStorageA());
R_UNLESS(IStorage::CheckOffsetAndSize(this->offset, size), fs::ResultInvalidSize());
R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
R_UNLESS(m_resizable, fs::ResultUnsupportedOperationInSubStorageA());
R_UNLESS(IStorage::CheckOffsetAndSize(m_offset, size), fs::ResultInvalidSize());
/* Ensure that we're allowed to set size. */
s64 cur_size;
R_TRY(this->base_storage->GetSize(std::addressof(cur_size)));
R_UNLESS(cur_size == this->offset + this->size, fs::ResultUnsupportedOperationInSubStorageB());
R_TRY(m_base_storage->GetSize(std::addressof(cur_size)));
R_UNLESS(cur_size == m_offset + m_size, fs::ResultUnsupportedOperationInSubStorageB());
/* Set the size. */
R_TRY(this->base_storage->SetSize(this->offset + size));
R_TRY(m_base_storage->SetSize(m_offset + size));
this->size = size;
m_size = size;
return ResultSuccess();
}
@ -122,7 +122,7 @@ namespace ams::fs {
/* Ensure we're initialized. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
*out = this->size;
*out = m_size;
return ResultSuccess();
}
@ -135,7 +135,7 @@ namespace ams::fs {
/* Validate arguments and operate. */
R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange());
return this->base_storage->OperateRange(dst, dst_size, op_id, this->offset + offset, size, src, src_size);
return m_base_storage->OperateRange(dst, dst_size, op_id, m_offset + offset, size, src, src_size);
}
using IStorage::OperateRange;

View file

@ -66,7 +66,7 @@ namespace ams::fs::impl {
class IdString {
private:
char buffer[0x20];
char m_buffer[0x20];
private:
const char *ToValueString(int id);
public:

View file

@ -23,9 +23,9 @@ namespace ams::fssrv::fscreator {
NON_COPYABLE(RomFileSystemCreator);
NON_MOVEABLE(RomFileSystemCreator);
private:
MemoryResource *allocator;
MemoryResource *m_allocator;
public:
explicit RomFileSystemCreator(MemoryResource *mr) : allocator(mr) { /* ... */ }
explicit RomFileSystemCreator(MemoryResource *mr) : m_allocator(mr) { /* ... */ }
virtual Result Create(std::shared_ptr<fs::fsa::IFileSystem> *out, std::shared_ptr<fs::IStorage> storage) override;
};

View file

@ -30,15 +30,15 @@ namespace ams::fssrv::fscreator {
NON_COPYABLE(StorageOnNcaCreator);
NON_MOVEABLE(StorageOnNcaCreator);
private:
MemoryResource *allocator;
fssystem::IBufferManager * const buffer_manager;
const fssystem::NcaCryptoConfiguration &nca_crypto_cfg;
bool is_prod;
bool is_enabled_program_verification;
MemoryResource *m_allocator;
fssystem::IBufferManager * const m_buffer_manager;
const fssystem::NcaCryptoConfiguration &m_nca_crypto_cfg;
bool m_is_prod;
bool m_is_enabled_program_verification;
private:
Result VerifyNcaHeaderSign2(fssystem::NcaReader *nca_reader, fs::IStorage *storage);
public:
explicit StorageOnNcaCreator(MemoryResource *mr, const fssystem::NcaCryptoConfiguration &cfg, bool prod, fssystem::IBufferManager *bm) : allocator(mr), buffer_manager(bm), nca_crypto_cfg(cfg), is_prod(prod), is_enabled_program_verification(true) {
explicit StorageOnNcaCreator(MemoryResource *mr, const fssystem::NcaCryptoConfiguration &cfg, bool prod, fssystem::IBufferManager *bm) : m_allocator(mr), m_buffer_manager(bm), m_nca_crypto_cfg(cfg), m_is_prod(prod), m_is_enabled_program_verification(true) {
/* ... */
}

View file

@ -22,17 +22,17 @@ namespace ams::fssrv {
class MemoryResourceFromExpHeap : public ams::MemoryResource {
private:
lmem::HeapHandle heap_handle;
lmem::HeapHandle m_heap_handle;
public:
constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : heap_handle(handle) { /* ... */ }
constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : m_heap_handle(handle) { /* ... */ }
protected:
virtual void *AllocateImpl(size_t size, size_t align) override {
return lmem::AllocateFromExpHeap(this->heap_handle, size, static_cast<s32>(align));
return lmem::AllocateFromExpHeap(m_heap_handle, size, static_cast<s32>(align));
}
virtual void DeallocateImpl(void *p, size_t size, size_t align) override {
AMS_UNUSED(size, align);
return lmem::FreeToExpHeap(this->heap_handle, p);
return lmem::FreeToExpHeap(m_heap_handle, p);
}
virtual bool IsEqualImpl(const MemoryResource &rhs) const override {
@ -43,24 +43,24 @@ namespace ams::fssrv {
class PeakCheckableMemoryResourceFromExpHeap : public ams::MemoryResource {
private:
lmem::HeapHandle heap_handle;
os::SdkMutex mutex;
size_t peak_free_size;
size_t current_free_size;
lmem::HeapHandle m_heap_handle;
os::SdkMutex m_mutex;
size_t m_peak_free_size;
size_t m_current_free_size;
public:
constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : heap_handle(nullptr), mutex(), peak_free_size(heap_size), current_free_size(heap_size) { /* ... */ }
constexpr explicit PeakCheckableMemoryResourceFromExpHeap(size_t heap_size) : m_heap_handle(nullptr), m_mutex(), m_peak_free_size(heap_size), m_current_free_size(heap_size) { /* ... */ }
void SetHeapHandle(lmem::HeapHandle handle) {
this->heap_handle = handle;
m_heap_handle = handle;
}
size_t GetPeakFreeSize() const { return this->peak_free_size; }
size_t GetCurrentFreeSize() const { return this->current_free_size; }
size_t GetPeakFreeSize() const { return m_peak_free_size; }
size_t GetCurrentFreeSize() const { return m_current_free_size; }
void ClearPeak() { this->peak_free_size = this->current_free_size; }
void ClearPeak() { m_peak_free_size = m_current_free_size; }
std::scoped_lock<os::SdkMutex> GetScopedLock() {
return std::scoped_lock(this->mutex);
return std::scoped_lock(m_mutex);
}
void OnAllocate(void *p, size_t size);

View file

@ -27,17 +27,17 @@ namespace ams::fssrv {
class MemoryResourceFromStandardAllocator : public ams::MemoryResource {
private:
mem::StandardAllocator *allocator;
os::SdkMutex mutex;
size_t peak_free_size;
size_t current_free_size;
size_t peak_allocated_size;
mem::StandardAllocator *m_allocator;
os::SdkMutex m_mutex;
size_t m_peak_free_size;
size_t m_current_free_size;
size_t m_peak_allocated_size;
public:
explicit MemoryResourceFromStandardAllocator(mem::StandardAllocator *allocator);
public:
size_t GetPeakFreeSize() const { return this->peak_free_size; }
size_t GetCurrentFreeSize() const { return this->current_free_size; }
size_t GetPeakAllocatedSize() const { return this->peak_allocated_size; }
size_t GetPeakFreeSize() const { return m_peak_free_size; }
size_t GetCurrentFreeSize() const { return m_current_free_size; }
size_t GetPeakAllocatedSize() const { return m_peak_allocated_size; }
void ClearPeak();
protected:

View file

@ -33,34 +33,34 @@ namespace ams::fssrv {
private:
using Buffer = std::unique_ptr<char[], fs::impl::Deleter>;
private:
Buffer buffer;
const char *path;
Result result;
Buffer m_buffer;
const char *m_path;
Result m_result;
private:
static Result Normalize(const char **out_path, Buffer *out_buf, const char *path, bool preserve_unc, bool preserve_tail_sep, bool has_mount_name);
public:
/* TODO: Remove non-option constructor. */
explicit PathNormalizer(const char *p) : buffer(), path(nullptr), result(ResultSuccess()) {
this->result = Normalize(std::addressof(this->path), std::addressof(this->buffer), p, false, false, false);
explicit PathNormalizer(const char *p) : m_buffer(), m_path(nullptr), m_result(ResultSuccess()) {
m_result = Normalize(std::addressof(m_path), std::addressof(m_buffer), p, false, false, false);
}
PathNormalizer(const char *p, u32 option) : buffer(), path(nullptr), result(ResultSuccess()) {
PathNormalizer(const char *p, u32 option) : m_buffer(), m_path(nullptr), m_result(ResultSuccess()) {
if ((option & Option_AcceptEmpty) && p[0] == '\x00') {
this->path = path;
m_path = p;
} else {
const bool preserve_unc = (option & Option_PreserveUnc);
const bool preserve_tail_sep = (option & Option_PreserveTailSeparator);
const bool has_mount_name = (option & Option_HasMountName);
this->result = Normalize(std::addressof(this->path), std::addressof(this->buffer), p, preserve_unc, preserve_tail_sep, has_mount_name);
m_result = Normalize(std::addressof(m_path), std::addressof(m_buffer), p, preserve_unc, preserve_tail_sep, has_mount_name);
}
}
Result GetResult() const {
return this->result;
return m_result;
}
const char *GetPath() const {
return this->path;
return m_path;
}
};

View file

@ -40,9 +40,9 @@ namespace ams::fssrv::impl {
class FileInterfaceAdapter {
NON_COPYABLE(FileInterfaceAdapter);
private:
ams::sf::SharedPointer<FileSystemInterfaceAdapter> parent_filesystem;
std::unique_ptr<fs::fsa::IFile> base_file;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
ams::sf::SharedPointer<FileSystemInterfaceAdapter> m_parent_filesystem;
std::unique_ptr<fs::fsa::IFile> m_base_file;
util::unique_lock<fssystem::SemaphoreAdapter> m_open_count_semaphore;
public:
FileInterfaceAdapter(std::unique_ptr<fs::fsa::IFile> &&file, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema);
~FileInterfaceAdapter();
@ -63,9 +63,9 @@ namespace ams::fssrv::impl {
class DirectoryInterfaceAdapter {
NON_COPYABLE(DirectoryInterfaceAdapter);
private:
ams::sf::SharedPointer<FileSystemInterfaceAdapter> parent_filesystem;
std::unique_ptr<fs::fsa::IDirectory> base_dir;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
ams::sf::SharedPointer<FileSystemInterfaceAdapter> m_parent_filesystem;
std::unique_ptr<fs::fsa::IDirectory> m_base_dir;
util::unique_lock<fssystem::SemaphoreAdapter> m_open_count_semaphore;
public:
DirectoryInterfaceAdapter(std::unique_ptr<fs::fsa::IDirectory> &&dir, FileSystemInterfaceAdapter *parent, util::unique_lock<fssystem::SemaphoreAdapter> &&sema);
~DirectoryInterfaceAdapter();
@ -79,11 +79,11 @@ namespace ams::fssrv::impl {
class FileSystemInterfaceAdapter : public ams::sf::ISharedObject {
NON_COPYABLE(FileSystemInterfaceAdapter);
private:
std::shared_ptr<fs::fsa::IFileSystem> base_fs;
util::unique_lock<fssystem::SemaphoreAdapter> mount_count_semaphore;
os::ReaderWriterLock invalidation_lock;
bool open_count_limited;
bool deep_retry_enabled = false;
std::shared_ptr<fs::fsa::IFileSystem> m_base_fs;
util::unique_lock<fssystem::SemaphoreAdapter> m_mount_count_semaphore;
os::ReaderWriterLock m_invalidation_lock;
bool m_open_count_limited;
bool m_deep_retry_enabled = false;
public:
FileSystemInterfaceAdapter(std::shared_ptr<fs::fsa::IFileSystem> &&fs, bool open_limited);
/* TODO: Other constructors. */

View file

@ -31,11 +31,11 @@ namespace ams::fssrv::impl {
NON_COPYABLE(StorageInterfaceAdapter);
private:
/* TODO: Nintendo uses fssystem::AsynchronousAccessStorage here. */
std::shared_ptr<fs::IStorage> base_storage;
util::unique_lock<fssystem::SemaphoreAdapter> open_count_semaphore;
os::ReaderWriterLock invalidation_lock;
std::shared_ptr<fs::IStorage> m_base_storage;
util::unique_lock<fssystem::SemaphoreAdapter> m_open_count_semaphore;
os::ReaderWriterLock m_invalidation_lock;
/* TODO: DataStorageContext. */
bool deep_retry_enabled = false;
bool m_deep_retry_enabled = false;
public:
StorageInterfaceAdapter(fs::IStorage *storage);
StorageInterfaceAdapter(std::unique_ptr<fs::IStorage> storage);

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

View file

@ -25,29 +25,29 @@ namespace ams::gpio::driver {
NON_MOVEABLE(Pad);
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::Pad, ::ams::ddsf::IDevice);
private:
int pad_number;
bool is_interrupt_enabled;
int m_pad_number;
bool m_is_interrupt_enabled;
public:
explicit Pad(int pad) : IDevice(true), pad_number(pad), is_interrupt_enabled(false) { /* ... */ }
explicit Pad(int pad) : IDevice(true), m_pad_number(pad), m_is_interrupt_enabled(false) { /* ... */ }
Pad() : Pad(0) { /* ... */ }
virtual ~Pad() { /* ... */ }
int GetPadNumber() const {
return this->pad_number;
return m_pad_number;
}
void SetPadNumber(int p) {
this->pad_number = p;
m_pad_number = p;
}
bool IsInterruptEnabled() const {
return this->is_interrupt_enabled;
return m_is_interrupt_enabled;
}
void SetInterruptEnabled(bool en) {
this->is_interrupt_enabled = en;
m_is_interrupt_enabled = en;
}
bool IsInterruptRequiredForDriver() const {

View file

@ -23,26 +23,26 @@ namespace ams::gpio::driver::impl {
NON_COPYABLE(EventHolder);
NON_MOVEABLE(EventHolder);
private:
os::SystemEventType *event;
os::SystemEventType *m_event;
public:
constexpr EventHolder() : event(nullptr) { /* ... */ }
constexpr EventHolder() : m_event(nullptr) { /* ... */ }
void AttachEvent(os::SystemEventType *event) {
this->event = event;
m_event = event;
}
os::SystemEventType *DetachEvent() {
auto ev = this->event;
this->event = nullptr;
auto ev = m_event;
m_event = nullptr;
return ev;
}
os::SystemEventType *GetSystemEvent() {
return this->event;
return m_event;
}
bool IsBound() const {
return this->event != nullptr;
return m_event != nullptr;
}
};

View file

@ -33,18 +33,18 @@ namespace ams::gpio::driver::impl {
NON_MOVEABLE(PadSessionImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::impl::PadSessionImpl, ::ams::ddsf::ISession);
private:
EventHolder event_holder;
EventHolder m_event_holder;
private:
Result UpdateDriverInterruptEnabled();
public:
PadSessionImpl() : event_holder() { /* ... */ }
PadSessionImpl() : m_event_holder() { /* ... */ }
~PadSessionImpl() {
this->Close();
}
bool IsInterruptBound() const {
return this->event_holder.IsBound();
return m_event_holder.IsBound();
}
Result Open(Pad *pad, ddsf::AccessMode access_mode);

View file

@ -25,25 +25,25 @@ namespace ams::i2c::driver {
NON_MOVEABLE(I2cDeviceProperty);
AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::I2cDeviceProperty, ::ams::ddsf::IDevice);
private:
u16 address;
AddressingMode addressing_mode;
util::IntrusiveListNode device_property_list_node;
u16 m_address;
AddressingMode m_addressing_mode;
util::IntrusiveListNode m_device_property_list_node;
public:
using DevicePropertyListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::device_property_list_node>;
using DevicePropertyListTraits = util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::m_device_property_list_node>;
using DevicePropertyList = typename DevicePropertyListTraits::ListType;
friend class util::IntrusiveList<I2cDeviceProperty, util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::device_property_list_node>>;
friend class util::IntrusiveList<I2cDeviceProperty, util::IntrusiveListMemberTraitsDeferredAssert<&I2cDeviceProperty::m_device_property_list_node>>;
public:
I2cDeviceProperty() : IDevice(false), address(0), addressing_mode(AddressingMode_SevenBit), device_property_list_node() { /* ... */ }
I2cDeviceProperty(u16 addr, AddressingMode m) : IDevice(false), address(addr), addressing_mode(m), device_property_list_node() { /* ... */ }
I2cDeviceProperty() : IDevice(false), m_address(0), m_addressing_mode(AddressingMode_SevenBit), m_device_property_list_node() { /* ... */ }
I2cDeviceProperty(u16 addr, AddressingMode m) : IDevice(false), m_address(addr), m_addressing_mode(m), m_device_property_list_node() { /* ... */ }
virtual ~I2cDeviceProperty() { /* ... */ }
u16 GetAddress() const {
return this->address;
return m_address;
}
AddressingMode GetAddressingMode() const {
return this->addressing_mode;
return m_addressing_mode;
}
};

View file

@ -36,8 +36,8 @@ namespace ams::i2c::driver::impl {
Receive = 1,
};
private:
TimeSpan retry_interval;
int max_retry_count;
TimeSpan m_retry_interval;
int m_max_retry_count;
private:
Result SendHandler(const u8 **cur_cmd, u8 **cur_dst);
Result ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst);
@ -45,7 +45,7 @@ namespace ams::i2c::driver::impl {
Result ExecuteTransactionWithRetry(void *dst, Command command, const void *src, size_t size, TransactionOption option);
public:
I2cSessionImpl(int mr, TimeSpan rt) : retry_interval(rt), max_retry_count(mr) { /* ... */ }
I2cSessionImpl(int mr, TimeSpan rt) : m_retry_interval(rt), m_max_retry_count(mr) { /* ... */ }
~I2cSessionImpl() {
this->Close();

View file

@ -28,20 +28,20 @@ namespace ams::i2c {
NON_COPYABLE(CommandListFormatter);
NON_MOVEABLE(CommandListFormatter);
private:
size_t current_index;
size_t command_list_length;
void *command_list;
size_t m_current_index;
size_t m_command_list_length;
void *m_command_list;
private:
Result IsEnqueueAble(size_t sz) const;
public:
CommandListFormatter(void *p, size_t sz) : current_index(0), command_list_length(sz), command_list(p) {
AMS_ABORT_UNLESS(this->command_list_length <= CommandListLengthMax);
CommandListFormatter(void *p, size_t sz) : m_current_index(0), m_command_list_length(sz), m_command_list(p) {
AMS_ABORT_UNLESS(m_command_list_length <= CommandListLengthMax);
}
~CommandListFormatter() { this->command_list = nullptr; }
~CommandListFormatter() { m_command_list = nullptr; }
size_t GetCurrentLength() const { return this->current_index; }
const void *GetListHead() const { return this->command_list; }
size_t GetCurrentLength() const { return m_current_index; }
const void *GetListHead() const { return m_command_list; }
Result EnqueueReceiveCommand(i2c::TransactionOption option, size_t size);
Result EnqueueSendCommand(i2c::TransactionOption option, const void *src, size_t size);

View file

@ -21,10 +21,10 @@ namespace ams::kvdb {
/* Functionality for parsing/generating a key value archive. */
class ArchiveReader {
private:
AutoBuffer &buffer;
size_t offset;
AutoBuffer &m_buffer;
size_t m_offset;
public:
ArchiveReader(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ }
ArchiveReader(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ }
private:
Result Peek(void *dst, size_t size);
Result Read(void *dst, size_t size);
@ -36,10 +36,10 @@ namespace ams::kvdb {
class ArchiveWriter {
private:
AutoBuffer &buffer;
size_t offset;
AutoBuffer &m_buffer;
size_t m_offset;
public:
ArchiveWriter(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ }
ArchiveWriter(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ }
private:
Result Write(const void *src, size_t size);
public:
@ -49,14 +49,14 @@ namespace ams::kvdb {
class ArchiveSizeHelper {
private:
size_t size;
size_t m_size;
public:
ArchiveSizeHelper();
void AddEntry(size_t key_size, size_t value_size);
size_t GetSize() const {
return this->size;
return m_size;
}
};

View file

@ -21,20 +21,20 @@ namespace ams::kvdb {
class AutoBuffer {
NON_COPYABLE(AutoBuffer);
private:
u8 *buffer;
size_t size;
u8 *m_buffer;
size_t m_size;
public:
AutoBuffer() : buffer(nullptr), size(0) { /* ... */ }
AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ }
~AutoBuffer() {
this->Reset();
}
AutoBuffer(AutoBuffer &&rhs) {
this->buffer = rhs.buffer;
this->size = rhs.size;
rhs.buffer = nullptr;
rhs.size = 0;
m_buffer = rhs.m_buffer;
m_size = rhs.m_size;
rhs.m_buffer = nullptr;
rhs.m_size = 0;
}
AutoBuffer &operator=(AutoBuffer &&rhs) {
@ -43,35 +43,35 @@ namespace ams::kvdb {
}
void Swap(AutoBuffer &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);
}
void Reset() {
if (this->buffer != nullptr) {
delete[] this->buffer;
this->buffer = nullptr;
this->size = 0;
if (m_buffer != nullptr) {
delete[] m_buffer;
m_buffer = nullptr;
m_size = 0;
}
}
u8 *Get() const {
return this->buffer;
return m_buffer;
}
size_t GetSize() const {
return this->size;
return m_size;
}
Result Initialize(size_t size) {
/* Check that we're not already initialized. */
AMS_ABORT_UNLESS(this->buffer == nullptr);
AMS_ABORT_UNLESS(m_buffer == nullptr);
/* Allocate a buffer. */
this->buffer = new (std::nothrow) u8[size];
R_UNLESS(this->buffer != nullptr, kvdb::ResultAllocationFailed());
m_buffer = new (std::nothrow) u8[size];
R_UNLESS(m_buffer != nullptr, kvdb::ResultAllocationFailed());
this->size = size;
m_size = size;
return ResultSuccess();
}
@ -80,7 +80,7 @@ namespace ams::kvdb {
R_TRY(this->Initialize(size));
/* Copy the input data in. */
std::memcpy(this->buffer, buf, size);
std::memcpy(m_buffer, buf, size);
return ResultSuccess();
}

View file

@ -23,7 +23,7 @@ namespace ams::kvdb {
class BoundedString {
static_assert(N > 0, "BoundedString requires non-zero backing buffer!");
private:
char buffer[N];
char m_buffer[N];
private:
/* Utility. */
static inline void CheckLength(size_t len) {
@ -32,7 +32,7 @@ namespace ams::kvdb {
public:
/* Constructors. */
constexpr BoundedString() {
buffer[0] = 0;
m_buffer[0] = 0;
}
explicit constexpr BoundedString(const char *s) {
@ -49,8 +49,8 @@ namespace ams::kvdb {
std::va_list args;
va_start(args, format);
CheckLength(util::VSNPrintf(string.buffer, N, format, args));
string.buffer[N - 1] = 0;
CheckLength(util::VSNPrintf(string.m_buffer, N, format, args));
string.m_buffer[N - 1] = 0;
va_end(args);
return string;
@ -58,30 +58,30 @@ namespace ams::kvdb {
/* Getters. */
size_t GetLength() const {
return util::Strnlen(this->buffer, N);
return util::Strnlen(m_buffer, N);
}
const char *Get() const {
return this->buffer;
return m_buffer;
}
operator const char *() const {
return this->buffer;
return m_buffer;
}
/* Setters. */
void Set(const char *s) {
/* Ensure string can fit in our buffer. */
CheckLength(util::Strnlen(s, N));
std::strncpy(this->buffer, s, N);
this->buffer[N - 1] = 0;
std::strncpy(m_buffer, s, N);
m_buffer[N - 1] = 0;
}
void SetFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) {
/* Format into the buffer, abort if too large. */
std::va_list args;
va_start(args, format);
CheckLength(util::VSNPrintf(this->buffer, N, format, args));
CheckLength(util::VSNPrintf(m_buffer, N, format, args));
va_end(args);
}
@ -89,21 +89,21 @@ namespace ams::kvdb {
void Append(const char *s) {
const size_t length = GetLength();
CheckLength(length + util::Strnlen(s, N));
std::strncat(this->buffer, s, N - length - 1);
std::strncat(m_buffer, s, N - length - 1);
}
void Append(char c) {
const size_t length = GetLength();
CheckLength(length + 1);
this->buffer[length] = c;
this->buffer[length + 1] = 0;
m_buffer[length] = c;
m_buffer[length + 1] = 0;
}
void AppendFormat(const char *format, ...) __attribute__((format (printf, 2, 3))) {
const size_t length = GetLength();
std::va_list args;
va_start(args, format);
CheckLength(util::VSNPrintf(this->buffer + length, N - length, format, args) + length);
CheckLength(util::VSNPrintf(m_buffer + length, N - length, format, args) + length);
va_end(args);
}
@ -113,19 +113,19 @@ namespace ams::kvdb {
AMS_ABORT_UNLESS(offset + length <= GetLength());
AMS_ABORT_UNLESS(dst_size > length);
/* Copy substring to dst. */
std::strncpy(dst, this->buffer + offset, length);
std::strncpy(dst, m_buffer + offset, length);
dst[length] = 0;
}
BoundedString<N> GetSubstring(size_t offset, size_t length) const {
BoundedString<N> string;
GetSubstring(string.buffer, N, offset, length);
GetSubstring(string.m_buffer, N, offset, length);
return string;
}
/* Comparison. */
constexpr bool operator==(const BoundedString<N> &rhs) const {
return std::strncmp(this->buffer, rhs.buffer, N) == 0;
return std::strncmp(m_buffer, rhs.m_buffer, N) == 0;
}
constexpr bool operator!=(const BoundedString<N> &rhs) const {
@ -133,7 +133,7 @@ namespace ams::kvdb {
}
bool EndsWith(const char *s, size_t offset) const {
return std::strncmp(this->buffer + offset, s, N - offset) == 0;
return std::strncmp(m_buffer + offset, s, N - offset) == 0;
}
bool EndsWith(const char *s) const {

View file

@ -34,9 +34,9 @@ namespace ams::kvdb {
static constexpr size_t FileSize = sizeof(LruHeader) + BufferSize;
using Path = FileKeyValueStore::Path;
private:
Path file_path;
Key *keys;
LruHeader header;
Path m_file_path;
Key *m_keys;
LruHeader m_header;
public:
static Result CreateNewList(const char *path) {
/* Create new lru_list.dat. */
@ -56,40 +56,40 @@ namespace ams::kvdb {
private:
void RemoveIndex(size_t i) {
AMS_ABORT_UNLESS(i < this->GetCount());
std::memmove(this->keys + i, this->keys + i + 1, sizeof(*this->keys) * (this->GetCount() - (i + 1)));
std::memmove(m_keys + i, m_keys + i + 1, sizeof(*m_keys) * (this->GetCount() - (i + 1)));
this->DecrementCount();
}
void IncrementCount() {
this->header.entry_count++;
m_header.entry_count++;
}
void DecrementCount() {
this->header.entry_count--;
m_header.entry_count--;
}
public:
LruList() : keys(nullptr), header({}) { /* ... */ }
LruList() : m_keys(nullptr), m_header() { /* ... */ }
Result Initialize(const char *path, void *buf, size_t size) {
/* Only initialize once, and ensure we have sufficient memory. */
AMS_ABORT_UNLESS(this->keys == nullptr);
AMS_ABORT_UNLESS(m_keys == nullptr);
AMS_ABORT_UNLESS(size >= BufferSize);
/* Setup member variables. */
this->keys = static_cast<Key *>(buf);
this->file_path.Set(path);
std::memset(this->keys, 0, BufferSize);
m_keys = static_cast<Key *>(buf);
m_file_path.Set(path);
std::memset(m_keys, 0, BufferSize);
/* Open file. */
fs::FileHandle file;
R_TRY(fs::OpenFile(std::addressof(file), this->file_path, fs::OpenMode_Read));
R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read));
ON_SCOPE_EXIT { fs::CloseFile(file); };
/* Read header. */
R_TRY(fs::ReadFile(file, 0, std::addressof(this->header), sizeof(this->header)));
R_TRY(fs::ReadFile(file, 0, std::addressof(m_header), sizeof(m_header)));
/* Read entries. */
R_TRY(fs::ReadFile(file, sizeof(this->header), this->keys, BufferSize));
R_TRY(fs::ReadFile(file, sizeof(m_header), m_keys, BufferSize));
return ResultSuccess();
}
@ -97,14 +97,14 @@ namespace ams::kvdb {
Result Save() {
/* Open file. */
fs::FileHandle file;
R_TRY(fs::OpenFile(std::addressof(file), this->file_path, fs::OpenMode_Read));
R_TRY(fs::OpenFile(std::addressof(file), m_file_path, fs::OpenMode_Read));
ON_SCOPE_EXIT { fs::CloseFile(file); };
/* Write header. */
R_TRY(fs::WriteFile(file, 0, std::addressof(this->header), sizeof(this->header), fs::WriteOption::None));
R_TRY(fs::WriteFile(file, 0, std::addressof(m_header), sizeof(m_header), fs::WriteOption::None));
/* Write entries. */
R_TRY(fs::WriteFile(file, sizeof(this->header), this->keys, BufferSize, fs::WriteOption::None));
R_TRY(fs::WriteFile(file, sizeof(m_header), m_keys, BufferSize, fs::WriteOption::None));
/* Flush. */
R_TRY(fs::FlushFile(file));
@ -113,7 +113,7 @@ namespace ams::kvdb {
}
size_t GetCount() const {
return this->header.entry_count;
return m_header.entry_count;
}
bool IsEmpty() const {
@ -126,7 +126,7 @@ namespace ams::kvdb {
Key Get(size_t i) const {
AMS_ABORT_UNLESS(i < this->GetCount());
return this->keys[i];
return m_keys[i];
}
Key Peek() const {
@ -136,7 +136,7 @@ namespace ams::kvdb {
void Push(const Key &key) {
AMS_ABORT_UNLESS(!this->IsFull());
this->keys[this->GetCount()] = key;
m_keys[this->GetCount()] = key;
this->IncrementCount();
}
@ -150,7 +150,7 @@ namespace ams::kvdb {
/* Iterate over the list, removing the last entry that matches the key. */
for (size_t i = 0; i < count; i++) {
if (this->keys[count - 1 - i] == key) {
if (m_keys[count - 1 - i] == key) {
this->RemoveIndex(count - 1 - i);
return true;
}
@ -164,7 +164,7 @@ namespace ams::kvdb {
/* Iterate over the list, checking to see if we have the key. */
for (size_t i = 0; i < count; i++) {
if (this->keys[count - 1 - i] == key) {
if (m_keys[count - 1 - i] == key) {
return true;
}
}
@ -196,8 +196,8 @@ namespace ams::kvdb {
/* as FileKeyValueStore paths are limited to 0x100 anyway. */
using Path = typename LeastRecentlyUsedList::Path;
private:
FileKeyValueStore kvs;
LeastRecentlyUsedList lru_list;
FileKeyValueStore m_kvs;
LeastRecentlyUsedList m_lru_list;
private:
static constexpr Path GetLeastRecentlyUsedListPath(const char *dir) {
return Path::MakeFormat("%s/%s", dir, "lru_list.dat");
@ -258,14 +258,14 @@ namespace ams::kvdb {
}
private:
void RemoveOldestKey() {
const Key &oldest_key = this->lru_list.Peek();
this->lru_list.Pop();
this->kvs.Remove(oldest_key);
const Key &oldest_key = m_lru_list.Peek();
m_lru_list.Pop();
m_kvs.Remove(oldest_key);
}
public:
Result Initialize(const char *dir, void *buf, size_t size) {
/* Initialize list. */
R_TRY(this->lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size));
R_TRY(m_lru_list.Initialize(GetLeastRecentlyUsedListPath(dir), buf, size));
/* Initialize kvs. */
/* NOTE: Despite creating the kvs folder and returning an error if it does not exist, */
@ -274,13 +274,13 @@ namespace ams::kvdb {
/* instead of in the same directory as a folder containing the store's .val files. */
/* This is probably a Nintendo bug, but because system saves contain data in the wrong */
/* layout it can't really be fixed without breaking existing devices... */
R_TRY(this->kvs.Initialize(dir));
R_TRY(m_kvs.Initialize(dir));
return ResultSuccess();
}
size_t GetCount() const {
return this->lru_list.GetCount();
return m_lru_list.GetCount();
}
size_t GetCapacity() const {
@ -288,53 +288,53 @@ namespace ams::kvdb {
}
Key GetKey(size_t i) const {
return this->lru_list.Get(i);
return m_lru_list.Get(i);
}
bool Contains(const Key &key) const {
return this->lru_list.Contains(key);
return m_lru_list.Contains(key);
}
Result Get(size_t *out_size, void *out_value, size_t max_out_size, const Key &key) {
/* Note that we accessed the key. */
this->lru_list.Update(key);
return this->kvs.Get(out_size, out_value, max_out_size, key);
m_lru_list.Update(key);
return m_kvs.Get(out_size, out_value, max_out_size, key);
}
template<typename Value>
Result Get(Value *out_value, const Key &key) {
/* Note that we accessed the key. */
this->lru_list.Update(key);
return this->kvs.Get(out_value, key);
m_lru_list.Update(key);
return m_kvs.Get(out_value, key);
}
Result GetSize(size_t *out_size, const Key &key) {
return this->kvs.GetSize(out_size, key);
return m_kvs.GetSize(out_size, key);
}
Result Set(const Key &key, const void *value, size_t value_size) {
if (this->lru_list.Update(key)) {
if (m_lru_list.Update(key)) {
/* If an entry for the key exists, delete the existing value file. */
this->kvs.Remove(key);
m_kvs.Remove(key);
} else {
/* If the list is full, we need to remove the oldest key. */
if (this->lru_list.IsFull()) {
if (m_lru_list.IsFull()) {
this->RemoveOldestKey();
}
/* Add the key to the list. */
this->lru_list.Push(key);
m_lru_list.Push(key);
}
/* Loop, trying to save the new value to disk. */
while (true) {
/* Try to set the key. */
R_TRY_CATCH(this->kvs.Set(key, value, value_size)) {
R_TRY_CATCH(m_kvs.Set(key, value, value_size)) {
R_CATCH(fs::ResultNotEnoughFreeSpace) {
/* If our entry is the only thing in the Lru list, remove it. */
if (this->lru_list.GetCount() == 1) {
this->lru_list.Pop();
R_TRY(this->lru_list.Save());
if (m_lru_list.GetCount() == 1) {
m_lru_list.Pop();
R_TRY(m_lru_list.Save());
return fs::ResultNotEnoughFreeSpace();
}
@ -349,7 +349,7 @@ namespace ams::kvdb {
}
/* Save the list. */
R_TRY(this->lru_list.Save());
R_TRY(m_lru_list.Save());
return ResultSuccess();
}
@ -361,19 +361,19 @@ namespace ams::kvdb {
Result Remove(const Key &key) {
/* Remove the key. */
this->lru_list.Remove(key);
R_TRY(this->kvs.Remove(key));
R_TRY(this->lru_list.Save());
m_lru_list.Remove(key);
R_TRY(m_kvs.Remove(key));
R_TRY(m_lru_list.Save());
return ResultSuccess();
}
Result RemoveAll() {
/* TODO: Nintendo doesn't check errors here. Should we? */
while (!this->lru_list.IsEmpty()) {
while (!m_lru_list.IsEmpty()) {
this->RemoveOldestKey();
}
R_TRY(this->lru_list.Save());
R_TRY(m_lru_list.Save());
return ResultSuccess();
}

View file

@ -42,17 +42,17 @@ namespace ams::kvdb {
class Cache {
private:
u8 *backing_buffer = nullptr;
size_t backing_buffer_size = 0;
size_t backing_buffer_free_offset = 0;
Entry *entries = nullptr;
size_t count = 0;
size_t capacity = 0;
u8 *m_backing_buffer = nullptr;
size_t m_backing_buffer_size = 0;
size_t m_backing_buffer_free_offset = 0;
Entry *m_entries = nullptr;
size_t m_count = 0;
size_t m_capacity = 0;
private:
void *Allocate(size_t size);
bool HasEntries() const {
return this->entries != nullptr && this->capacity != 0;
return m_entries != nullptr && m_capacity != 0;
}
public:
Result Initialize(void *buffer, size_t buffer_size, size_t capacity);
@ -63,14 +63,14 @@ namespace ams::kvdb {
bool Contains(const void *key, size_t key_size);
};
private:
os::SdkMutex lock;
Path dir_path;
Cache cache;
os::SdkMutex m_lock;
Path m_dir_path;
Cache m_cache;
private:
Path GetPath(const void *key, size_t key_size);
Result GetKey(size_t *out_size, void *out_key, size_t max_out_size, const FileName &file_name);
public:
FileKeyValueStore() : lock() { /* ... */ }
FileKeyValueStore() : m_lock() { /* ... */ }
/* Basic accessors. */
Result Initialize(const char *dir);

View file

@ -33,36 +33,36 @@ namespace ams::kvdb {
/* Subtypes. */
class Entry {
private:
Key key;
void *value;
size_t value_size;
Key m_key;
void *m_value;
size_t m_value_size;
public:
constexpr Entry(const Key &k, void *v, size_t s) : key(k), value(v), value_size(s) { /* ... */ }
constexpr Entry(const Key &k, void *v, size_t s) : m_key(k), m_value(v), m_value_size(s) { /* ... */ }
const Key &GetKey() const {
return this->key;
return m_key;
}
template<typename Value = void>
Value *GetValuePointer() {
/* Size check. Note: Nintendo does not size check. */
if constexpr (!std::is_same<Value, void>::value) {
AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size);
AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size);
/* Ensure we only get pod. */
static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod");
}
return reinterpret_cast<Value *>(this->value);
return reinterpret_cast<Value *>(m_value);
}
template<typename Value = void>
const Value *GetValuePointer() const {
/* Size check. Note: Nintendo does not size check. */
if constexpr (!std::is_same<Value, void>::value) {
AMS_ABORT_UNLESS(sizeof(Value) <= this->value_size);
AMS_ABORT_UNLESS(sizeof(Value) <= m_value_size);
/* Ensure we only get pod. */
static_assert(util::is_pod<Value>::value, "KeyValueStore Values must be pod");
}
return reinterpret_cast<Value *>(this->value);
return reinterpret_cast<Value *>(m_value);
}
template<typename Value>
@ -76,55 +76,55 @@ namespace ams::kvdb {
}
size_t GetValueSize() const {
return this->value_size;
return m_value_size;
}
constexpr inline bool operator<(const Key &rhs) const {
return key < rhs;
return m_key < rhs;
}
constexpr inline bool operator==(const Key &rhs) const {
return key == rhs;
return m_key == rhs;
}
};
class Index {
private:
size_t count;
size_t capacity;
Entry *entries;
MemoryResource *memory_resource;
size_t m_count;
size_t m_capacity;
Entry *m_entries;
MemoryResource *m_memory_resource;
public:
Index() : count(0), capacity(0), entries(nullptr), memory_resource(nullptr) { /* ... */ }
Index() : m_count(0), m_capacity(0), m_entries(nullptr), m_memory_resource(nullptr) { /* ... */ }
~Index() {
if (this->entries != nullptr) {
if (m_entries != nullptr) {
this->ResetEntries();
this->memory_resource->Deallocate(this->entries, sizeof(Entry) * this->capacity);
this->entries = nullptr;
m_memory_resource->Deallocate(m_entries, sizeof(Entry) * m_capacity);
m_entries = nullptr;
}
}
size_t GetCount() const {
return this->count;
return m_count;
}
size_t GetCapacity() const {
return this->capacity;
return m_capacity;
}
void ResetEntries() {
for (size_t i = 0; i < this->count; i++) {
this->memory_resource->Deallocate(this->entries[i].GetValuePointer(), this->entries[i].GetValueSize());
for (size_t i = 0; i < m_count; i++) {
m_memory_resource->Deallocate(m_entries[i].GetValuePointer(), m_entries[i].GetValueSize());
}
this->count = 0;
m_count = 0;
}
Result Initialize(size_t capacity, MemoryResource *mr) {
this->entries = reinterpret_cast<Entry *>(mr->Allocate(sizeof(Entry) * capacity));
R_UNLESS(this->entries != nullptr, kvdb::ResultAllocationFailed());
this->capacity = capacity;
this->memory_resource = mr;
m_entries = reinterpret_cast<Entry *>(mr->Allocate(sizeof(Entry) * capacity));
R_UNLESS(m_entries != nullptr, kvdb::ResultAllocationFailed());
m_capacity = capacity;
m_memory_resource = mr;
return ResultSuccess();
}
@ -133,16 +133,16 @@ namespace ams::kvdb {
Entry *it = this->lower_bound(key);
if (it != this->end() && it->GetKey() == key) {
/* Entry already exists. Free old value. */
this->memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize());
m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize());
} else {
/* We need to add a new entry. Check we have room, move future keys forward. */
R_UNLESS(this->count < this->capacity, kvdb::ResultOutOfKeyResource());
R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource());
std::memmove(it + 1, it, sizeof(*it) * (this->end() - it));
this->count++;
m_count++;
}
/* Allocate new value. */
void *new_value = this->memory_resource->Allocate(value_size);
void *new_value = m_memory_resource->Allocate(value_size);
R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed());
std::memcpy(new_value, value, value_size);
@ -152,9 +152,9 @@ namespace ams::kvdb {
}
Result AddUnsafe(const Key &key, void *value, size_t value_size) {
R_UNLESS(this->count < this->capacity, kvdb::ResultOutOfKeyResource());
R_UNLESS(m_count < m_capacity, kvdb::ResultOutOfKeyResource());
this->entries[this->count++] = Entry(key, value, value_size);
m_entries[m_count++] = Entry(key, value, value_size);
return ResultSuccess();
}
@ -164,9 +164,9 @@ namespace ams::kvdb {
R_UNLESS(it != this->end(), kvdb::ResultKeyNotFound());
/* Free the value, move entries back. */
this->memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize());
m_memory_resource->Deallocate(it->GetValuePointer(), it->GetValueSize());
std::memmove(it, it + 1, sizeof(*it) * (this->end() - (it + 1)));
this->count--;
m_count--;
return ResultSuccess();
}
@ -211,19 +211,19 @@ namespace ams::kvdb {
}
private:
Entry *GetBegin() {
return this->entries;
return m_entries;
}
const Entry *GetBegin() const {
return this->entries;
return m_entries;
}
Entry *GetEnd() {
return this->GetBegin() + this->count;
return this->GetBegin() + m_count;
}
const Entry *GetEnd() const {
return this->GetBegin() + this->count;
return this->GetBegin() + m_count;
}
Entry *GetLowerBound(const Key &key) {
@ -255,10 +255,10 @@ namespace ams::kvdb {
private:
using Path = kvdb::BoundedString<fs::EntryNameLengthMax>;
private:
Index index;
Path path;
Path temp_path;
MemoryResource *memory_resource;
Index m_index;
Path m_path;
Path m_temp_path;
MemoryResource *m_memory_resource;
public:
MemoryKeyValueStore() { /* ... */ }
@ -269,12 +269,12 @@ namespace ams::kvdb {
R_UNLESS(entry_type == fs::DirectoryEntryType_Directory, fs::ResultPathNotFound());
/* Set paths. */
this->path.SetFormat("%s%s", dir, "/imkvdb.arc");
this->temp_path.SetFormat("%s%s", dir, "/imkvdb.tmp");
m_path.SetFormat("%s%s", dir, "/imkvdb.arc");
m_temp_path.SetFormat("%s%s", dir, "/imkvdb.tmp");
/* Initialize our index. */
R_TRY(this->index.Initialize(capacity, mr));
this->memory_resource = mr;
R_TRY(m_index.Initialize(capacity, mr));
m_memory_resource = mr;
return ResultSuccess();
}
@ -282,26 +282,26 @@ namespace ams::kvdb {
Result Initialize(size_t capacity, MemoryResource *mr) {
/* This initializes without an archive file. */
/* A store initialized this way cannot have its contents loaded from or flushed to disk. */
this->path.Set("");
this->temp_path.Set("");
m_path.Set("");
m_temp_path.Set("");
/* Initialize our index. */
R_TRY(this->index.Initialize(capacity, mr));
this->memory_resource = mr;
R_TRY(m_index.Initialize(capacity, mr));
m_memory_resource = mr;
return ResultSuccess();
}
size_t GetCount() const {
return this->index.GetCount();
return m_index.GetCount();
}
size_t GetCapacity() const {
return this->index.GetCapacity();
return m_index.GetCapacity();
}
Result Load() {
/* Reset any existing entries. */
this->index.ResetEntries();
m_index.ResetEntries();
/* Try to read the archive -- note, path not found is a success condition. */
/* This is because no archive file = no entries, so we're in the right state. */
@ -323,14 +323,14 @@ namespace ams::kvdb {
R_TRY(reader.GetEntrySize(std::addressof(key_size), std::addressof(value_size)));
/* Allocate memory for value. */
void *new_value = this->memory_resource->Allocate(value_size);
void *new_value = m_memory_resource->Allocate(value_size);
R_UNLESS(new_value != nullptr, kvdb::ResultAllocationFailed());
auto value_guard = SCOPE_GUARD { this->memory_resource->Deallocate(new_value, value_size); };
auto value_guard = SCOPE_GUARD { m_memory_resource->Deallocate(new_value, value_size); };
/* Read key and value. */
Key key;
R_TRY(reader.ReadEntry(std::addressof(key), sizeof(key), new_value, value_size));
R_TRY(this->index.AddUnsafe(key, new_value, value_size));
R_TRY(m_index.AddUnsafe(key, new_value, value_size));
/* We succeeded, so cancel the value guard to prevent deallocation. */
value_guard.Cancel();
@ -349,7 +349,7 @@ namespace ams::kvdb {
{
ArchiveWriter writer(buffer);
writer.WriteHeader(this->GetCount());
for (const auto &it : this->index) {
for (const auto &it : m_index) {
const auto &key = it.GetKey();
writer.WriteEntry(std::addressof(key), sizeof(Key), it.GetValuePointer(), it.GetValueSize());
}
@ -360,7 +360,7 @@ namespace ams::kvdb {
}
Result Set(const Key &key, const void *value, size_t value_size) {
return this->index.Set(key, value, value_size);
return m_index.Set(key, value, value_size);
}
template<typename Value>
@ -428,47 +428,47 @@ namespace ams::kvdb {
}
Result Remove(const Key &key) {
return this->index.Remove(key);
return m_index.Remove(key);
}
Entry *begin() {
return this->index.begin();
return m_index.begin();
}
const Entry *begin() const {
return this->index.begin();
return m_index.begin();
}
Entry *end() {
return this->index.end();
return m_index.end();
}
const Entry *end() const {
return this->index.end();
return m_index.end();
}
const Entry *cbegin() const {
return this->index.cbegin();
return m_index.cbegin();
}
const Entry *cend() const {
return this->index.cend();
return m_index.cend();
}
Entry *lower_bound(const Key &key) {
return this->index.lower_bound(key);
return m_index.lower_bound(key);
}
const Entry *lower_bound(const Key &key) const {
return this->index.lower_bound(key);
return m_index.lower_bound(key);
}
Entry *find(const Key &key) {
return this->index.find(key);
return m_index.find(key);
}
const Entry *find(const Key &key) const {
return this->index.find(key);
return m_index.find(key);
}
private:
Result SaveArchiveToFile(const char *path, const void *buf, size_t size) {
@ -492,16 +492,16 @@ namespace ams::kvdb {
Result Commit(const AutoBuffer &buffer, bool destructive) {
if (destructive) {
/* Delete and save to the real archive. */
R_TRY(SaveArchiveToFile(this->path.Get(), buffer.Get(), buffer.GetSize()));
R_TRY(SaveArchiveToFile(m_path.Get(), buffer.Get(), buffer.GetSize()));
} else {
/* Delete and save to a temporary archive. */
R_TRY(SaveArchiveToFile(this->temp_path.Get(), buffer.Get(), buffer.GetSize()));
R_TRY(SaveArchiveToFile(m_temp_path.Get(), buffer.Get(), buffer.GetSize()));
/* Try to delete the saved archive, but allow deletion failure. */
fs::DeleteFile(this->path.Get());
fs::DeleteFile(m_path.Get());
/* Rename the path. */
R_TRY(fs::RenameFile(this->temp_path.Get(), this->path.Get()));
R_TRY(fs::RenameFile(m_temp_path.Get(), m_path.Get()));
}
return ResultSuccess();
@ -510,7 +510,7 @@ namespace ams::kvdb {
size_t GetArchiveSize() const {
ArchiveSizeHelper size_helper;
for (const auto &it : this->index) {
for (const auto &it : m_index) {
size_helper.AddEntry(sizeof(Key), it.GetValueSize());
}
@ -520,7 +520,7 @@ namespace ams::kvdb {
Result ReadArchiveFile(AutoBuffer *dst) const {
/* Open the file. */
fs::FileHandle file;
R_TRY(fs::OpenFile(std::addressof(file), path, fs::OpenMode_Read));
R_TRY(fs::OpenFile(std::addressof(file), m_path, fs::OpenMode_Read));
ON_SCOPE_EXIT { fs::CloseFile(file); };
/* Get the archive file size. */

View file

@ -23,13 +23,13 @@ namespace ams::lr {
class AddOnContentLocationResolver {
NON_COPYABLE(AddOnContentLocationResolver);
private:
sf::SharedPointer<IAddOnContentLocationResolver> interface;
sf::SharedPointer<IAddOnContentLocationResolver> m_interface;
public:
AddOnContentLocationResolver() { /* ... */ }
explicit AddOnContentLocationResolver(sf::SharedPointer<IAddOnContentLocationResolver> intf) : interface(intf) { /* ... */ }
explicit AddOnContentLocationResolver(sf::SharedPointer<IAddOnContentLocationResolver> intf) : m_interface(intf) { /* ... */ }
AddOnContentLocationResolver(AddOnContentLocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
AddOnContentLocationResolver &operator=(AddOnContentLocationResolver &&rhs) {
@ -38,37 +38,37 @@ namespace ams::lr {
}
void Swap(AddOnContentLocationResolver &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
/* Actual commands. */
Result ResolveAddOnContentPath(Path *out, ncm::DataId id) {
AMS_ASSERT(this->interface);
return this->interface->ResolveAddOnContentPath(out, id);
AMS_ASSERT(m_interface);
return m_interface->ResolveAddOnContentPath(out, id);
}
Result RegisterAddOnContentStorage(ncm::DataId id, ncm::ApplicationId application_id, ncm::StorageId storage_id) {
AMS_ASSERT(this->interface);
AMS_ASSERT(m_interface);
if (hos::GetVersion() >= hos::Version_9_0_0) {
return this->interface->RegisterAddOnContentStorage(id, application_id, storage_id);
return m_interface->RegisterAddOnContentStorage(id, application_id, storage_id);
} else {
return this->interface->RegisterAddOnContentStorageDeprecated(id, storage_id);
return m_interface->RegisterAddOnContentStorageDeprecated(id, storage_id);
}
}
Result UnregisterAllAddOnContentPath() {
AMS_ASSERT(this->interface);
return this->interface->UnregisterAllAddOnContentPath();
AMS_ASSERT(m_interface);
return m_interface->UnregisterAllAddOnContentPath();
}
Result RefreshApplicationAddOnContent(const ncm::ApplicationId *ids, size_t num_ids) {
AMS_ASSERT(this->interface);
return this->interface->RefreshApplicationAddOnContent(sf::InArray<ncm::ApplicationId>(ids, num_ids));
AMS_ASSERT(m_interface);
return m_interface->RefreshApplicationAddOnContent(sf::InArray<ncm::ApplicationId>(ids, num_ids));
}
Result UnregisterApplicationAddOnContent(ncm::ApplicationId id) {
AMS_ASSERT(this->interface);
return this->interface->UnregisterApplicationAddOnContent(id);
AMS_ASSERT(m_interface);
return m_interface->UnregisterApplicationAddOnContent(id);
}
};

View file

@ -23,13 +23,13 @@ namespace ams::lr {
class LocationResolver {
NON_COPYABLE(LocationResolver);
private:
sf::SharedPointer<ILocationResolver> interface;
sf::SharedPointer<ILocationResolver> m_interface;
public:
LocationResolver() { /* ... */ }
explicit LocationResolver(sf::SharedPointer<ILocationResolver> intf) : interface(intf) { /* ... */ }
explicit LocationResolver(sf::SharedPointer<ILocationResolver> intf) : m_interface(intf) { /* ... */ }
LocationResolver(LocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
LocationResolver &operator=(LocationResolver &&rhs) {
@ -38,137 +38,137 @@ namespace ams::lr {
}
void swap(LocationResolver &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
Result ResolveProgramPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveProgramPath(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveProgramPath(out, id);
}
void RedirectProgramPath(const Path &path, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->RedirectProgramPath(path, id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->RedirectProgramPath(path, id));
}
Result ResolveApplicationControlPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveApplicationControlPath(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveApplicationControlPath(out, id);
}
Result ResolveApplicationHtmlDocumentPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveApplicationHtmlDocumentPath(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveApplicationHtmlDocumentPath(out, id);
}
Result ResolveDataPath(Path *out, ncm::DataId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveDataPath(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveDataPath(out, id);
}
void RedirectApplicationControlPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectApplicationControlPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectApplicationControlPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectApplicationControlPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectApplicationControlPathDeprecated(path, id));
}
}
void RedirectApplicationHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectApplicationHtmlDocumentPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectApplicationHtmlDocumentPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectApplicationHtmlDocumentPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectApplicationHtmlDocumentPathDeprecated(path, id));
}
}
Result ResolveApplicationLegalInformationPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveApplicationLegalInformationPath(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveApplicationLegalInformationPath(out, id);
}
void RedirectApplicationLegalInformationPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectApplicationLegalInformationPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectApplicationLegalInformationPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectApplicationLegalInformationPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectApplicationLegalInformationPathDeprecated(path, id));
}
}
Result Refresh() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Refresh();
AMS_ASSERT(m_interface != nullptr);
return m_interface->Refresh();
}
void RedirectApplicationProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathDeprecated(path, id));
}
}
Result ClearApplicationRedirection() {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
AMS_ASSERT(hos::GetVersion() < hos::Version_9_0_0);
return this->ClearApplicationRedirection(nullptr, 0);
}
Result ClearApplicationRedirection(const ncm::ProgramId *excluding_ids, size_t num_ids) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
return this->interface->ClearApplicationRedirection(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids));
return m_interface->ClearApplicationRedirection(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids));
} else {
return this->interface->ClearApplicationRedirectionDeprecated();
return m_interface->ClearApplicationRedirectionDeprecated();
}
}
Result EraseProgramRedirection(ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->EraseProgramRedirection(id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->EraseProgramRedirection(id);
}
Result EraseApplicationControlRedirection(ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->EraseApplicationControlRedirection(id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->EraseApplicationControlRedirection(id);
}
Result EraseApplicationHtmlDocumentRedirection(ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->EraseApplicationHtmlDocumentRedirection(id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->EraseApplicationHtmlDocumentRedirection(id);
}
Result EraseApplicationLegalInformationRedirection(ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->EraseApplicationLegalInformationRedirection(id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->EraseApplicationLegalInformationRedirection(id);
}
Result ResolveProgramPathForDebug(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ResolveProgramPathForDebug(out, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ResolveProgramPathForDebug(out, id);
}
void RedirectProgramPathForDebug(const Path &path, ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->RedirectProgramPathForDebug(path, id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->RedirectProgramPathForDebug(path, id));
}
void RedirectApplicationProgramPathForDebug(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathForDebug(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathForDebug(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectApplicationProgramPathForDebugDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectApplicationProgramPathForDebugDeprecated(path, id));
}
}
Result EraseProgramRedirectionForDebug(ncm::ProgramId id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->EraseProgramRedirectionForDebug(id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->EraseProgramRedirectionForDebug(id);
}
};

View file

@ -24,11 +24,11 @@ namespace ams::lr {
class LocationResolverManagerImpl {
private:
/* Resolver storage. */
ncm::BoundedMap<ncm::StorageId, sf::SharedPointer<ILocationResolver>, 5> location_resolvers;
sf::SharedPointer<IRegisteredLocationResolver> registered_location_resolver = nullptr;
sf::SharedPointer<IAddOnContentLocationResolver> add_on_content_location_resolver = nullptr;
ncm::BoundedMap<ncm::StorageId, sf::SharedPointer<ILocationResolver>, 5> m_location_resolvers{};
sf::SharedPointer<IRegisteredLocationResolver> m_registered_location_resolver = nullptr;
sf::SharedPointer<IAddOnContentLocationResolver> m_add_on_content_location_resolver = nullptr;
os::SdkMutex mutex{};
os::SdkMutex m_mutex{};
public:
/* Actual commands. */
Result OpenLocationResolver(sf::Out<sf::SharedPointer<ILocationResolver>> out, ncm::StorageId storage_id);

View file

@ -23,13 +23,13 @@ namespace ams::lr {
class RegisteredLocationResolver {
NON_COPYABLE(RegisteredLocationResolver);
private:
sf::SharedPointer<IRegisteredLocationResolver> interface;
sf::SharedPointer<IRegisteredLocationResolver> m_interface;
public:
RegisteredLocationResolver() { /* ... */ }
explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : interface(intf) { /* ... */ }
explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : m_interface(intf) { /* ... */ }
RegisteredLocationResolver(RegisteredLocationResolver &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
RegisteredLocationResolver &operator=(RegisteredLocationResolver &&rhs) {
@ -38,74 +38,74 @@ namespace ams::lr {
}
void Swap(RegisteredLocationResolver &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
/* Actual commands. */
Result ResolveProgramPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface);
return this->interface->ResolveProgramPath(out, id);
AMS_ASSERT(m_interface);
return m_interface->ResolveProgramPath(out, id);
}
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface);
AMS_ASSERT(m_interface);
if (hos::GetVersion() >= hos::Version_9_0_0) {
return this->interface->RegisterProgramPath(path, id, owner_id);
return m_interface->RegisterProgramPath(path, id, owner_id);
} else {
return this->interface->RegisterProgramPathDeprecated(path, id);
return m_interface->RegisterProgramPathDeprecated(path, id);
}
}
Result UnregisterProgramPath(ncm::ProgramId id) {
AMS_ASSERT(this->interface);
return this->interface->UnregisterProgramPath(id);
AMS_ASSERT(m_interface);
return m_interface->UnregisterProgramPath(id);
}
void RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface);
AMS_ASSERT(m_interface);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectProgramPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectProgramPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectProgramPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectProgramPathDeprecated(path, id));
}
}
Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface);
return this->interface->ResolveHtmlDocumentPath(out, id);
AMS_ASSERT(m_interface);
return m_interface->ResolveHtmlDocumentPath(out, id);
}
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface);
AMS_ASSERT(m_interface);
if (hos::GetVersion() >= hos::Version_9_0_0) {
return this->interface->RegisterHtmlDocumentPath(path, id, owner_id);
return m_interface->RegisterHtmlDocumentPath(path, id, owner_id);
} else {
return this->interface->RegisterHtmlDocumentPathDeprecated(path, id);
return m_interface->RegisterHtmlDocumentPathDeprecated(path, id);
}
}
Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
AMS_ASSERT(this->interface);
return this->interface->UnregisterHtmlDocumentPath(id);
AMS_ASSERT(m_interface);
return m_interface->UnregisterHtmlDocumentPath(id);
}
void RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_id) {
AMS_ASSERT(this->interface);
AMS_ASSERT(m_interface);
if (hos::GetVersion() >= hos::Version_9_0_0) {
R_ABORT_UNLESS(this->interface->RedirectHtmlDocumentPath(path, id, owner_id));
R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPath(path, id, owner_id));
} else {
R_ABORT_UNLESS(this->interface->RedirectHtmlDocumentPathDeprecated(path, id));
R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPathDeprecated(path, id));
}
}
Result Refresh() {
AMS_ASSERT(this->interface);
return this->interface->Refresh();
AMS_ASSERT(m_interface);
return m_interface->Refresh();
}
Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) {
AMS_ASSERT(this->interface);
return this->interface->RefreshExcluding(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids));
AMS_ASSERT(m_interface);
return m_interface->RefreshExcluding(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids));
}
};

View file

@ -24,18 +24,18 @@ namespace ams::mem::impl::heap {
class CachedHeap final {
NON_COPYABLE(CachedHeap);
private:
TlsHeapCache *tls_heap_cache;
TlsHeapCache *m_tls_heap_cache;
public:
constexpr CachedHeap() : tls_heap_cache() { /* ... */ }
constexpr CachedHeap() : m_tls_heap_cache() { /* ... */ }
~CachedHeap() { this->Finalize(); }
ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : tls_heap_cache(rhs.tls_heap_cache) {
rhs.tls_heap_cache = nullptr;
ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : m_tls_heap_cache(rhs.m_tls_heap_cache) {
rhs.m_tls_heap_cache = nullptr;
}
ALWAYS_INLINE CachedHeap &operator=(CachedHeap &&rhs) {
this->Reset();
this->tls_heap_cache = rhs.tls_heap_cache;
rhs.tls_heap_cache = nullptr;
m_tls_heap_cache = rhs.m_tls_heap_cache;
rhs.m_tls_heap_cache = nullptr;
return *this;
}
@ -57,7 +57,7 @@ namespace ams::mem::impl::heap {
void Reset(TlsHeapCache *thc);
TlsHeapCache *Release();
constexpr explicit ALWAYS_INLINE operator bool() const { return this->tls_heap_cache != nullptr; }
constexpr explicit ALWAYS_INLINE operator bool() const { return m_tls_heap_cache != nullptr; }
};
}

View file

@ -33,13 +33,13 @@ namespace ams::mem::impl::heap {
static constexpr size_t MinimumAlignment = alignof(u64);
using DestructorHandler = void (*)(void *start, void *end);
private:
TlsHeapCentral *tls_heap_central;
bool use_virtual_memory;
u32 option;
u8 *start;
u8 *end;
TlsHeapCentral *m_tls_heap_central;
bool m_use_virtual_memory;
u32 m_option;
u8 *m_start;
u8 *m_end;
public:
constexpr CentralHeap() : tls_heap_central(), use_virtual_memory(), option(), start(), end() { /* ... */ }
constexpr CentralHeap() : m_tls_heap_central(), m_use_virtual_memory(), m_option(), m_start(), m_end() { /* ... */ }
~CentralHeap() { this->Finalize(); }
errno_t Initialize(void *start, size_t size, u32 option);

View file

@ -31,18 +31,18 @@ namespace ams::mem {
size_t hash;
};
private:
bool initialized;
bool enable_thread_cache;
uintptr_t unused;
os::TlsSlot tls_slot;
impl::InternalCentralHeapStorage central_heap_storage;
bool m_initialized;
bool m_enable_thread_cache;
uintptr_t m_unused;
os::TlsSlot m_tls_slot;
impl::InternalCentralHeapStorage m_central_heap_storage;
public:
StandardAllocator();
StandardAllocator(void *mem, size_t size);
StandardAllocator(void *mem, size_t size, bool enable_cache);
~StandardAllocator() {
if (this->initialized) {
if (m_initialized) {
this->Finalize();
}
}

View file

@ -21,20 +21,20 @@ namespace ams::ncm {
class AutoBuffer {
NON_COPYABLE(AutoBuffer);
private:
u8 *buffer;
size_t size;
u8 *m_buffer;
size_t m_size;
public:
AutoBuffer() : buffer(nullptr), size(0) { /* ... */ }
AutoBuffer() : m_buffer(nullptr), m_size(0) { /* ... */ }
~AutoBuffer() {
this->Reset();
}
AutoBuffer(AutoBuffer &&rhs) {
this->buffer = rhs.buffer;
this->size = rhs.size;
rhs.buffer = nullptr;
rhs.size = 0;
m_buffer = rhs.m_buffer;
m_size = rhs.m_size;
rhs.m_buffer = nullptr;
rhs.m_size = 0;
}
AutoBuffer &operator=(AutoBuffer &&rhs) {
@ -43,35 +43,35 @@ namespace ams::ncm {
}
void Swap(AutoBuffer &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);
}
void Reset() {
if (this->buffer != nullptr) {
delete[] this->buffer;
this->buffer = nullptr;
this->size = 0;
if (m_buffer != nullptr) {
delete[] m_buffer;
m_buffer = nullptr;
m_size = 0;
}
}
u8 *Get() const {
return this->buffer;
return m_buffer;
}
size_t GetSize() const {
return this->size;
return m_size;
}
Result Initialize(size_t size) {
/* Check that we're not already initialized. */
AMS_ABORT_UNLESS(this->buffer == nullptr);
AMS_ABORT_UNLESS(m_buffer == nullptr);
/* Allocate a buffer. */
this->buffer = new (std::nothrow) u8[size];
R_UNLESS(this->buffer != nullptr, ncm::ResultAllocationFailed());
m_buffer = new (std::nothrow) u8[size];
R_UNLESS(m_buffer != nullptr, ncm::ResultAllocationFailed());
this->size = size;
m_size = size;
return ResultSuccess();
}
@ -80,7 +80,7 @@ namespace ams::ncm {
R_TRY(this->Initialize(size));
/* Copy the input data in. */
std::memcpy(this->buffer, buf, size);
std::memcpy(m_buffer, buf, size);
return ResultSuccess();
}

View file

@ -22,11 +22,11 @@ namespace ams::ncm {
class ContentMetaDatabaseBuilder {
private:
ContentMetaDatabase *db;
ContentMetaDatabase *m_db;
private:
Result BuildFromPackageContentMeta(void *buf, size_t size, const ContentInfo &meta_info);
public:
explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : db(d) { /* ... */ }
explicit ContentMetaDatabaseBuilder(ContentMetaDatabase *d) : m_db(d) { /* ... */ }
Result BuildFromStorage(ContentStorage *storage);
Result BuildFromPackage(const char *package_root_path);

View file

@ -33,26 +33,26 @@ namespace ams::ncm {
class ContentMetaMemoryResource : public MemoryResource {
private:
mem::StandardAllocator allocator;
size_t peak_total_alloc_size;
size_t peak_alloc_size;
mem::StandardAllocator m_allocator;
size_t m_peak_total_alloc_size;
size_t m_peak_alloc_size;
public:
explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : allocator(heap, heap_size) { /* ... */ }
explicit ContentMetaMemoryResource(void *heap, size_t heap_size) : m_allocator(heap, heap_size), m_peak_alloc_size(0), m_peak_total_alloc_size(0) { /* ... */ }
mem::StandardAllocator *GetAllocator() { return std::addressof(this->allocator); }
size_t GetPeakTotalAllocationSize() const { return this->peak_total_alloc_size; }
size_t GetPeakAllocationSize() const { return this->peak_alloc_size; }
mem::StandardAllocator *GetAllocator() { return std::addressof(m_allocator); }
size_t GetPeakTotalAllocationSize() const { return m_peak_total_alloc_size; }
size_t GetPeakAllocationSize() const { return m_peak_alloc_size; }
private:
virtual void *AllocateImpl(size_t size, size_t alignment) override {
void *mem = this->allocator.Allocate(size, alignment);
this->peak_total_alloc_size = std::max(this->allocator.Hash().allocated_size, this->peak_total_alloc_size);
this->peak_alloc_size = std::max(size, this->peak_alloc_size);
void *mem = m_allocator.Allocate(size, alignment);
m_peak_total_alloc_size = std::max(m_allocator.Hash().allocated_size, m_peak_total_alloc_size);
m_peak_alloc_size = std::max(size, m_peak_alloc_size);
return mem;
}
virtual void DeallocateImpl(void *buffer, size_t size, size_t alignment) override {
AMS_UNUSED(size, alignment);
return this->allocator.Free(buffer);
return m_allocator.Free(buffer);
}
virtual bool IsEqualImpl(const MemoryResource &resource) const override {
@ -103,16 +103,16 @@ namespace ams::ncm {
ContentMetaDatabaseRoot() { /* ... */ }
};
private:
os::SdkRecursiveMutex mutex;
bool initialized;
ContentStorageRoot content_storage_roots[MaxContentStorageRoots];
ContentMetaDatabaseRoot content_meta_database_roots[MaxContentMetaDatabaseRoots];
u32 num_content_storage_entries;
u32 num_content_meta_entries;
RightsIdCache rights_id_cache;
RegisteredHostContent registered_host_content;
os::SdkRecursiveMutex m_mutex;
bool m_initialized;
ContentStorageRoot m_content_storage_roots[MaxContentStorageRoots];
ContentMetaDatabaseRoot m_content_meta_database_roots[MaxContentMetaDatabaseRoots];
u32 m_num_content_storage_entries;
u32 m_num_content_meta_entries;
RightsIdCache m_rights_id_cache;
RegisteredHostContent m_registered_host_content;
public:
ContentManagerImpl() : mutex(), initialized(false), num_content_storage_entries(0), num_content_meta_entries(0), rights_id_cache(), registered_host_content() {
ContentManagerImpl() : m_mutex(), m_initialized(false), m_content_storage_roots(), m_content_meta_database_roots(), m_num_content_storage_entries(0), m_num_content_meta_entries(0), m_rights_id_cache(), m_registered_host_content() {
/* ... */
};
~ContentManagerImpl();

View file

@ -118,9 +118,9 @@ namespace ams::ncm {
using HeaderType = ContentMetaHeaderType;
using InfoType = ContentInfoType;
private:
void *data;
const size_t size;
bool is_header_valid;
void *m_data;
const size_t m_size;
bool m_is_header_valid;
private:
static size_t GetExtendedHeaderSize(ContentMetaType type) {
switch (type) {
@ -132,8 +132,8 @@ namespace ams::ncm {
}
}
protected:
constexpr ContentMetaAccessor(const void *d, size_t sz) : data(const_cast<void *>(d)), size(sz), is_header_valid(true) { /* ... */ }
constexpr ContentMetaAccessor(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ }
constexpr ContentMetaAccessor(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr ContentMetaAccessor(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
template<class NewHeaderType, class NewInfoType>
static constexpr size_t CalculateSizeImpl(size_t ext_header_size, size_t content_count, size_t content_meta_count, size_t extended_data_size, bool has_digest) {
@ -145,7 +145,7 @@ namespace ams::ncm {
}
uintptr_t GetExtendedHeaderAddress() const {
return reinterpret_cast<uintptr_t>(this->data) + sizeof(HeaderType);
return reinterpret_cast<uintptr_t>(m_data) + sizeof(HeaderType);
}
uintptr_t GetContentInfoStartAddress() const {
@ -214,21 +214,21 @@ namespace ams::ncm {
public:
const void *GetData() const {
return this->data;
return m_data;
}
size_t GetSize() const {
return this->size;
return m_size;
}
HeaderType *GetWritableHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
return reinterpret_cast<HeaderType *>(this->data);
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<HeaderType *>(m_data);
}
const HeaderType *GetHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
return static_cast<const HeaderType *>(this->data);
AMS_ABORT_UNLESS(m_is_header_valid);
return static_cast<const HeaderType *>(m_data);
}
ContentMetaKey GetKey() const {

View file

@ -26,13 +26,13 @@ namespace ams::ncm {
s32 total;
};
private:
sf::SharedPointer<IContentMetaDatabase> interface;
sf::SharedPointer<IContentMetaDatabase> m_interface;
public:
ContentMetaDatabase() { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : interface(intf) { /* ... */ }
explicit ContentMetaDatabase(sf::SharedPointer<IContentMetaDatabase> intf) : m_interface(intf) { /* ... */ }
ContentMetaDatabase(ContentMetaDatabase &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
ContentMetaDatabase &operator=(ContentMetaDatabase &&rhs) {
@ -41,18 +41,18 @@ namespace ams::ncm {
}
void swap(ContentMetaDatabase &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
Result Set(const ContentMetaKey &key, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Set(key, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->Set(key, sf::InBuffer(buf, size));
}
Result Get(size_t *out_size, void *dst, size_t dst_size, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(this->interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size)));
R_TRY(m_interface->Get(std::addressof(size), key, sf::OutBuffer(dst, dst_size)));
*out_size = size;
return ResultSuccess();
@ -60,13 +60,13 @@ namespace ams::ncm {
#define AMS_NCM_DEFINE_GETTERS(Kind, IdType) \
Result Get##Kind(ContentId *out, IdType##Id id, u32 version) { \
return this->interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \
return m_interface->GetContentIdByType(out, ContentMetaKey::MakeUnknownType(id.value, version), ContentType::Kind); \
} \
\
Result GetLatest##Kind(ContentId *out, IdType##Id id) { \
ContentMetaKey latest_key; \
R_TRY(this->interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
return this->interface->GetContentIdByType(out, latest_key, ContentType::Kind); \
R_TRY(m_interface->GetLatestContentMetaKey(std::addressof(latest_key), id.value)); \
return m_interface->GetContentIdByType(out, latest_key, ContentType::Kind); \
}
AMS_NCM_DEFINE_GETTERS(Program, Program)
@ -78,8 +78,8 @@ namespace ams::ncm {
#undef AMS_NCM_DEFINE_GETTERS
Result Remove(const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Remove(key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Remove(key);
}
Result Remove(SystemProgramId id, u32 version) {
@ -95,99 +95,99 @@ namespace ams::ncm {
}
Result GetContentIdByType(ContentId *out_content_id, const ContentMetaKey &key, ContentType type) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentIdByType(out_content_id, key, type);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentIdByType(out_content_id, key, type);
}
Result GetContentIdByTypeAndIdOffset(ContentId *out_content_id, const ContentMetaKey &key, ContentType type, u8 id_offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentIdByTypeAndIdOffset(out_content_id, key, type, id_offset);
}
ListCount ListApplication(ApplicationContentMetaKey *dst, size_t dst_size) {
ListCount lc = {};
R_ABORT_UNLESS(this->interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ApplicationContentMetaKey>(dst, dst_size), ContentMetaType::Unknown));
R_ABORT_UNLESS(m_interface->ListApplication(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ApplicationContentMetaKey>(dst, dst_size), ContentMetaType::Unknown));
return lc;
}
ListCount ListContentMeta(ContentMetaKey *dst, size_t dst_size, ContentMetaType type = ContentMetaType::Unknown, ApplicationId app_id = InvalidApplicationId, u64 min = std::numeric_limits<u64>::min(), u64 max = std::numeric_limits<u64>::max(), ContentInstallType install_type = ContentInstallType::Full) {
ListCount lc = {};
R_ABORT_UNLESS(this->interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ContentMetaKey>(dst, dst_size), type, app_id, min, max, install_type));
R_ABORT_UNLESS(m_interface->List(std::addressof(lc.total), std::addressof(lc.written), sf::OutArray<ContentMetaKey>(dst, dst_size), type, app_id, min, max, install_type));
return lc;
}
Result GetLatest(ContentMetaKey *out_key, u64 id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetLatestContentMetaKey(out_key, id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetLatestContentMetaKey(out_key, id);
}
Result ListContentInfo(s32 *out_count, ContentInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentInfo(out_count, sf::OutArray<ContentInfo>(dst, dst_size), key, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentInfo(out_count, sf::OutArray<ContentInfo>(dst, dst_size), key, offset);
}
Result ListContentMetaInfo(s32 *out_count, ContentMetaInfo *dst, size_t dst_size, const ContentMetaKey &key, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentMetaInfo(out_count, sf::OutArray<ContentMetaInfo>(dst, dst_size), key, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentMetaInfo(out_count, sf::OutArray<ContentMetaInfo>(dst, dst_size), key, offset);
}
Result Has(bool *out, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Has(out, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Has(out, key);
}
Result HasAll(bool *out, const ContentMetaKey *keys, size_t num_keys) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasAll(out, sf::InArray<ContentMetaKey>(keys, num_keys));
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasAll(out, sf::InArray<ContentMetaKey>(keys, num_keys));
}
Result HasContent(bool *out, const ContentMetaKey &key, const ContentId &content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasContent(out, key, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasContent(out, key, content_id);
}
Result GetSize(size_t *out_size, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
u64 size;
R_TRY(this->interface->GetSize(std::addressof(size), key));
R_TRY(m_interface->GetSize(std::addressof(size), key));
*out_size = size;
return ResultSuccess();
}
Result GetRequiredSystemVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRequiredSystemVersion(out_version, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRequiredSystemVersion(out_version, key);
}
Result GetPatchId(PatchId *out_patch_id, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetPatchId(out_patch_id, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetPatchId(out_patch_id, key);
}
Result DisableForcibly() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DisableForcibly();
AMS_ASSERT(m_interface != nullptr);
return m_interface->DisableForcibly();
}
Result LookupOrphanContent(bool *out_orphaned, ContentId *content_list, size_t count) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->LookupOrphanContent(sf::OutArray<bool>(out_orphaned, count), sf::InArray<ContentId>(content_list, count));
AMS_ASSERT(m_interface != nullptr);
return m_interface->LookupOrphanContent(sf::OutArray<bool>(out_orphaned, count), sf::InArray<ContentId>(content_list, count));
}
Result Commit() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Commit();
AMS_ASSERT(m_interface != nullptr);
return m_interface->Commit();
}
Result GetAttributes(u8 *out_attributes, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetAttributes(out_attributes, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetAttributes(out_attributes, key);
}
Result GetRequiredApplicationVersion(u32 *out_version, const ContentMetaKey &key) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRequiredApplicationVersion(out_version, key);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRequiredApplicationVersion(out_version, key);
}
};

View file

@ -112,10 +112,10 @@ namespace ams::ncm {
template<typename MemberTypePointer, typename DataTypePointer>
class PatchMetaExtendedDataReaderWriterBase {
private:
MemberTypePointer data;
const size_t size;
MemberTypePointer m_data;
const size_t m_size;
public:
PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : data(d), size(sz) { /* ... */ }
PatchMetaExtendedDataReaderWriterBase(MemberTypePointer d, size_t sz) : m_data(d), m_size(sz) { /* ... */ }
protected:
s32 CountFragmentSet(s32 delta_index) const {
auto delta_header = this->GetPatchDeltaHeader(0);
@ -154,7 +154,7 @@ namespace ams::ncm {
}
DataTypePointer GetHeaderAddress() const {
return reinterpret_cast<DataTypePointer>(this->data);
return reinterpret_cast<DataTypePointer>(m_data);
}
DataTypePointer GetPatchHistoryHeaderAddress(s32 index) const {
@ -307,15 +307,15 @@ namespace ams::ncm {
class SystemUpdateMetaExtendedDataReaderWriterBase {
private:
void *data;
const size_t size;
bool is_header_valid;
void *m_data;
const size_t m_size;
bool m_is_header_valid;
protected:
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : data(const_cast<void *>(d)), size(sz), is_header_valid(true) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : data(d), size(sz), is_header_valid(false) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(const void *d, size_t sz) : m_data(const_cast<void *>(d)), m_size(sz), m_is_header_valid(true) { /* ... */ }
constexpr SystemUpdateMetaExtendedDataReaderWriterBase(void *d, size_t sz) : m_data(d), m_size(sz), m_is_header_valid(false) { /* ... */ }
uintptr_t GetHeaderAddress() const {
return reinterpret_cast<uintptr_t>(this->data);
return reinterpret_cast<uintptr_t>(m_data);
}
uintptr_t GetFirmwareVariationIdStartAddress() const {
@ -343,7 +343,7 @@ namespace ams::ncm {
}
public:
const SystemUpdateMetaExtendedDataHeader *GetHeader() const {
AMS_ABORT_UNLESS(this->is_header_valid);
AMS_ABORT_UNLESS(m_is_header_valid);
return reinterpret_cast<const SystemUpdateMetaExtendedDataHeader *>(this->GetHeaderAddress());
}

View file

@ -21,13 +21,13 @@ namespace ams::ncm {
class ContentStorage {
NON_COPYABLE(ContentStorage);
private:
sf::SharedPointer<IContentStorage> interface;
sf::SharedPointer<IContentStorage> m_interface;
public:
ContentStorage() { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : interface(intf) { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : m_interface(intf) { /* ... */ }
ContentStorage(ContentStorage &&rhs) {
this->interface = std::move(rhs.interface);
m_interface = std::move(rhs.m_interface);
}
ContentStorage &operator=(ContentStorage &&rhs) {
@ -36,166 +36,166 @@ namespace ams::ncm {
}
void swap(ContentStorage &rhs) {
std::swap(this->interface, rhs.interface);
std::swap(m_interface, rhs.m_interface);
}
public:
PlaceHolderId GeneratePlaceHolderId() {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
PlaceHolderId id;
R_ABORT_UNLESS(this->interface->GeneratePlaceHolderId(std::addressof(id)));
R_ABORT_UNLESS(m_interface->GeneratePlaceHolderId(std::addressof(id)));
return id;
}
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->CreatePlaceHolder(placeholder_id, content_id, size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->CreatePlaceHolder(placeholder_id, content_id, size);
}
Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DeletePlaceHolder(placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->DeletePlaceHolder(placeholder_id);
}
Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->HasPlaceHolder(out, placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->HasPlaceHolder(out, placeholder_id);
}
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size));
}
Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Register(placeholder_id, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Register(placeholder_id, content_id);
}
Result Delete(ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Delete(content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Delete(content_id);
}
Result Has(bool *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->Has(out, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->Has(out, content_id);
}
void GetPath(Path *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPath(out, content_id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPath(out, content_id));
}
void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPlaceHolderPath(out, placeholder_id));
AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(m_interface->GetPlaceHolderPath(out, placeholder_id));
}
Result CleanupAllPlaceHolder() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->CleanupAllPlaceHolder();
AMS_ASSERT(m_interface != nullptr);
return m_interface->CleanupAllPlaceHolder();
}
Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size));
}
Result GetContentCount(s32 *out_count) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetContentCount(out_count);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetContentCount(out_count);
}
Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset);
}
Result GetSize(s64 *out_size, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetSizeFromContentId(out_size, content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetSizeFromContentId(out_size, content_id);
}
Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetSizeFromPlaceHolderId(out_size, placeholder_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id);
}
Result DisableForcibly() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->DisableForcibly();
AMS_ASSERT(m_interface != nullptr);
return m_interface->DisableForcibly();
}
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id);
}
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->SetPlaceHolderSize(placeholder_id, size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->SetPlaceHolderSize(placeholder_id, size);
}
Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset);
AMS_ASSERT(m_interface != nullptr);
return m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset);
}
Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) {
return this->interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id);
return m_interface->GetRightsIdFromPlaceHolderId(out_rights_id, placeholder_id);
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
return this->interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id);
return m_interface->GetRightsIdFromPlaceHolderIdDeprecated(std::addressof(out_rights_id->id), placeholder_id);
}
}
Result GetRightsId(ncm::RightsId *out_rights_id, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr);
AMS_ASSERT(m_interface != nullptr);
const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) {
return this->interface->GetRightsIdFromContentId(out_rights_id, content_id);
return m_interface->GetRightsIdFromContentId(out_rights_id, content_id);
} else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {};
return this->interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id);
return m_interface->GetRightsIdFromContentIdDeprecated(std::addressof(out_rights_id->id), content_id);
}
}
Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size));
AMS_ASSERT(m_interface != nullptr);
return m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size));
}
Result GetFreeSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetFreeSpaceSize(out_size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetFreeSpaceSize(out_size);
}
Result GetTotalSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetTotalSpaceSize(out_size);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetTotalSpaceSize(out_size);
}
Result FlushPlaceHolder() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->FlushPlaceHolder();
AMS_ASSERT(m_interface != nullptr);
return m_interface->FlushPlaceHolder();
}
Result RepairInvalidFileAttribute() {
AMS_ASSERT(this->interface != nullptr);
return this->interface->RepairInvalidFileAttribute();
AMS_ASSERT(m_interface != nullptr);
return m_interface->RepairInvalidFileAttribute();
}
Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
AMS_ASSERT(this->interface != nullptr);
return this->interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id);
AMS_ASSERT(m_interface != nullptr);
return m_interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id);
}
};

View file

@ -82,18 +82,18 @@ namespace ams::ncm {
NON_COPYABLE(InstallTaskBase);
NON_MOVEABLE(InstallTaskBase);
private:
crypto::Sha256Generator sha256_generator;
StorageId install_storage;
InstallTaskDataBase *data;
InstallProgress progress;
os::SdkMutex progress_mutex;
u32 config;
os::SdkMutex cancel_mutex;
bool cancel_requested;
InstallThroughput throughput;
TimeSpan throughput_start_time;
os::SdkMutex throughput_mutex;
FirmwareVariationId firmware_variation_id;
crypto::Sha256Generator m_sha256_generator;
StorageId m_install_storage;
InstallTaskDataBase *m_data;
InstallProgress m_progress;
os::SdkMutex m_progress_mutex;
u32 m_config;
os::SdkMutex m_cancel_mutex;
bool m_cancel_requested;
InstallThroughput m_throughput;
TimeSpan m_throughput_start_time;
os::SdkMutex m_throughput_mutex;
FirmwareVariationId m_firmware_variation_id;
private:
ALWAYS_INLINE Result SetLastResultOnFailure(Result result) {
if (R_FAILED(result)) {
@ -102,7 +102,7 @@ namespace ams::ncm {
return result;
}
public:
InstallTaskBase() : data(), progress(), progress_mutex(), cancel_mutex(), cancel_requested(), throughput_mutex() { /* ... */ }
InstallTaskBase() : m_data(), m_progress(), m_progress_mutex(), m_cancel_mutex(), m_cancel_requested(), m_throughput_mutex() { /* ... */ }
virtual ~InstallTaskBase() { /* ... */ };
public:
virtual void Cancel();
@ -144,10 +144,10 @@ namespace ams::ncm {
virtual Result PrepareDependency();
Result PrepareSystemUpdateDependency();
virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */
u32 GetConfig() const { return this->config; }
u32 GetConfig() const { return m_config; }
Result WriteContentMetaToPlaceHolder(InstallContentInfo *out_install_content_info, ContentStorage *storage, const InstallContentMetaInfo &meta_info, util::optional<bool> is_temporary);
StorageId GetInstallStorage() const { return this->install_storage; }
StorageId GetInstallStorage() const { return m_install_storage; }
virtual Result OnPrepareComplete() { return ResultSuccess(); }
@ -196,7 +196,7 @@ namespace ams::ncm {
public:
virtual Result CheckInstallable() { return ResultSuccess(); }
void SetFirmwareVariationId(FirmwareVariationId id) { this->firmware_variation_id = id; }
void SetFirmwareVariationId(FirmwareVariationId id) { m_firmware_variation_id = id; }
Result ListRightsIds(s32 *out_count, Span<RightsId> out_span, const ContentMetaKey &key, s32 offset);
};

View file

@ -59,12 +59,12 @@ namespace ams::ncm {
struct DataHolder : public InstallContentMeta, public util::IntrusiveListBaseNode<DataHolder>{};
using DataList = util::IntrusiveListBaseTraits<DataHolder>::ListType;
private:
DataList data_list;
InstallProgressState state;
Result last_result;
SystemUpdateTaskApplyInfo system_update_task_apply_info;
DataList m_data_list;
InstallProgressState m_state;
Result m_last_result;
SystemUpdateTaskApplyInfo m_system_update_task_apply_info;
public:
MemoryInstallTaskData() : state(InstallProgressState::NotPrepared), last_result(ResultSuccess()) { /* ... */ };
MemoryInstallTaskData() : m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()) { /* ... */ };
~MemoryInstallTaskData() {
this->Cleanup();
}
@ -104,8 +104,8 @@ namespace ams::ncm {
static_assert(sizeof(EntryInfo) == 0x10);
private:
Header header;
char path[64];
Header m_header;
char m_path[64];
private:
static constexpr Header MakeInitialHeader(s32 max_entries) {
return {

View file

@ -40,13 +40,13 @@ namespace ams::ncm {
class HeapState {
private:
os::SdkMutex mutex;
lmem::HeapHandle heap_handle;
size_t total_alloc_size;
size_t peak_total_alloc_size;
size_t peak_alloc_size;
os::SdkMutex m_mutex;
lmem::HeapHandle m_heap_handle;
size_t m_total_alloc_size;
size_t m_peak_total_alloc_size;
size_t m_peak_alloc_size;
public:
constexpr HeapState() : mutex(), heap_handle(nullptr), total_alloc_size(0), peak_total_alloc_size(0), peak_alloc_size(0) { /* ... */ }
constexpr HeapState() : m_mutex(), m_heap_handle(nullptr), m_total_alloc_size(0), m_peak_total_alloc_size(0), m_peak_alloc_size(0) { /* ... */ }
void Initialize(lmem::HeapHandle heap_handle);
void Allocate(size_t size);

View file

@ -20,7 +20,7 @@ namespace ams::ncm {
class PackageInstallTask : public PackageInstallTaskBase {
private:
MemoryInstallTaskData data;
MemoryInstallTaskData m_data;
public:
Result Initialize(const char *package_root, StorageId storage_id, void *buffer, size_t buffer_size, bool ignore_ticket);
protected:

View file

@ -23,16 +23,16 @@ namespace ams::ncm {
private:
using PackagePath = kvdb::BoundedString<256>;
private:
PackagePath package_root;
void *buffer;
size_t buffer_size;
PackagePath m_package_root;
void *m_buffer;
size_t m_buffer_size;
public:
PackageInstallTaskBase() : package_root() { /* ... */ }
PackageInstallTaskBase() : m_package_root() { /* ... */ }
Result Initialize(const char *package_root_path, void *buffer, size_t buffer_size, StorageId storage_id, InstallTaskDataBase *data, u32 config);
protected:
const char *GetPackageRootPath() {
return this->package_root.Get();
return m_package_root.Get();
}
private:
virtual Result OnWritePlaceHolder(const ContentMetaKey &key, InstallContentInfo *content_info) override;

View file

@ -22,10 +22,10 @@ namespace ams::ncm {
private:
using PackagePath = kvdb::BoundedString<0x100>;
private:
PackagePath context_path;
FileInstallTaskData data;
ContentMetaDatabase package_db;
bool gamecard_content_meta_database_active;
PackagePath m_context_path;
FileInstallTaskData m_data;
ContentMetaDatabase m_package_db;
bool m_gamecard_content_meta_database_active;
public:
~PackageSystemUpdateTask();
@ -35,7 +35,7 @@ namespace ams::ncm {
protected:
virtual Result PrepareInstallContentMetaData() override;
virtual Result GetInstallContentMetaInfo(InstallContentMetaInfo *out, const ContentMetaKey &key) override;
InstallTaskDataBase &GetInstallData() { return this->data; } /* Atmosphere extension. */
InstallTaskDataBase &GetInstallData() { return m_data; } /* Atmosphere extension. */
private:
virtual Result PrepareDependency() override;

View file

@ -28,10 +28,10 @@ namespace ams::ncm {
private:
using RegisteredPathList = ams::util::IntrusiveListBaseTraits<RegisteredPath>::ListType;
private:
os::SdkMutex mutex;
RegisteredPathList path_list;
os::SdkMutex m_mutex;
RegisteredPathList m_path_list;
public:
RegisteredHostContent() : mutex(), path_list() { /* ... */ }
RegisteredHostContent() : m_mutex(), m_path_list() { /* ... */ }
~RegisteredHostContent();
Result RegisterPath(const ncm::ContentId &content_id, const ncm::Path &path);

View file

@ -33,28 +33,28 @@ namespace ams::ncm {
u64 last_accessed;
};
private:
Entry entries[MaxEntries];
u64 counter;
os::SdkMutex mutex;
Entry m_entries[MaxEntries];
u64 m_counter;
os::SdkMutex m_mutex;
public:
RightsIdCache() : mutex() {
RightsIdCache() : m_mutex() {
this->Invalidate();
}
void Invalidate() {
this->counter = 2;
m_counter = 2;
for (size_t i = 0; i < MaxEntries; i++) {
this->entries[i].last_accessed = 1;
m_entries[i].last_accessed = 1;
}
}
void Store(ContentId content_id, ncm::RightsId rights_id) {
std::scoped_lock lk(this->mutex);
Entry *eviction_candidate = std::addressof(this->entries[0]);
std::scoped_lock lk(m_mutex);
Entry *eviction_candidate = std::addressof(m_entries[0]);
/* Find a suitable existing entry to store our new one at. */
for (size_t i = 1; i < MaxEntries; i++) {
Entry *entry = std::addressof(this->entries[i]);
Entry *entry = std::addressof(m_entries[i]);
/* Change eviction candidates if the uuid already matches ours, or if the uuid doesn't already match and the last_accessed count is lower */
if (content_id == entry->uuid || (content_id != eviction_candidate->uuid && entry->last_accessed < eviction_candidate->last_accessed)) {
@ -65,19 +65,19 @@ namespace ams::ncm {
/* Update the cache. */
eviction_candidate->uuid = content_id.uuid;
eviction_candidate->rights_id = rights_id;
eviction_candidate->last_accessed = this->counter++;
eviction_candidate->last_accessed = m_counter++;
}
bool Find(ncm::RightsId *out_rights_id, ContentId content_id) {
std::scoped_lock lk(this->mutex);
std::scoped_lock lk(m_mutex);
/* Attempt to locate the content id in the cache. */
for (size_t i = 0; i < MaxEntries; i++) {
Entry *entry = std::addressof(this->entries[i]);
Entry *entry = std::addressof(m_entries[i]);
if (entry->last_accessed != 1 && content_id == entry->uuid) {
entry->last_accessed = this->counter;
this->counter++;
entry->last_accessed = m_counter;
m_counter++;
*out_rights_id = entry->rights_id;
return true;
}

View file

@ -23,30 +23,30 @@ namespace ams::ncm {
public:
static constexpr s32 MaxCount = 10;
private:
StorageId ids[MaxCount];
s32 count;
StorageId m_ids[MaxCount];
s32 m_count;
public:
constexpr StorageList() : ids(), count() { /* ... */ }
constexpr StorageList() : m_ids(), m_count() { /* ... */ }
void Push(StorageId storage_id) {
AMS_ABORT_UNLESS(this->count < MaxCount);
AMS_ABORT_UNLESS(m_count < MaxCount);
for (s32 i = 0; i < MaxCount; i++) {
if (this->ids[i] == storage_id) {
if (m_ids[i] == storage_id) {
return;
}
}
this->ids[this->count++] = storage_id;
m_ids[m_count++] = storage_id;
}
s32 Count() const {
return this->count;
return m_count;
}
StorageId operator[](s32 i) const {
AMS_ABORT_UNLESS(i < this->count);
return this->ids[i];
AMS_ABORT_UNLESS(i < m_count);
return m_ids[i];
}
};

View file

@ -23,7 +23,7 @@ namespace ams::ncm {
private:
class Impl;
private:
std::unique_ptr<Impl> impl;
std::unique_ptr<Impl> m_impl;
public:
SubmissionPackageInstallTask();
virtual ~SubmissionPackageInstallTask() override;

View file

@ -28,28 +28,28 @@ namespace ams::os::impl {
class InternalConditionVariable {
private:
InternalConditionVariableImpl impl;
InternalConditionVariableImpl m_impl;
public:
constexpr InternalConditionVariable() : impl() { /* ... */ }
constexpr InternalConditionVariable() : m_impl() { /* ... */ }
constexpr void Initialize() {
this->impl.Initialize();
m_impl.Initialize();
}
void Signal() {
this->impl.Signal();
m_impl.Signal();
}
void Broadcast() {
this->impl.Broadcast();
m_impl.Broadcast();
}
void Wait(InternalCriticalSection *cs) {
this->impl.Wait(cs);
m_impl.Wait(cs);
}
ConditionVariableStatus TimedWait(InternalCriticalSection *cs, const TimeoutHelper &timeout_helper) {
return this->impl.TimedWait(cs, timeout_helper);
return m_impl.TimedWait(cs, timeout_helper);
}
};

View file

@ -25,12 +25,12 @@ namespace ams::os::impl {
class InternalConditionVariableImpl {
private:
u32 value;
u32 m_value;
public:
constexpr InternalConditionVariableImpl() : value(0) { /* ... */ }
constexpr InternalConditionVariableImpl() : m_value(0) { /* ... */ }
constexpr void Initialize() {
this->value = 0;
m_value = 0;
}
void Signal();

View file

@ -27,18 +27,18 @@ namespace ams::os::impl {
class InternalCriticalSection {
private:
InternalCriticalSectionImpl impl;
InternalCriticalSectionImpl m_impl;
public:
constexpr InternalCriticalSection() : impl() { /* ... */ }
constexpr InternalCriticalSection() : m_impl() { /* ... */ }
constexpr void Initialize() { this->impl.Initialize(); }
constexpr void Finalize() { this->impl.Finalize(); }
constexpr void Initialize() { m_impl.Initialize(); }
constexpr void Finalize() { m_impl.Finalize(); }
void Enter() { return this->impl.Enter(); }
bool TryEnter() { return this->impl.TryEnter(); }
void Leave() { return this->impl.Leave(); }
void Enter() { return m_impl.Enter(); }
bool TryEnter() { return m_impl.TryEnter(); }
void Leave() { return m_impl.Leave(); }
bool IsLockedByCurrentThread() const { return this->impl.IsLockedByCurrentThread(); }
bool IsLockedByCurrentThread() const { return m_impl.IsLockedByCurrentThread(); }
ALWAYS_INLINE void Lock() { return this->Enter(); }
ALWAYS_INLINE bool TryLock() { return this->TryEnter(); }
@ -49,11 +49,11 @@ namespace ams::os::impl {
ALWAYS_INLINE void unlock() { return this->Unlock(); }
InternalCriticalSectionImpl *Get() {
return std::addressof(this->impl);
return std::addressof(m_impl);
}
const InternalCriticalSectionImpl *Get() const {
return std::addressof(this->impl);
return std::addressof(m_impl);
}
};

View file

@ -33,11 +33,11 @@ namespace ams::os::impl {
friend class InternalConditionVariableImpl;
private:
u32 thread_handle;
u32 m_thread_handle;
public:
constexpr InternalCriticalSectionImpl() : thread_handle(svc::InvalidHandle) { /* ... */ }
constexpr InternalCriticalSectionImpl() : m_thread_handle(svc::InvalidHandle) { /* ... */ }
constexpr void Initialize() { this->thread_handle = svc::InvalidHandle; }
constexpr void Initialize() { m_thread_handle = svc::InvalidHandle; }
constexpr void Finalize() { /* ... */ }
void Enter();

Some files were not shown because too many files have changed in this diff Show more