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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -135,8 +135,8 @@ namespace ams::fs {
using DirectoryEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomDirectoryEntry>; using DirectoryEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomDirectoryEntry>;
using FileEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomFileEntry>; using FileEntryMapTable = EntryMapTable<RomEntryKey, EntryKey, RomFileEntry>;
private: private:
DirectoryEntryMapTable dir_table; DirectoryEntryMapTable m_dir_table;
FileEntryMapTable file_table; FileEntryMapTable m_file_table;
public: public:
static s64 QueryDirectoryEntryBucketStorageSize(s64 count); static s64 QueryDirectoryEntryBucketStorageSize(s64 count);
static size_t QueryDirectoryEntrySize(size_t aux_size); static size_t QueryDirectoryEntrySize(size_t aux_size);
@ -148,11 +148,11 @@ namespace ams::fs {
HierarchicalRomFileTable(); HierarchicalRomFileTable();
constexpr u32 GetDirectoryEntryCount() const { constexpr u32 GetDirectoryEntryCount() const {
return this->dir_table.GetEntryCount(); return m_dir_table.GetEntryCount();
} }
constexpr u32 GetFileEntryCount() const { 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); 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); static_assert(util::is_pod<Element>::value);
private: private:
s64 bucket_count; s64 m_bucket_count;
SubStorage bucket_storage; SubStorage m_bucket_storage;
SubStorage kv_storage; SubStorage m_kv_storage;
s64 total_entry_size; s64 m_total_entry_size;
u32 entry_count; u32 m_entry_count;
public: public:
static constexpr s64 QueryBucketStorageSize(s64 num) { static constexpr s64 QueryBucketStorageSize(s64 num) {
return num * sizeof(Position); return num * sizeof(Position);
@ -69,42 +69,42 @@ namespace ams::fs {
return ResultSuccess(); return ResultSuccess();
} }
public: 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) { Result Initialize(const SubStorage &bucket, s64 count, const SubStorage &kv) {
AMS_ASSERT(count > 0); AMS_ASSERT(count > 0);
this->bucket_storage = bucket; m_bucket_storage = bucket;
this->bucket_count = count; m_bucket_count = count;
this->kv_storage = kv; m_kv_storage = kv;
return ResultSuccess(); return ResultSuccess();
} }
void Finalize() { void Finalize() {
this->bucket_storage = SubStorage(); m_bucket_storage = SubStorage();
this->kv_storage = SubStorage(); m_kv_storage = SubStorage();
this->bucket_count = 0; m_bucket_count = 0;
} }
s64 GetTotalEntrySize() const { s64 GetTotalEntrySize() const {
return this->total_entry_size; return m_total_entry_size;
} }
Result GetFreeSize(s64 *out) { Result GetFreeSize(s64 *out) {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
s64 kv_size = 0; s64 kv_size = 0;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
*out = kv_size - this->total_entry_size; *out = kv_size - m_total_entry_size;
return ResultSuccess(); return ResultSuccess();
} }
constexpr u32 GetEntryCount() const { constexpr u32 GetEntryCount() const {
return this->entry_count; return m_entry_count;
} }
protected: protected:
Result AddInternal(Position *out, const Key &key, u32 hash_key, const void *aux, size_t aux_size, const Value &value) { 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(out != nullptr);
AMS_ASSERT(aux != nullptr || aux_size == 0); AMS_ASSERT(aux != nullptr || aux_size == 0);
AMS_ASSERT(this->bucket_count > 0); AMS_ASSERT(m_bucket_count > 0);
{ {
Position pos, prev_pos; Position pos, prev_pos;
@ -125,7 +125,7 @@ namespace ams::fs {
R_TRY(this->WriteKeyValue(std::addressof(elem), pos, aux, aux_size)); R_TRY(this->WriteKeyValue(std::addressof(elem), pos, aux, aux_size));
*out = pos; *out = pos;
this->entry_count++; m_entry_count++;
return ResultSuccess(); return ResultSuccess();
} }
@ -178,7 +178,7 @@ namespace ams::fs {
} }
private: private:
BucketIndex HashToBucket(u32 hash_key) const { 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) { 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_prev != nullptr);
AMS_ASSERT(out_elem != nullptr); AMS_ASSERT(out_elem != nullptr);
AMS_ASSERT(aux != nullptr || aux_size == 0); AMS_ASSERT(aux != nullptr || aux_size == 0);
AMS_ASSERT(this->bucket_count > 0); AMS_ASSERT(m_bucket_count > 0);
*out_pos = 0; *out_pos = 0;
*out_prev = 0; *out_prev = 0;
@ -197,7 +197,7 @@ namespace ams::fs {
R_TRY(this->ReadBucket(std::addressof(cur), ind)); R_TRY(this->ReadBucket(std::addressof(cur), ind));
s64 kv_size; 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); AMS_ASSERT(cur == InvalidPosition || cur < kv_size);
R_UNLESS(cur != InvalidPosition, fs::ResultDbmKeyNotFound()); R_UNLESS(cur != InvalidPosition, fs::ResultDbmKeyNotFound());
@ -225,13 +225,13 @@ namespace ams::fs {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
s64 kv_size; s64 kv_size;
R_TRY(this->kv_storage.GetSize(std::addressof(kv_size))); R_TRY(m_kv_storage.GetSize(std::addressof(kv_size)));
const size_t end_pos = this->total_entry_size + sizeof(Element) + aux_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()); 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(); return ResultSuccess();
} }
@ -244,7 +244,7 @@ namespace ams::fs {
R_TRY(this->ReadBucket(std::addressof(next), ind)); R_TRY(this->ReadBucket(std::addressof(next), ind));
s64 kv_size; 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); AMS_ASSERT(next == InvalidPosition || next < kv_size);
R_TRY(this->WriteBucket(pos, ind)); R_TRY(this->WriteBucket(pos, ind));
@ -255,27 +255,27 @@ namespace ams::fs {
Result ReadBucket(Position *out, BucketIndex ind) { Result ReadBucket(Position *out, BucketIndex ind) {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
AMS_ASSERT(ind < this->bucket_count); AMS_ASSERT(ind < m_bucket_count);
const s64 offset = ind * sizeof(Position); 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) { Result WriteBucket(Position pos, BucketIndex ind) {
AMS_ASSERT(ind < this->bucket_count); AMS_ASSERT(ind < m_bucket_count);
const s64 offset = ind * sizeof(Position); 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) { Result ReadKeyValue(Element *out, Position pos) {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
s64 kv_size; 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); 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) { 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; *out_aux_size = out->size;
if (out->size > 0) { 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(); return ResultSuccess();
@ -298,13 +298,13 @@ namespace ams::fs {
AMS_ASSERT(aux != nullptr); AMS_ASSERT(aux != nullptr);
s64 kv_size; 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); 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) { 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(); return ResultSuccess();

View file

@ -81,12 +81,12 @@ namespace ams::fs::RomPathTool {
class PathParser { class PathParser {
private: private:
const RomPathChar *prev_path_start; const RomPathChar *m_prev_path_start;
const RomPathChar *prev_path_end; const RomPathChar *m_prev_path_end;
const RomPathChar *next_path; const RomPathChar *m_next_path;
bool finished; bool m_finished;
public: 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); Result Initialize(const RomPathChar *path);
void Finalize(); void Finalize();

View file

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

View file

@ -28,13 +28,13 @@ namespace ams::fs {
class FsContext { class FsContext {
private: private:
ResultHandler handler; ResultHandler m_handler;
public: 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); void SetDefaultFsContextResultHandler(const ResultHandler handler);
@ -44,24 +44,24 @@ namespace ams::fs {
class ScopedFsContext { class ScopedFsContext {
private: private:
const FsContext * const prev_context; const FsContext * const m_prev_context;
public: public:
ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : prev_context(GetCurrentThreadFsContext()) { ALWAYS_INLINE ScopedFsContext(const FsContext &ctx) : m_prev_context(GetCurrentThreadFsContext()) {
SetCurrentThreadFsContext(std::addressof(ctx)); SetCurrentThreadFsContext(std::addressof(ctx));
} }
ALWAYS_INLINE ~ScopedFsContext() { ALWAYS_INLINE ~ScopedFsContext() {
SetCurrentThreadFsContext(this->prev_context); SetCurrentThreadFsContext(m_prev_context);
} }
}; };
class ScopedAutoAbortDisabler { class ScopedAutoAbortDisabler {
private: private:
const FsContext * const prev_context; const FsContext * const m_prev_context;
public: public:
ScopedAutoAbortDisabler(); ScopedAutoAbortDisabler();
ALWAYS_INLINE ~ScopedAutoAbortDisabler() { ALWAYS_INLINE ~ScopedAutoAbortDisabler() {
SetCurrentThreadFsContext(this->prev_context); SetCurrentThreadFsContext(m_prev_context);
} }
}; };

View file

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

View file

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

View file

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

View file

@ -28,17 +28,17 @@ namespace ams::fs {
NON_COPYABLE(ReadOnlyFile); NON_COPYABLE(ReadOnlyFile);
NON_MOVEABLE(ReadOnlyFile); NON_MOVEABLE(ReadOnlyFile);
private: private:
std::unique_ptr<fsa::IFile> base_file; std::unique_ptr<fsa::IFile> m_base_file;
public: 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() { /* ... */ } virtual ~ReadOnlyFile() { /* ... */ }
private: private:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { 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 { virtual Result DoGetSize(s64 *out) override final {
return this->base_file->GetSize(out); return m_base_file->GetSize(out);
} }
virtual Result DoFlush() override final { virtual Result DoFlush() override final {
@ -59,14 +59,14 @@ namespace ams::fs {
switch (op_id) { switch (op_id) {
case OperationId::Invalidate: case OperationId::Invalidate:
case OperationId::QueryRange: 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: default:
return fs::ResultUnsupportedOperationInReadOnlyFileB(); return fs::ResultUnsupportedOperationInReadOnlyFileB();
} }
} }
public: public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { 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_COPYABLE(ReadOnlyFileSystemTemplate);
NON_MOVEABLE(ReadOnlyFileSystemTemplate); NON_MOVEABLE(ReadOnlyFileSystemTemplate);
private: private:
T base_fs; T m_base_fs;
public: public:
explicit ReadOnlyFileSystemTemplate(T &&fs) : base_fs(std::move(fs)) { /* ... */ } explicit ReadOnlyFileSystemTemplate(T &&fs) : m_base_fs(std::move(fs)) { /* ... */ }
virtual ~ReadOnlyFileSystemTemplate() { /* ... */ } virtual ~ReadOnlyFileSystemTemplate() { /* ... */ }
private: private:
virtual Result DoOpenFile(std::unique_ptr<fsa::IFile> *out_file, const char *path, OpenMode mode) override final { 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()); R_UNLESS((mode & fs::OpenMode_All) == fs::OpenMode_Read, fs::ResultInvalidOpenMode());
std::unique_ptr<fsa::IFile> base_file; 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)); auto read_only_file = std::make_unique<ReadOnlyFile>(std::move(base_file));
R_UNLESS(read_only_file != nullptr, fs::ResultAllocationFailureInReadOnlyFileSystemA()); 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 { 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 { 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 { virtual Result DoCommit() override final {

View file

@ -26,30 +26,30 @@ namespace ams::fs {
class RemoteFile : public fsa::IFile, public impl::Newable { class RemoteFile : public fsa::IFile, public impl::Newable {
private: private:
::FsFile base_file; ::FsFile m_base_file;
public: 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: public:
virtual Result DoRead(size_t *out, s64 offset, void *buffer, size_t size, const fs::ReadOption &option) override final { 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 { 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 { 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 { 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 { 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 { 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(op_id == OperationId::QueryRange, fs::ResultUnsupportedOperationInFileServiceObjectAdapterA());
R_UNLESS(dst_size == sizeof(FileQueryRangeInfo), fs::ResultInvalidSize()); 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: public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { 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 { class RemoteDirectory : public fsa::IDirectory, public impl::Newable {
private: private:
::FsDir base_dir; ::FsDir m_base_dir;
public: 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: public:
virtual Result DoRead(s64 *out_count, DirectoryEntry *out_entries, s64 max_entries) override final { 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 { virtual Result DoGetEntryCount(s64 *out) override final {
return fsDirGetEntryCount(std::addressof(this->base_dir), out); return fsDirGetEntryCount(std::addressof(m_base_dir), out);
} }
public: public:
virtual sf::cmif::DomainObjectId GetDomainObjectId() const override { 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 { class RemoteFileSystem : public fsa::IFileSystem, public impl::Newable {
private: private:
::FsFileSystem base_fs; ::FsFileSystem m_base_fs;
public: 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: private:
Result GetPathForServiceObject(fssrv::sf::Path *out_path, const char *path) { Result GetPathForServiceObject(fssrv::sf::Path *out_path, const char *path) {
/* Copy and null terminate. */ /* Copy and null terminate. */
@ -113,31 +113,31 @@ namespace ams::fs {
virtual Result DoCreateFile(const char *path, s64 size, int flags) override final { virtual Result DoCreateFile(const char *path, s64 size, int flags) override final {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { virtual Result DoDeleteFile(const char *path) override final {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { virtual Result DoCreateDirectory(const char *path) override final {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { virtual Result DoDeleteDirectory(const char *path) override final {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { virtual Result DoDeleteDirectoryRecursively(const char *path) override final {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { 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; fssrv::sf::Path new_sf_path;
R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path));
R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_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 { 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; fssrv::sf::Path new_sf_path;
R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path)); R_TRY(GetPathForServiceObject(std::addressof(old_sf_path), old_path));
R_TRY(GetPathForServiceObject(std::addressof(new_sf_path), new_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 { 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)); R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
static_assert(sizeof(::FsDirEntryType) == sizeof(DirectoryEntryType)); 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 { 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)); R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
FsFile f; 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); auto file = std::make_unique<RemoteFile>(f);
R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew()); R_UNLESS(file != nullptr, fs::ResultAllocationFailureInNew());
@ -183,7 +183,7 @@ namespace ams::fs {
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
FsDir d; 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); auto dir = std::make_unique<RemoteDirectory>(d);
R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew()); R_UNLESS(dir != nullptr, fs::ResultAllocationFailureInNew());
@ -193,39 +193,39 @@ namespace ams::fs {
} }
virtual Result DoCommit() override final { 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) { virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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) { virtual Result DoGetTotalSpaceSize(s64 *out, const char *path) {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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) { virtual Result DoCleanDirectoryRecursively(const char *path) {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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) { virtual Result DoGetFileTimeStampRaw(FileTimeStampRaw *out, const char *path) {
fssrv::sf::Path sf_path; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), path)); R_TRY(GetPathForServiceObject(std::addressof(sf_path), path));
static_assert(sizeof(FileTimeStampRaw) == sizeof(::FsTimeStampRaw)); 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) { 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; fssrv::sf::Path sf_path;
R_TRY(GetPathForServiceObject(std::addressof(sf_path), 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 { class RemoteStorage : public IStorage, public impl::Newable {
private: private:
std::unique_ptr<::FsStorage, impl::Deleter> base_storage; std::unique_ptr<::FsStorage, impl::Deleter> m_base_storage;
public: public:
RemoteStorage(::FsStorage &s) { RemoteStorage(::FsStorage &s) {
this->base_storage = impl::MakeUnique<::FsStorage>(); m_base_storage = impl::MakeUnique<::FsStorage>();
*this->base_storage = s; *m_base_storage = s;
} }
virtual ~RemoteStorage() { fsStorageClose(this->base_storage.get()); } virtual ~RemoteStorage() { fsStorageClose(m_base_storage.get()); }
public: public:
virtual Result Read(s64 offset, void *buffer, size_t size) override { 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 { 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 { virtual Result Flush() override {
return fsStorageFlush(this->base_storage.get()); return fsStorageFlush(m_base_storage.get());
}; };
virtual Result GetSize(s64 *out_size) override { 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 { 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 { 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: public:
using RomFileTable = HierarchicalRomFileTable; using RomFileTable = HierarchicalRomFileTable;
private: private:
RomFileTable rom_file_table; RomFileTable m_rom_file_table;
IStorage *base_storage; IStorage *m_base_storage;
std::unique_ptr<IStorage> unique_storage; std::unique_ptr<IStorage> m_unique_storage;
std::unique_ptr<IStorage> dir_bucket_storage; std::unique_ptr<IStorage> m_dir_bucket_storage;
std::unique_ptr<IStorage> dir_entry_storage; std::unique_ptr<IStorage> m_dir_entry_storage;
std::unique_ptr<IStorage> file_bucket_storage; std::unique_ptr<IStorage> m_file_bucket_storage;
std::unique_ptr<IStorage> file_entry_storage; std::unique_ptr<IStorage> m_file_entry_storage;
s64 entry_size; s64 m_entry_size;
private: private:
Result GetFileInfo(RomFileTable::FileInfo *out, const char *path); Result GetFileInfo(RomFileTable::FileInfo *out, const char *path);
public: public:

View file

@ -26,29 +26,29 @@ namespace ams::fs {
NON_COPYABLE(SharedFileSystemHolder); NON_COPYABLE(SharedFileSystemHolder);
NON_MOVEABLE(SharedFileSystemHolder); NON_MOVEABLE(SharedFileSystemHolder);
private: private:
std::shared_ptr<fsa::IFileSystem> fs; std::shared_ptr<fsa::IFileSystem> m_fs;
public: 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: public:
virtual Result DoCreateFile(const char *path, s64 size, int flags) override { return this->fs->CreateFile(path, size, flags); } 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 this->fs->DeleteFile(path); } virtual Result DoDeleteFile(const char *path) override { return m_fs->DeleteFile(path); }
virtual Result DoCreateDirectory(const char *path) override { return this->fs->CreateDirectory(path); } virtual Result DoCreateDirectory(const char *path) override { return m_fs->CreateDirectory(path); }
virtual Result DoDeleteDirectory(const char *path) override { return this->fs->DeleteDirectory(path); } virtual Result DoDeleteDirectory(const char *path) override { return m_fs->DeleteDirectory(path); }
virtual Result DoDeleteDirectoryRecursively(const char *path) override { return this->fs->DeleteDirectoryRecursively(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 this->fs->RenameFile(old_path, new_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 this->fs->RenameDirectory(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 this->fs->GetEntryType(out, 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 this->fs->OpenFile(out_file, path, mode); } 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 this->fs->OpenDirectory(out_dir, 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 this->fs->Commit(); } virtual Result DoCommit() override { return m_fs->Commit(); }
virtual Result DoGetFreeSpaceSize(s64 *out, const char *path) override { return this->fs->GetFreeSpaceSize(out, path); } 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 this->fs->GetTotalSpaceSize(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 this->fs->CleanDirectoryRecursively(path); } virtual Result DoCleanDirectoryRecursively(const char *path) override { return m_fs->CleanDirectoryRecursively(path); }
/* These aren't accessible as commands. */ /* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override { return this->fs->CommitProvisionally(counter); } virtual Result DoCommitProvisionally(s64 counter) override { return m_fs->CommitProvisionally(counter); }
virtual Result DoRollback() override { return this->fs->Rollback(); } virtual Result DoRollback() override { return m_fs->Rollback(); }
virtual Result DoFlush() override { return this->fs->Flush(); } 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 { class SubStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private: private:
std::shared_ptr<IStorage> shared_base_storage; std::shared_ptr<IStorage> m_shared_base_storage;
fs::IStorage *base_storage; fs::IStorage *m_base_storage;
s64 offset; s64 m_offset;
s64 size; s64 m_size;
bool resizable; bool m_resizable;
private: private:
constexpr bool IsValid() const { constexpr bool IsValid() const {
return this->base_storage != nullptr; return m_base_storage != nullptr;
} }
public: 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) { SubStorage &operator=(const SubStorage &rhs) {
if (this != std::addressof(rhs)) { if (this != std::addressof(rhs)) {
this->base_storage = rhs.base_storage; m_base_storage = rhs.m_base_storage;
this->offset = rhs.offset; m_offset = rhs.m_offset;
this->size = rhs.size; m_size = rhs.m_size;
this->resizable = rhs.resizable; m_resizable = rhs.m_resizable;
} }
return *this; 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->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0); AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(this->size >= 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->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0); AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(this->size >= 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->IsValid());
AMS_ABORT_UNLESS(this->offset >= 0); AMS_ABORT_UNLESS(m_offset >= 0);
AMS_ABORT_UNLESS(this->size >= 0); AMS_ABORT_UNLESS(m_size >= 0);
AMS_ABORT_UNLESS(sub->size >= o + sz); AMS_ABORT_UNLESS(sub->m_size >= o + sz);
} }
public: public:
void SetResizable(bool rsz) { void SetResizable(bool rsz) {
this->resizable = rsz; m_resizable = rsz;
} }
public: public:
virtual Result Read(s64 offset, void *buffer, size_t size) override { virtual Result Read(s64 offset, void *buffer, size_t size) override {
@ -77,9 +77,9 @@ namespace ams::fs {
/* Validate arguments and read. */ /* Validate arguments and read. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
return this->base_storage->Read(this->offset + offset, buffer, size); return m_base_storage->Read(m_offset + offset, buffer, size);
} }
virtual Result Write(s64 offset, const void *buffer, size_t size) override{ virtual Result Write(s64 offset, const void *buffer, size_t size) override{
@ -90,31 +90,31 @@ namespace ams::fs {
R_SUCCEED_IF(size == 0); R_SUCCEED_IF(size == 0);
/* Validate arguments and write. */ /* Validate arguments and write. */
R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument()); R_UNLESS(buffer != nullptr, fs::ResultNullptrArgument());
R_UNLESS(IStorage::CheckAccessRange(offset, size, this->size), fs::ResultOutOfRange()); R_UNLESS(IStorage::CheckAccessRange(offset, size, m_size), fs::ResultOutOfRange());
return this->base_storage->Write(this->offset + offset, buffer, size); return m_base_storage->Write(m_offset + offset, buffer, size);
} }
virtual Result Flush() override { virtual Result Flush() override {
R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
return this->base_storage->Flush(); return m_base_storage->Flush();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
/* Ensure we're initialized and validate arguments. */ /* Ensure we're initialized and validate arguments. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
R_UNLESS(this->resizable, fs::ResultUnsupportedOperationInSubStorageA()); R_UNLESS(m_resizable, fs::ResultUnsupportedOperationInSubStorageA());
R_UNLESS(IStorage::CheckOffsetAndSize(this->offset, size), fs::ResultInvalidSize()); R_UNLESS(IStorage::CheckOffsetAndSize(m_offset, size), fs::ResultInvalidSize());
/* Ensure that we're allowed to set size. */ /* Ensure that we're allowed to set size. */
s64 cur_size; s64 cur_size;
R_TRY(this->base_storage->GetSize(std::addressof(cur_size))); R_TRY(m_base_storage->GetSize(std::addressof(cur_size)));
R_UNLESS(cur_size == this->offset + this->size, fs::ResultUnsupportedOperationInSubStorageB()); R_UNLESS(cur_size == m_offset + m_size, fs::ResultUnsupportedOperationInSubStorageB());
/* Set the size. */ /* 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(); return ResultSuccess();
} }
@ -122,7 +122,7 @@ namespace ams::fs {
/* Ensure we're initialized. */ /* Ensure we're initialized. */
R_UNLESS(this->IsValid(), fs::ResultNotInitialized()); R_UNLESS(this->IsValid(), fs::ResultNotInitialized());
*out = this->size; *out = m_size;
return ResultSuccess(); return ResultSuccess();
} }
@ -135,7 +135,7 @@ namespace ams::fs {
/* Validate arguments and operate. */ /* Validate arguments and operate. */
R_UNLESS(IStorage::CheckOffsetAndSize(offset, size), fs::ResultOutOfRange()); 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; using IStorage::OperateRange;

View file

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

View file

@ -23,9 +23,9 @@ namespace ams::fssrv::fscreator {
NON_COPYABLE(RomFileSystemCreator); NON_COPYABLE(RomFileSystemCreator);
NON_MOVEABLE(RomFileSystemCreator); NON_MOVEABLE(RomFileSystemCreator);
private: private:
MemoryResource *allocator; MemoryResource *m_allocator;
public: 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; 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_COPYABLE(StorageOnNcaCreator);
NON_MOVEABLE(StorageOnNcaCreator); NON_MOVEABLE(StorageOnNcaCreator);
private: private:
MemoryResource *allocator; MemoryResource *m_allocator;
fssystem::IBufferManager * const buffer_manager; fssystem::IBufferManager * const m_buffer_manager;
const fssystem::NcaCryptoConfiguration &nca_crypto_cfg; const fssystem::NcaCryptoConfiguration &m_nca_crypto_cfg;
bool is_prod; bool m_is_prod;
bool is_enabled_program_verification; bool m_is_enabled_program_verification;
private: private:
Result VerifyNcaHeaderSign2(fssystem::NcaReader *nca_reader, fs::IStorage *storage); Result VerifyNcaHeaderSign2(fssystem::NcaReader *nca_reader, fs::IStorage *storage);
public: 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 { class MemoryResourceFromExpHeap : public ams::MemoryResource {
private: private:
lmem::HeapHandle heap_handle; lmem::HeapHandle m_heap_handle;
public: public:
constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : heap_handle(handle) { /* ... */ } constexpr explicit MemoryResourceFromExpHeap(lmem::HeapHandle handle) : m_heap_handle(handle) { /* ... */ }
protected: protected:
virtual void *AllocateImpl(size_t size, size_t align) override { 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 { virtual void DeallocateImpl(void *p, size_t size, size_t align) override {
AMS_UNUSED(size, align); 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 { virtual bool IsEqualImpl(const MemoryResource &rhs) const override {
@ -43,24 +43,24 @@ namespace ams::fssrv {
class PeakCheckableMemoryResourceFromExpHeap : public ams::MemoryResource { class PeakCheckableMemoryResourceFromExpHeap : public ams::MemoryResource {
private: private:
lmem::HeapHandle heap_handle; lmem::HeapHandle m_heap_handle;
os::SdkMutex mutex; os::SdkMutex m_mutex;
size_t peak_free_size; size_t m_peak_free_size;
size_t current_free_size; size_t m_current_free_size;
public: 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) { void SetHeapHandle(lmem::HeapHandle handle) {
this->heap_handle = handle; m_heap_handle = handle;
} }
size_t GetPeakFreeSize() const { return this->peak_free_size; } size_t GetPeakFreeSize() const { return m_peak_free_size; }
size_t GetCurrentFreeSize() const { return this->current_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() { 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); void OnAllocate(void *p, size_t size);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -29,11 +29,11 @@ namespace ams::fssystem {
static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize; static constexpr size_t KeySize = crypto::Aes128XtsEncryptor::KeySize;
static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize; static constexpr size_t IvSize = crypto::Aes128XtsEncryptor::IvSize;
private: private:
IStorage * const base_storage; IStorage * const m_base_storage;
char key[2][KeySize]; char m_key[2][KeySize];
char iv[IvSize]; char m_iv[IvSize];
const size_t block_size; const size_t m_block_size;
os::SdkMutex mutex; os::SdkMutex m_mutex;
public: 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); 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(DataAlign));
static_assert(util::IsPowerOfTwo(BufferAlign)); static_assert(util::IsPowerOfTwo(BufferAlign));
private: private:
std::shared_ptr<fs::IStorage> shared_base_storage; std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const base_storage; fs::IStorage * const m_base_storage;
s64 base_storage_size; s64 m_base_storage_size;
bool is_base_storage_size_dirty; bool m_is_base_storage_size_dirty;
public: 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_TRY(this->GetSize(std::addressof(bs_size)));
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); 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 { 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_TRY(this->GetSize(std::addressof(bs_size)));
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); 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 { virtual Result Flush() override {
return this->base_storage->Flush(); return m_base_storage->Flush();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; }; ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
return this->base_storage->SetSize(util::AlignUp(size, DataAlign)); return m_base_storage->SetSize(util::AlignUp(size, DataAlign));
} }
virtual Result GetSize(s64 *out) override { virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
if (this->is_base_storage_size_dirty) { if (m_is_base_storage_size_dirty) {
s64 size; 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;
this->is_base_storage_size_dirty = false; m_is_base_storage_size_dirty = false;
} }
*out = this->base_storage_size; *out = m_base_storage_size;
return ResultSuccess(); return ResultSuccess();
} }
@ -123,7 +123,7 @@ namespace ams::fssystem {
const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign); const auto aligned_offset_end = util::AlignUp(offset + valid_size, DataAlign);
const auto aligned_size = aligned_offset_end - aligned_offset; 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)); static_assert(util::IsPowerOfTwo(BufferAlign));
private: private:
fs::IStorage * const base_storage; fs::IStorage * const m_base_storage;
s64 base_storage_size; s64 m_base_storage_size;
size_t data_align; size_t m_data_align;
bool is_base_storage_size_dirty; bool m_is_base_storage_size_dirty;
public: 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)); AMS_ASSERT(util::IsPowerOfTwo(da));
} }
@ -158,9 +158,9 @@ namespace ams::fssystem {
/* Allocate a pooled buffer. */ /* Allocate a pooled buffer. */
PooledBuffer 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 { virtual Result Write(s64 offset, const void *buffer, size_t size) override {
@ -176,32 +176,32 @@ namespace ams::fssystem {
/* Allocate a pooled buffer. */ /* Allocate a pooled buffer. */
PooledBuffer 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 { virtual Result Flush() override {
return this->base_storage->Flush(); return m_base_storage->Flush();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->is_base_storage_size_dirty = true; }; ON_SCOPE_EXIT { m_is_base_storage_size_dirty = true; };
return this->base_storage->SetSize(util::AlignUp(size, this->data_align)); return m_base_storage->SetSize(util::AlignUp(size, m_data_align));
} }
virtual Result GetSize(s64 *out) override { virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
if (this->is_base_storage_size_dirty) { if (m_is_base_storage_size_dirty) {
s64 size; 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;
this->is_base_storage_size_dirty = false; m_is_base_storage_size_dirty = false;
} }
*out = this->base_storage_size; *out = m_base_storage_size;
return ResultSuccess(); return ResultSuccess();
} }
@ -216,11 +216,11 @@ namespace ams::fssystem {
/* Operate on the base storage. */ /* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset); const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, this->data_align); const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align); const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset; 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)); static_assert(util::IsPowerOfTwo(BufferAlign));
private: private:
std::shared_ptr<fs::IStorage> shared_base_storage; std::shared_ptr<fs::IStorage> m_shared_base_storage;
fs::IStorage * const base_storage; fs::IStorage * const m_base_storage;
s64 base_storage_size; s64 m_base_storage_size;
size_t data_align; size_t m_data_align;
public: public:
explicit AlignmentMatchingStorageInBulkRead(fs::IStorage *bs, size_t da) : shared_base_storage(), base_storage(bs), base_storage_size(-1), data_align(da) { 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(this->data_align)); 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)); AMS_ASSERT(util::IsPowerOfTwo(da));
} }
@ -260,30 +260,30 @@ namespace ams::fssystem {
R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange()); R_UNLESS(fs::IStorage::CheckAccessRange(offset, size, bs_size), fs::ResultOutOfRange());
/* Allocate a pooled buffer. */ /* Allocate a pooled buffer. */
PooledBuffer pooled_buffer(this->data_align, this->data_align); PooledBuffer pooled_buffer(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 { virtual Result Flush() override {
return this->base_storage->Flush(); return m_base_storage->Flush();
} }
virtual Result SetSize(s64 size) override { virtual Result SetSize(s64 size) override {
ON_SCOPE_EXIT { this->base_storage_size = -1; }; ON_SCOPE_EXIT { m_base_storage_size = -1; };
return this->base_storage->SetSize(util::AlignUp(size, this->data_align)); return m_base_storage->SetSize(util::AlignUp(size, m_data_align));
} }
virtual Result GetSize(s64 *out) override { virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
if (this->base_storage_size < 0) { if (m_base_storage_size < 0) {
s64 size; 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(); return ResultSuccess();
} }
@ -298,11 +298,11 @@ namespace ams::fssystem {
/* Operate on the base storage. */ /* Operate on the base storage. */
const auto valid_size = std::min(size, bs_size - offset); const auto valid_size = std::min(size, bs_size - offset);
const auto aligned_offset = util::AlignDown(offset, this->data_align); const auto aligned_offset = util::AlignDown(offset, m_data_align);
const auto aligned_offset_end = util::AlignUp(offset + valid_size, this->data_align); const auto aligned_offset_end = util::AlignUp(offset + valid_size, m_data_align);
const auto aligned_size = aligned_offset_end - aligned_offset; 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 { class ContinuousReadingInfo {
private: private:
size_t read_size; size_t m_read_size;
s32 skip_count; s32 m_skip_count;
bool done; bool m_done;
public: 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 void SetSkipCount(s32 count) { AMS_ASSERT(count >= 0); m_skip_count = count; }
constexpr s32 GetSkipCount() const { return this->skip_count; } constexpr s32 GetSkipCount() const { return m_skip_count; }
constexpr bool CheckNeedScan() { return (--this->skip_count) <= 0; } constexpr bool CheckNeedScan() { return (--m_skip_count) <= 0; }
constexpr void Done() { this->read_size = 0; this->done = true; } constexpr void Done() { m_read_size = 0; m_done = true; }
constexpr bool IsDone() const { return this->done; } constexpr bool IsDone() const { return m_done; }
constexpr void SetReadSize(size_t size) { this->read_size = size; } constexpr void SetReadSize(size_t size) { m_read_size = size; }
constexpr size_t GetReadSize() const { return this->read_size; } constexpr size_t GetReadSize() const { return m_read_size; }
constexpr bool CanDo() const { return this->read_size > 0; } constexpr bool CanDo() const { return m_read_size > 0; }
}; };
using IAllocator = MemoryResource; using IAllocator = MemoryResource;
@ -80,60 +80,60 @@ namespace ams::fssystem {
class NodeBuffer { class NodeBuffer {
NON_COPYABLE(NodeBuffer); NON_COPYABLE(NodeBuffer);
private: private:
IAllocator *allocator; IAllocator *m_allocator;
void *header; void *m_header;
public: public:
NodeBuffer() : allocator(), header() { /* ... */ } NodeBuffer() : m_allocator(), m_header() { /* ... */ }
~NodeBuffer() { ~NodeBuffer() {
AMS_ASSERT(this->header == nullptr); AMS_ASSERT(m_header == nullptr);
} }
NodeBuffer(NodeBuffer &&rhs) : allocator(rhs.allocator), header(rhs.allocator) { NodeBuffer(NodeBuffer &&rhs) : m_allocator(rhs.m_allocator), m_header(rhs.m_allocator) {
rhs.allocator = nullptr; rhs.m_allocator = nullptr;
rhs.header = nullptr; rhs.m_header = nullptr;
} }
NodeBuffer &operator=(NodeBuffer &&rhs) { NodeBuffer &operator=(NodeBuffer &&rhs) {
if (this != std::addressof(rhs)) { if (this != std::addressof(rhs)) {
AMS_ASSERT(this->header == nullptr); AMS_ASSERT(m_header == nullptr);
this->allocator = rhs.allocator; m_allocator = rhs.m_allocator;
this->header = rhs.header; m_header = rhs.m_header;
rhs.allocator = nullptr; rhs.m_allocator = nullptr;
rhs.header = nullptr; rhs.m_header = nullptr;
} }
return *this; return *this;
} }
bool Allocate(IAllocator *allocator, size_t node_size) { bool Allocate(IAllocator *allocator, size_t node_size) {
AMS_ASSERT(this->header == nullptr); AMS_ASSERT(m_header == nullptr);
this->allocator = allocator; m_allocator = allocator;
this->header = allocator->Allocate(node_size, sizeof(s64)); 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) { void Free(size_t node_size) {
if (this->header) { if (m_header) {
this->allocator->Deallocate(this->header, node_size); m_allocator->Deallocate(m_header, node_size);
this->header = nullptr; m_header = nullptr;
} }
this->allocator = nullptr; m_allocator = nullptr;
} }
void FillZero(size_t node_size) const { void FillZero(size_t node_size) const {
if (this->header) { if (m_header) {
std::memset(this->header, 0, node_size); std::memset(m_header, 0, node_size);
} }
} }
NodeHeader *Get() const { NodeHeader *Get() const {
return reinterpret_cast<NodeHeader *>(this->header); return reinterpret_cast<NodeHeader *>(m_header);
} }
NodeHeader *operator->() const { return this->Get(); } NodeHeader *operator->() const { return this->Get(); }
@ -142,11 +142,11 @@ namespace ams::fssystem {
T *Get() const { T *Get() const {
static_assert(util::is_pod<T>::value); static_assert(util::is_pod<T>::value);
static_assert(sizeof(T) == sizeof(NodeHeader)); static_assert(sizeof(T) == sizeof(NodeHeader));
return reinterpret_cast<T *>(this->header); return reinterpret_cast<T *>(m_header);
} }
IAllocator *GetAllocator() const { IAllocator *GetAllocator() const {
return this->allocator; return m_allocator;
} }
}; };
private: private:
@ -205,43 +205,43 @@ namespace ams::fssystem {
return GetEntrySetCount(node_size, entry_size, entry_count) * static_cast<s64>(node_size); return GetEntrySetCount(node_size, entry_size, entry_count) * static_cast<s64>(node_size);
} }
private: private:
mutable fs::SubStorage node_storage; mutable fs::SubStorage m_node_storage;
mutable fs::SubStorage entry_storage; mutable fs::SubStorage m_entry_storage;
NodeBuffer node_l1; NodeBuffer m_node_l1;
size_t node_size; size_t m_node_size;
size_t entry_size; size_t m_entry_size;
s32 entry_count; s32 m_entry_count;
s32 offset_count; s32 m_offset_count;
s32 entry_set_count; s32 m_entry_set_count;
s64 start_offset; s64 m_start_offset;
s64 end_offset; s64 m_end_offset;
public: 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(); } ~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); 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 Initialize(size_t node_size, s64 end_offset);
void Finalize(); void Finalize();
bool IsInitialized() const { return this->node_size > 0; } bool IsInitialized() const { return m_node_size > 0; }
bool IsEmpty() const { return this->entry_size == 0; } bool IsEmpty() const { return m_entry_size == 0; }
Result Find(Visitor *visitor, s64 virtual_address) const; Result Find(Visitor *visitor, s64 virtual_address) const;
Result InvalidateCache(); Result InvalidateCache();
s32 GetEntryCount() const { return this->entry_count; } s32 GetEntryCount() const { return m_entry_count; }
IAllocator *GetAllocator() const { return this->node_l1.GetAllocator(); } IAllocator *GetAllocator() const { return m_node_l1.GetAllocator(); }
s64 GetStart() const { return this->start_offset; } s64 GetStart() const { return m_start_offset; }
s64 GetEnd() const { return this->end_offset; } s64 GetEnd() const { return m_end_offset; }
s64 GetSize() const { return this->end_offset - this->start_offset; } s64 GetSize() const { return m_end_offset - m_start_offset; }
bool Includes(s64 offset) const { 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 { 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: private:
template<typename EntryType> template<typename EntryType>
@ -256,11 +256,11 @@ namespace ams::fssystem {
template<typename EntryType> template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam<EntryType> &param) const; Result ScanContinuousReading(ContinuousReadingInfo *out_info, const ContinuousReadingParam<EntryType> &param) const;
bool IsExistL2() const { return this->offset_count < this->entry_set_count; } bool IsExistL2() const { return m_offset_count < m_entry_set_count; }
bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && this->node_l1->count < this->offset_count; } bool IsExistOffsetL2OnL1() const { return this->IsExistL2() && m_node_l1->count < m_offset_count; }
s64 GetEntrySetIndex(s32 node_index, s32 offset_index) const { 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); static_assert(util::is_pod<EntrySetHeader>::value);
private: private:
const BucketTree *tree; const BucketTree *m_tree;
void *entry; void *m_entry;
s32 entry_index; s32 m_entry_index;
s32 entry_set_count; s32 m_entry_set_count;
EntrySetHeader entry_set; EntrySetHeader m_entry_set;
public: 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() { ~Visitor() {
if (this->entry != nullptr) { if (m_entry != nullptr) {
this->tree->GetAllocator()->Deallocate(this->entry, this->tree->entry_size); m_tree->GetAllocator()->Deallocate(m_entry, m_tree->m_entry_size);
this->tree = nullptr; m_tree = nullptr;
this->entry = nullptr; m_entry = nullptr;
} }
} }
bool IsValid() const { return this->entry_index >= 0; } bool IsValid() const { return m_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 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() && (this->entry_index > 0 || this->entry_set.info.index > 0); } bool CanMovePrevious() const { return this->IsValid() && (m_entry_index > 0 || m_entry_set.info.index > 0); }
Result MoveNext(); Result MoveNext();
Result MovePrevious(); Result MovePrevious();
@ -307,12 +307,12 @@ namespace ams::fssystem {
template<typename EntryType> template<typename EntryType>
Result ScanContinuousReading(ContinuousReadingInfo *out_info, s64 offset, size_t size) const; 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> 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: private:
Result Initialize(const BucketTree *tree); Result Initialize(const BucketTree *tree);

View file

@ -27,7 +27,7 @@ namespace ams::fssystem {
/* Validate our preconditions. */ /* Validate our preconditions. */
AMS_ASSERT(this->IsInitialized()); AMS_ASSERT(this->IsInitialized());
AMS_ASSERT(out_info != nullptr); AMS_ASSERT(out_info != nullptr);
AMS_ASSERT(this->entry_size == sizeof(EntryType)); AMS_ASSERT(m_entry_size == sizeof(EntryType));
/* Reset the output. */ /* Reset the output. */
out_info->Reset(); out_info->Reset();
@ -44,14 +44,14 @@ namespace ams::fssystem {
R_UNLESS(entry.GetVirtualOffset() <= cur_offset, fs::ResultOutOfRange()); R_UNLESS(entry.GetVirtualOffset() <= cur_offset, fs::ResultOutOfRange());
/* Create a pooled buffer for our scan. */ /* Create a pooled buffer for our scan. */
PooledBuffer pool(this->node_size, 1); PooledBuffer pool(m_node_size, 1);
char *buffer = nullptr; char *buffer = nullptr;
/* Read the node. */ /* Read the node. */
if (this->node_size <= pool.GetSize()) { if (m_node_size <= pool.GetSize()) {
buffer = pool.GetBuffer(); buffer = pool.GetBuffer();
const auto ofs = param.entry_set.index * static_cast<s64>(this->node_size); const auto ofs = param.entry_set.index * static_cast<s64>(m_node_size);
R_TRY(this->entry_storage.Read(ofs, buffer, this->node_size)); R_TRY(m_entry_storage.Read(ofs, buffer, m_node_size));
} }
/* Calculate extents. */ /* Calculate extents. */
@ -81,11 +81,11 @@ namespace ams::fssystem {
if (entry_index + 1 < entry_count) { if (entry_index + 1 < entry_count) {
if (buffer != nullptr) { if (buffer != nullptr) {
const auto ofs = impl::GetBucketTreeEntryOffset(0, this->entry_size, entry_index + 1); const auto ofs = impl::GetBucketTreeEntryOffset(0, m_entry_size, entry_index + 1);
std::memcpy(std::addressof(next_entry), buffer + ofs, this->entry_size); std::memcpy(std::addressof(next_entry), buffer + ofs, m_entry_size);
} else { } else {
const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, this->node_size, this->entry_size, entry_index + 1); const auto ofs = impl::GetBucketTreeEntryOffset(param.entry_set.index, m_node_size, m_entry_size, entry_index + 1);
R_TRY(this->entry_storage.Read(ofs, std::addressof(next_entry), this->entry_size)); R_TRY(m_entry_storage.Read(ofs, std::addressof(next_entry), m_entry_size));
} }
next_entry_offset = next_entry.GetVirtualOffset(); next_entry_offset = next_entry.GetVirtualOffset();
@ -154,12 +154,12 @@ namespace ams::fssystem {
/* Create our parameters. */ /* Create our parameters. */
ContinuousReadingParam<EntryType> param = { 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. */ /* 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>; using PathResolutionFileSystem = impl::IPathResolutionFileSystem<DirectoryRedirectionFileSystem>;
friend class impl::IPathResolutionFileSystem<DirectoryRedirectionFileSystem>; friend class impl::IPathResolutionFileSystem<DirectoryRedirectionFileSystem>;
private: private:
char *before_dir; char *m_before_dir;
size_t before_dir_len; size_t m_before_dir_len;
char *after_dir; char *m_after_dir;
size_t after_dir_len; size_t m_after_dir_len;
public: public:
DirectoryRedirectionFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, const char *before, const char *after, bool unc = false); 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); 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>; using PathResolutionFileSystem = impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
friend class impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>; friend class impl::IPathResolutionFileSystem<DirectorySaveDataFileSystem>;
private: private:
os::SdkMutex accessor_mutex; os::SdkMutex m_accessor_mutex;
s32 open_writable_files; s32 m_open_writable_files;
public: public:
DirectorySaveDataFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs); DirectorySaveDataFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs);
DirectorySaveDataFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs); DirectorySaveDataFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs);
@ -35,7 +35,7 @@ namespace ams::fssystem {
protected: protected:
inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() { inline util::optional<std::scoped_lock<os::SdkMutex>> GetAccessorLock() {
/* We have a real accessor lock that we want to use. */ /* 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: private:
Result AllocateWorkBuffer(std::unique_ptr<u8[]> *out, size_t *out_size, size_t ideal_size); 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); return BucketTree::QueryEntryStorageSize(NodeSize, sizeof(Entry), entry_count);
} }
private: private:
BucketTree table; BucketTree m_table;
fs::SubStorage data_storage[StorageCount]; fs::SubStorage m_data_storage[StorageCount];
public: public:
IndirectStorage() : table(), data_storage() { /* ... */ } IndirectStorage() : m_table(), m_data_storage() { /* ... */ }
virtual ~IndirectStorage() { this->Finalize(); } virtual ~IndirectStorage() { this->Finalize(); }
Result Initialize(IAllocator *allocator, fs::SubStorage table_storage); Result Initialize(IAllocator *allocator, fs::SubStorage table_storage);
void Finalize(); 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) { 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) { void SetStorage(s32 idx, fs::SubStorage storage) {
AMS_ASSERT(0 <= idx && idx < StorageCount); AMS_ASSERT(0 <= idx && idx < StorageCount);
this->data_storage[idx] = storage; m_data_storage[idx] = storage;
} }
template<typename T> template<typename T>
void SetStorage(s32 idx, T storage, s64 offset, s64 size) { void SetStorage(s32 idx, T storage, s64 offset, s64 size) {
AMS_ASSERT(0 <= idx && idx < StorageCount); 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); 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 { virtual Result GetSize(s64 *out) override {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
*out = this->table.GetEnd(); *out = m_table.GetEnd();
return ResultSuccess(); return ResultSuccess();
} }
@ -151,11 +151,11 @@ namespace ams::fssystem {
return fs::ResultUnsupportedOperationInIndirectStorageB(); return fs::ResultUnsupportedOperationInIndirectStorageB();
} }
protected: protected:
BucketTree &GetEntryTable() { return this->table; } BucketTree &GetEntryTable() { return m_table; }
fs::SubStorage &GetDataStorage(s32 index) { fs::SubStorage &GetDataStorage(s32 index) {
AMS_ASSERT(0 <= index && index < StorageCount); AMS_ASSERT(0 <= index && index < StorageCount);
return this->data_storage[index]; return m_data_storage[index];
} }
template<bool ContinuousCheck, typename F> template<bool ContinuousCheck, typename F>

View file

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

View file

@ -28,46 +28,46 @@ namespace ams::fssystem {
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable { class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private: private:
save::HierarchicalIntegrityVerificationStorage integrity_storage; save::HierarchicalIntegrityVerificationStorage m_integrity_storage;
save::FileSystemBufferManagerSet buffers; save::FileSystemBufferManagerSet m_buffers;
os::SdkRecursiveMutex mutex; os::SdkRecursiveMutex m_mutex;
Hash master_hash; Hash m_master_hash;
std::unique_ptr<fs::MemoryStorage> master_hash_storage; std::unique_ptr<fs::MemoryStorage> m_master_hash_storage;
public: public:
IntegrityRomFsStorage() : mutex() { /* ... */ } IntegrityRomFsStorage() : m_mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); } virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm); Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, IBufferManager *bm);
void Finalize(); void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override { 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 { 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 SetSize(s64 size) override { AMS_UNUSED(size); return fs::ResultUnsupportedOperationInIntegrityRomFsStorageA(); }
virtual Result GetSize(s64 *out) override { virtual Result GetSize(s64 *out) override {
return this->integrity_storage.GetSize(out); return m_integrity_storage.GetSize(out);
} }
virtual Result Flush() override { 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 { 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() { Result Commit() {
return this->integrity_storage.Commit(); return m_integrity_storage.Commit();
} }
save::FileSystemBufferManagerSet *GetBuffers() { 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_COPYABLE(NcaReader);
NON_MOVEABLE(NcaReader); NON_MOVEABLE(NcaReader);
private: private:
NcaHeader header; NcaHeader m_header;
u8 decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize]; u8 m_decryption_keys[NcaHeader::DecryptionKey_Count][NcaCryptoConfiguration::Aes128KeySize];
std::shared_ptr<fs::IStorage> shared_base_storage; std::shared_ptr<fs::IStorage> m_shared_base_storage;
std::unique_ptr<fs::IStorage> header_storage; std::unique_ptr<fs::IStorage> m_header_storage;
fs::IStorage *body_storage; fs::IStorage *m_body_storage;
u8 external_decryption_key[NcaCryptoConfiguration::Aes128KeySize]; u8 m_external_decryption_key[NcaCryptoConfiguration::Aes128KeySize];
DecryptAesCtrFunction decrypt_aes_ctr; DecryptAesCtrFunction m_decrypt_aes_ctr;
DecryptAesCtrFunction decrypt_aes_ctr_external; DecryptAesCtrFunction m_decrypt_aes_ctr_external;
bool is_software_aes_prioritized; bool m_is_software_aes_prioritized;
NcaHeader::EncryptionType header_encryption_type; NcaHeader::EncryptionType m_header_encryption_type;
public: public:
NcaReader(); NcaReader();
~NcaReader(); ~NcaReader();
@ -143,18 +143,18 @@ namespace ams::fssystem {
NON_COPYABLE(NcaFsHeaderReader); NON_COPYABLE(NcaFsHeaderReader);
NON_MOVEABLE(NcaFsHeaderReader); NON_MOVEABLE(NcaFsHeaderReader);
private: private:
NcaFsHeader data; NcaFsHeader m_data;
s32 fs_index; s32 m_fs_index;
public: public:
NcaFsHeaderReader() : fs_index(-1) { NcaFsHeaderReader() : m_fs_index(-1) {
std::memset(std::addressof(this->data), 0, sizeof(this->data)); std::memset(std::addressof(m_data), 0, sizeof(m_data));
} }
Result Initialize(const NcaReader &reader, s32 index); 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; } NcaFsHeader &GetData() { return m_data; }
const NcaFsHeader &GetData() const { return this->data; } const NcaFsHeader &GetData() const { return m_data; }
void GetRawData(void *dst, size_t dst_size) const; void GetRawData(void *dst, size_t dst_size) const;
NcaFsHeader::HashData &GetHashData(); NcaFsHeader::HashData &GetHashData();
@ -179,19 +179,19 @@ namespace ams::fssystem {
class StorageOption; class StorageOption;
class StorageOptionWithHeaderReader; class StorageOptionWithHeaderReader;
private: private:
std::shared_ptr<NcaReader> original_reader; std::shared_ptr<NcaReader> m_original_reader;
std::shared_ptr<NcaReader> reader; std::shared_ptr<NcaReader> m_reader;
MemoryResource * const allocator; MemoryResource * const m_allocator;
fssystem::IBufferManager * const buffer_manager; fssystem::IBufferManager * const m_buffer_manager;
public: public:
static Result SetupFsHeaderReader(NcaFsHeaderReader *out, const NcaReader &reader, s32 fs_index); static Result SetupFsHeaderReader(NcaFsHeaderReader *out, const NcaReader &reader, s32 fs_index);
public: public:
NcaFileSystemDriver(std::shared_ptr<NcaReader> reader, MemoryResource *allocator, IBufferManager *buffer_manager) : original_reader(), reader(reader), allocator(allocator), buffer_manager(buffer_manager) { 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(this->reader != nullptr); 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) { 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(this->reader != nullptr); AMS_ASSERT(m_reader != nullptr);
} }
Result OpenRawStorage(std::shared_ptr<fs::IStorage> *out, s32 fs_index); Result OpenRawStorage(std::shared_ptr<fs::IStorage> *out, s32 fs_index);

View file

@ -24,126 +24,126 @@ namespace ams::fssystem {
private: private:
friend class NcaFileSystemDriver; friend class NcaFileSystemDriver;
private: private:
const s32 fs_index; const s32 m_fs_index;
NcaFsHeaderReader * const header_reader; NcaFsHeaderReader * const m_header_reader;
fs::IStorage *data_storage; fs::IStorage *m_data_storage;
s64 data_storage_size; s64 m_data_storage_size;
fs::IStorage *aes_ctr_ex_table_storage; fs::IStorage *m_aes_ctr_ex_table_storage;
AesCtrCounterExtendedStorage *aes_ctr_ex_storage_raw; AesCtrCounterExtendedStorage *m_aes_ctr_ex_storage_raw;
fs::IStorage *aes_ctr_ex_storage; fs::IStorage *m_aes_ctr_ex_storage;
IndirectStorage *indirect_storage; IndirectStorage *m_indirect_storage;
SparseStorage *sparse_storage; SparseStorage *m_sparse_storage;
public: 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() { 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(this->header_reader != nullptr); 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() { 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(this->header_reader != nullptr); AMS_ASSERT(m_header_reader != nullptr);
AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax); AMS_ASSERT(0 <= index && index < NcaHeader::FsCountMax);
} }
s32 GetFsIndex() const { return this->fs_index; } s32 GetFsIndex() const { return m_fs_index; }
NcaFsHeaderReader &GetHeaderReader() { return *this->header_reader; } NcaFsHeaderReader &GetHeaderReader() { return *m_header_reader; }
const NcaFsHeaderReader &GetHeaderReader() const { return *this->header_reader; } const NcaFsHeaderReader &GetHeaderReader() const { return *m_header_reader; }
fs::SubStorage GetDataStorage() const { return fs::SubStorage(this->data_storage, 0, this->data_storage_size); } fs::SubStorage GetDataStorage() const { return fs::SubStorage(m_data_storage, 0, m_data_storage_size); }
fs::IStorage *GetAesCtrExTableStorage() const { return this->aes_ctr_ex_table_storage; } fs::IStorage *GetAesCtrExTableStorage() const { return m_aes_ctr_ex_table_storage; }
fs::IStorage *GetAesCtrExStorage() const { return this->aes_ctr_ex_storage; } fs::IStorage *GetAesCtrExStorage() const { return m_aes_ctr_ex_storage; }
AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return this->aes_ctr_ex_storage_raw; } AesCtrCounterExtendedStorage *GetAesCtrExStorageRaw() const { return m_aes_ctr_ex_storage_raw; }
IndirectStorage *GetIndirectStorage() const { return this->indirect_storage; } IndirectStorage *GetIndirectStorage() const { return m_indirect_storage; }
SparseStorage *GetSparseStorage() const { return this->sparse_storage; } SparseStorage *GetSparseStorage() const { return m_sparse_storage; }
private: private:
void SetDataStorage(fs::IStorage *storage, s64 size) { void SetDataStorage(fs::IStorage *storage, s64 size) {
AMS_ASSERT(storage != nullptr); AMS_ASSERT(storage != nullptr);
AMS_ASSERT(size >= 0); AMS_ASSERT(size >= 0);
this->data_storage = storage; m_data_storage = storage;
this->data_storage_size = size; m_data_storage_size = size;
} }
void SetAesCtrExTableStorage(fs::IStorage *storage) { AMS_ASSERT(storage != nullptr); this->aes_ctr_ex_table_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); this->aes_ctr_ex_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); this->aes_ctr_ex_storage_raw = storage; } void SetAesCtrExStorageRaw(AesCtrCounterExtendedStorage *storage) { AMS_ASSERT(storage != nullptr); m_aes_ctr_ex_storage_raw = storage; }
void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); this->indirect_storage = storage; } void SetIndirectStorage(IndirectStorage *storage) { AMS_ASSERT(storage != nullptr); m_indirect_storage = storage; }
void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); this->sparse_storage = storage; } void SetSparseStorage(SparseStorage *storage) { AMS_ASSERT(storage != nullptr); m_sparse_storage = storage; }
}; };
class NcaFileSystemDriver::StorageOptionWithHeaderReader : public NcaFileSystemDriver::StorageOption { class NcaFileSystemDriver::StorageOptionWithHeaderReader : public NcaFileSystemDriver::StorageOption {
private: private:
NcaFsHeaderReader header_reader_data; NcaFsHeaderReader m_header_reader_data;
public: 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 { class NcaFileSystemDriver::BaseStorage {
private: private:
std::unique_ptr<fs::IStorage> storage; std::unique_ptr<fs::IStorage> m_storage;
fs::SubStorage sub_storage; fs::SubStorage m_sub_storage;
s64 storage_offset; s64 m_storage_offset;
NcaAesCtrUpperIv aes_ctr_upper_iv; NcaAesCtrUpperIv m_aes_ctr_upper_iv;
public: public:
BaseStorage() : storage(), sub_storage(), storage_offset(0) { BaseStorage() : m_storage(), m_sub_storage(), m_storage_offset(0) {
this->aes_ctr_upper_iv.value = 0; m_aes_ctr_upper_iv.value = 0;
} }
explicit BaseStorage(const fs::SubStorage &ss) : storage(), sub_storage(ss), storage_offset(0) { explicit BaseStorage(const fs::SubStorage &ss) : m_storage(), m_sub_storage(ss), m_storage_offset(0) {
this->aes_ctr_upper_iv.value = 0; m_aes_ctr_upper_iv.value = 0;
} }
template<typename T> template<typename T>
BaseStorage(T s, s64 offset, s64 size) : storage(), sub_storage(s, offset, size), storage_offset(0) { BaseStorage(T s, s64 offset, s64 size) : m_storage(), m_sub_storage(s, offset, size), m_storage_offset(0) {
this->aes_ctr_upper_iv.value = 0; m_aes_ctr_upper_iv.value = 0;
} }
void SetStorage(std::unique_ptr<fs::IStorage> &&storage) { void SetStorage(std::unique_ptr<fs::IStorage> &&storage) {
this->storage = std::move(storage); m_storage = std::move(storage);
} }
template<typename T> template<typename T>
void SetStorage(T storage, s64 offset, s64 size) { 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() { std::unique_ptr<fs::IStorage> MakeStorage() {
if (this->storage != nullptr) { if (m_storage != nullptr) {
return std::move(this->storage); 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() { 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) { Result GetSubStorage(fs::SubStorage *out, s64 offset, s64 size) {
s64 storage_size = 0; s64 storage_size = 0;
if (this->storage != nullptr) { if (m_storage != nullptr) {
R_TRY(this->storage->GetSize(std::addressof(storage_size))); R_TRY(m_storage->GetSize(std::addressof(storage_size)));
R_UNLESS(offset + size <= storage_size, fs::ResultNcaBaseStorageOutOfRangeA()); 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 { } 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()); 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(); return ResultSuccess();
} }
void SetStorageOffset(s64 offset) { void SetStorageOffset(s64 offset) {
this->storage_offset = offset; m_storage_offset = offset;
} }
s64 GetStorageOffset() const { s64 GetStorageOffset() const {
return this->storage_offset; return m_storage_offset;
} }
void SetAesCtrUpperIv(NcaAesCtrUpperIv v) { void SetAesCtrUpperIv(NcaAesCtrUpperIv v) {
this->aes_ctr_upper_iv = v; m_aes_ctr_upper_iv = v;
} }
const NcaAesCtrUpperIv GetAesCtrUpperIv() const { 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 PartitionFile;
class PartitionDirectory; class PartitionDirectory;
private: private:
fs::IStorage *base_storage; fs::IStorage *m_base_storage;
MetaType *meta_data; MetaType *m_meta_data;
bool initialized; bool m_initialized;
size_t meta_data_size; size_t m_meta_data_size;
std::unique_ptr<MetaType> unique_meta_data; std::unique_ptr<MetaType> m_unique_meta_data;
std::shared_ptr<fs::IStorage> shared_storage; std::shared_ptr<fs::IStorage> m_shared_storage;
private: private:
Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator); Result Initialize(fs::IStorage *base_storage, MemoryResource *allocator);
public: public:

View file

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

View file

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

View file

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

View file

@ -65,9 +65,9 @@ namespace ams::fssystem {
} }
}; };
private: private:
ZeroStorage zero_storage; ZeroStorage m_zero_storage;
public: public:
SparseStorage() : IndirectStorage(), zero_storage() { /* ... */ } SparseStorage() : IndirectStorage(), m_zero_storage() { /* ... */ }
virtual ~SparseStorage() { /* ... */ } virtual ~SparseStorage() { /* ... */ }
using IndirectStorage::Initialize; using IndirectStorage::Initialize;
@ -95,7 +95,7 @@ namespace ams::fssystem {
virtual Result Read(s64 offset, void *buffer, size_t size) override; virtual Result Read(s64 offset, void *buffer, size_t size) override;
private: private:
void SetZeroStorage() { 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>; using PathResolutionFileSystem = impl::IPathResolutionFileSystem<SubDirectoryFileSystem>;
friend class impl::IPathResolutionFileSystem<SubDirectoryFileSystem>; friend class impl::IPathResolutionFileSystem<SubDirectoryFileSystem>;
private: private:
char *base_path; char *m_base_path;
size_t base_path_len; size_t m_base_path_len;
public: public:
SubDirectoryFileSystem(std::shared_ptr<fs::fsa::IFileSystem> fs, const char *bp, bool unc = false); 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); SubDirectoryFileSystem(std::unique_ptr<fs::fsa::IFileSystem> fs, const char *bp, bool unc = false);

View file

@ -48,9 +48,9 @@ namespace ams::fssystem {
private: private:
static s32 GetThreadPriorityByAccessPriority(AccessMode mode); static s32 GetThreadPriorityByAccessPriority(AccessMode mode);
private: private:
ScopedThreadPriorityChanger scoped_changer; ScopedThreadPriorityChanger m_scoped_changer;
public: 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 { class IPathResolutionFileSystem : public fs::fsa::IFileSystem, public fs::impl::Newable {
NON_COPYABLE(IPathResolutionFileSystem); NON_COPYABLE(IPathResolutionFileSystem);
private: private:
std::shared_ptr<fs::fsa::IFileSystem> shared_fs; std::shared_ptr<fs::fsa::IFileSystem> m_shared_fs;
std::unique_ptr<fs::fsa::IFileSystem> unique_fs; std::unique_ptr<fs::fsa::IFileSystem> m_unique_fs;
bool unc_preserved; bool m_unc_preserved;
protected: protected:
fs::fsa::IFileSystem * const base_fs; fs::fsa::IFileSystem * const m_base_fs;
public: 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() { /* ... */ } virtual ~IPathResolutionFileSystem() { /* ... */ }
protected: protected:
constexpr inline bool IsUncPreserved() const { constexpr inline bool IsUncPreserved() const {
return this->unc_preserved; return m_unc_preserved;
} }
public: public:
virtual Result DoCreateFile(const char *path, s64 size, int option) override { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); 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(); 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 { 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)); 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(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { virtual Result DoCommit() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { 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)); R_TRY(static_cast<Impl*>(this)->ResolveFullPath(full_path, sizeof(full_path), path));
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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. */ /* These aren't accessible as commands. */
virtual Result DoCommitProvisionally(s64 counter) override { virtual Result DoCommitProvisionally(s64 counter) override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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 { virtual Result DoRollback() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock();
return this->base_fs->Rollback(); return m_base_fs->Rollback();
} }
virtual Result DoFlush() override { virtual Result DoFlush() override {
util::optional optional_lock = static_cast<Impl*>(this)->GetAccessorLock(); 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), Flag_RealData = (1 << 10),
}; };
private: private:
IBufferManager *buffer_manager; IBufferManager *m_buffer_manager;
os::SdkRecursiveMutex *mutex; os::SdkRecursiveMutex *m_mutex;
std::unique_ptr<CacheEntry[], ::ams::fs::impl::Deleter> entries; std::unique_ptr<CacheEntry[], ::ams::fs::impl::Deleter> m_entries;
IStorage *data_storage; IStorage *m_data_storage;
Result last_result; Result m_last_result;
s64 data_size; s64 m_data_size;
size_t verification_block_size; size_t m_verification_block_size;
size_t verification_block_shift; size_t m_verification_block_shift;
CacheIndex invalidate_index; CacheIndex m_invalidate_index;
s32 max_cache_entry_count; s32 m_max_cache_entry_count;
s32 flags; s32 m_flags;
s32 buffer_level; s32 m_buffer_level;
fs::StorageType storage_type; fs::StorageType m_storage_type;
public: public:
BlockCacheBufferedStorage(); BlockCacheBufferedStorage();
virtual ~BlockCacheBufferedStorage() override; virtual ~BlockCacheBufferedStorage() override;
@ -96,31 +96,31 @@ namespace ams::fssystem::save {
Result OnRollback(); Result OnRollback();
bool IsEnabledKeepBurstMode() const { bool IsEnabledKeepBurstMode() const {
return (this->flags & Flag_KeepBurstMode) != 0; return (m_flags & Flag_KeepBurstMode) != 0;
} }
bool IsRealDataCache() const { bool IsRealDataCache() const {
return (this->flags & Flag_RealData) != 0; return (m_flags & Flag_RealData) != 0;
} }
void SetKeepBurstMode(bool en) { void SetKeepBurstMode(bool en) {
if (en) { if (en) {
this->flags |= Flag_KeepBurstMode; m_flags |= Flag_KeepBurstMode;
} else { } else {
this->flags &= ~Flag_KeepBurstMode; m_flags &= ~Flag_KeepBurstMode;
} }
} }
void SetRealDataCache(bool en) { void SetRealDataCache(bool en) {
if (en) { if (en) {
this->flags |= Flag_RealData; m_flags |= Flag_RealData;
} else { } else {
this->flags &= ~Flag_RealData; m_flags &= ~Flag_RealData;
} }
} }
private: private:
s32 GetMaxCacheEntryCount() const { s32 GetMaxCacheEntryCount() const {
return this->max_cache_entry_count; return m_max_cache_entry_count;
} }
Result ClearImpl(s64 offset, s64 size); Result ClearImpl(s64 offset, s64 size);

View file

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

View file

@ -82,8 +82,8 @@ namespace ams::fssystem::save {
}; };
static_assert(util::is_pod<InputParam>::value); static_assert(util::is_pod<InputParam>::value);
private: private:
fs::SubStorage storage; fs::SubStorage m_storage;
HierarchicalIntegrityVerificationMetaInformation meta; HierarchicalIntegrityVerificationMetaInformation m_meta;
public: public:
static Result QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size); static Result QuerySize(HierarchicalIntegrityVerificationSizeSet *out, const InputParam &input_param, s32 layer_count, s64 data_size);
/* TODO Format */ /* TODO Format */
@ -94,10 +94,10 @@ namespace ams::fssystem::save {
Result Initialize(fs::SubStorage meta_storage); Result Initialize(fs::SubStorage meta_storage);
void Finalize(); void Finalize();
u32 GetMasterHashSize() const { return this->meta.master_hash_size; } u32 GetMasterHashSize() const { return m_meta.master_hash_size; }
void GetLevelHashInfo(HierarchicalIntegrityVerificationInformation *out) { void GetLevelHashInfo(HierarchicalIntegrityVerificationInformation *out) {
AMS_ASSERT(out != nullptr); 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, DataStorage = 6,
}; };
private: private:
fs::SubStorage storages[DataStorage + 1]; fs::SubStorage m_storages[DataStorage + 1];
public: public:
void SetMasterHashStorage(fs::SubStorage s) { this->storages[MasterStorage] = s; } void SetMasterHashStorage(fs::SubStorage s) { m_storages[MasterStorage] = s; }
void SetLayer1HashStorage(fs::SubStorage s) { this->storages[Layer1Storage] = s; } void SetLayer1HashStorage(fs::SubStorage s) { m_storages[Layer1Storage] = s; }
void SetLayer2HashStorage(fs::SubStorage s) { this->storages[Layer2Storage] = s; } void SetLayer2HashStorage(fs::SubStorage s) { m_storages[Layer2Storage] = s; }
void SetLayer3HashStorage(fs::SubStorage s) { this->storages[Layer3Storage] = s; } void SetLayer3HashStorage(fs::SubStorage s) { m_storages[Layer3Storage] = s; }
void SetLayer4HashStorage(fs::SubStorage s) { this->storages[Layer4Storage] = s; } void SetLayer4HashStorage(fs::SubStorage s) { m_storages[Layer4Storage] = s; }
void SetLayer5HashStorage(fs::SubStorage s) { this->storages[Layer5Storage] = s; } void SetLayer5HashStorage(fs::SubStorage s) { m_storages[Layer5Storage] = s; }
void SetDataStorage(fs::SubStorage s) { this->storages[DataStorage] = s; } void SetDataStorage(fs::SubStorage s) { m_storages[DataStorage] = s; }
fs::SubStorage &operator[](s32 index) { fs::SubStorage &operator[](s32 index) {
AMS_ASSERT(MasterStorage <= index && index <= DataStorage); AMS_ASSERT(MasterStorage <= index && index <= DataStorage);
return this->storages[index]; return m_storages[index];
} }
}; };
private: private:
@ -146,15 +146,15 @@ namespace ams::fssystem::save {
s_generate_random = func; s_generate_random = func;
} }
private: private:
FileSystemBufferManagerSet *buffers; FileSystemBufferManagerSet *m_buffers;
os::SdkRecursiveMutex *mutex; os::SdkRecursiveMutex *m_mutex;
IntegrityVerificationStorage verify_storages[MaxLayers - 1]; IntegrityVerificationStorage m_verify_storages[MaxLayers - 1];
BlockCacheBufferedStorage buffer_storages[MaxLayers - 1]; BlockCacheBufferedStorage m_buffer_storages[MaxLayers - 1];
s64 data_size; s64 m_data_size;
s32 max_layers; s32 m_max_layers;
bool is_written_for_rollback; bool m_is_written_for_rollback;
public: 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(); } virtual ~HierarchicalIntegrityVerificationStorage() override { this->Finalize(); }
Result Initialize(const HierarchicalIntegrityVerificationInformation &info, HierarchicalStorageInformation storage, FileSystemBufferManagerSet *bufs, os::SdkRecursiveMutex *mtx, fs::StorageType storage_type); 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(); Result OnRollback();
bool IsInitialized() const { bool IsInitialized() const {
return this->data_size >= 0; return m_data_size >= 0;
} }
bool IsWrittenForRollback() const { bool IsWrittenForRollback() const {
return this->is_written_for_rollback; return m_is_written_for_rollback;
} }
FileSystemBufferManagerSet *GetBuffers() { FileSystemBufferManagerSet *GetBuffers() {
return this->buffers; return m_buffers;
} }
void GetParameters(HierarchicalIntegrityVerificationStorageControlArea::InputParam *out) const { void GetParameters(HierarchicalIntegrityVerificationStorageControlArea::InputParam *out) const {
AMS_ASSERT(out != nullptr); AMS_ASSERT(out != nullptr);
for (auto level = 0; level <= this->max_layers - 2; ++level) { for (auto level = 0; level <= m_max_layers - 2; ++level) {
out->level_block_size[level] = static_cast<size_t>(this->verify_storages[level].GetBlockSize()); out->level_block_size[level] = static_cast<size_t>(m_verify_storages[level].GetBlockSize());
} }
} }
s64 GetL1HashVerificationBlockSize() const { s64 GetL1HashVerificationBlockSize() const {
return this->verify_storages[this->max_layers - 2].GetBlockSize(); return m_verify_storages[m_max_layers - 2].GetBlockSize();
} }
fs::SubStorage GetL1HashStorage() { 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); static_assert(util::is_pod<BlockHash>::value);
private: private:
fs::SubStorage hash_storage; fs::SubStorage m_hash_storage;
fs::SubStorage data_storage; fs::SubStorage m_data_storage;
s64 verification_block_size; s64 m_verification_block_size;
s64 verification_block_order; s64 m_verification_block_order;
s64 upper_layer_verification_block_size; s64 m_upper_layer_verification_block_size;
s64 upper_layer_verification_block_order; s64 m_upper_layer_verification_block_order;
IBufferManager *buffer_manager; IBufferManager *m_buffer_manager;
fs::HashSalt salt; fs::HashSalt m_salt;
bool is_real_data; bool m_is_real_data;
fs::StorageType storage_type; fs::StorageType m_storage_type;
public: 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(); } 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); 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; void CalcBlockHash(BlockHash *out, const void *buffer, size_t block_size) const;
s64 GetBlockSize() const { s64 GetBlockSize() const {
return this->verification_block_size; return m_verification_block_size;
} }
private: private:
Result ReadBlockSignature(void *dst, size_t dst_size, s64 offset, size_t size); 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); Result VerifyHash(const void *buf, BlockHash *hash);
void CalcBlockHash(BlockHash *out, const void *buffer) const { 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); Result IsCleared(bool *is_cleared, const BlockHash &hash);

View file

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

View file

@ -23,26 +23,26 @@ namespace ams::gpio::driver::impl {
NON_COPYABLE(EventHolder); NON_COPYABLE(EventHolder);
NON_MOVEABLE(EventHolder); NON_MOVEABLE(EventHolder);
private: private:
os::SystemEventType *event; os::SystemEventType *m_event;
public: public:
constexpr EventHolder() : event(nullptr) { /* ... */ } constexpr EventHolder() : m_event(nullptr) { /* ... */ }
void AttachEvent(os::SystemEventType *event) { void AttachEvent(os::SystemEventType *event) {
this->event = event; m_event = event;
} }
os::SystemEventType *DetachEvent() { os::SystemEventType *DetachEvent() {
auto ev = this->event; auto ev = m_event;
this->event = nullptr; m_event = nullptr;
return ev; return ev;
} }
os::SystemEventType *GetSystemEvent() { os::SystemEventType *GetSystemEvent() {
return this->event; return m_event;
} }
bool IsBound() const { 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); NON_MOVEABLE(PadSessionImpl);
AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::impl::PadSessionImpl, ::ams::ddsf::ISession); AMS_DDSF_CASTABLE_TRAITS(ams::gpio::driver::impl::PadSessionImpl, ::ams::ddsf::ISession);
private: private:
EventHolder event_holder; EventHolder m_event_holder;
private: private:
Result UpdateDriverInterruptEnabled(); Result UpdateDriverInterruptEnabled();
public: public:
PadSessionImpl() : event_holder() { /* ... */ } PadSessionImpl() : m_event_holder() { /* ... */ }
~PadSessionImpl() { ~PadSessionImpl() {
this->Close(); this->Close();
} }
bool IsInterruptBound() const { bool IsInterruptBound() const {
return this->event_holder.IsBound(); return m_event_holder.IsBound();
} }
Result Open(Pad *pad, ddsf::AccessMode access_mode); Result Open(Pad *pad, ddsf::AccessMode access_mode);

View file

@ -25,25 +25,25 @@ namespace ams::i2c::driver {
NON_MOVEABLE(I2cDeviceProperty); NON_MOVEABLE(I2cDeviceProperty);
AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::I2cDeviceProperty, ::ams::ddsf::IDevice); AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::I2cDeviceProperty, ::ams::ddsf::IDevice);
private: private:
u16 address; u16 m_address;
AddressingMode addressing_mode; AddressingMode m_addressing_mode;
util::IntrusiveListNode device_property_list_node; util::IntrusiveListNode m_device_property_list_node;
public: 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; 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: public:
I2cDeviceProperty() : IDevice(false), address(0), addressing_mode(AddressingMode_SevenBit), 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), address(addr), addressing_mode(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() { /* ... */ } virtual ~I2cDeviceProperty() { /* ... */ }
u16 GetAddress() const { u16 GetAddress() const {
return this->address; return m_address;
} }
AddressingMode GetAddressingMode() const { AddressingMode GetAddressingMode() const {
return this->addressing_mode; return m_addressing_mode;
} }
}; };

View file

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

View file

@ -28,20 +28,20 @@ namespace ams::i2c {
NON_COPYABLE(CommandListFormatter); NON_COPYABLE(CommandListFormatter);
NON_MOVEABLE(CommandListFormatter); NON_MOVEABLE(CommandListFormatter);
private: private:
size_t current_index; size_t m_current_index;
size_t command_list_length; size_t m_command_list_length;
void *command_list; void *m_command_list;
private: private:
Result IsEnqueueAble(size_t sz) const; Result IsEnqueueAble(size_t sz) const;
public: public:
CommandListFormatter(void *p, size_t sz) : current_index(0), command_list_length(sz), command_list(p) { CommandListFormatter(void *p, size_t sz) : m_current_index(0), m_command_list_length(sz), m_command_list(p) {
AMS_ABORT_UNLESS(this->command_list_length <= CommandListLengthMax); 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; } size_t GetCurrentLength() const { return m_current_index; }
const void *GetListHead() const { return this->command_list; } const void *GetListHead() const { return m_command_list; }
Result EnqueueReceiveCommand(i2c::TransactionOption option, size_t size); Result EnqueueReceiveCommand(i2c::TransactionOption option, size_t size);
Result EnqueueSendCommand(i2c::TransactionOption option, const void *src, 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. */ /* Functionality for parsing/generating a key value archive. */
class ArchiveReader { class ArchiveReader {
private: private:
AutoBuffer &buffer; AutoBuffer &m_buffer;
size_t offset; size_t m_offset;
public: public:
ArchiveReader(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } ArchiveReader(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ }
private: private:
Result Peek(void *dst, size_t size); Result Peek(void *dst, size_t size);
Result Read(void *dst, size_t size); Result Read(void *dst, size_t size);
@ -36,10 +36,10 @@ namespace ams::kvdb {
class ArchiveWriter { class ArchiveWriter {
private: private:
AutoBuffer &buffer; AutoBuffer &m_buffer;
size_t offset; size_t m_offset;
public: public:
ArchiveWriter(AutoBuffer &b) : buffer(b), offset(0) { /* ... */ } ArchiveWriter(AutoBuffer &b) : m_buffer(b), m_offset(0) { /* ... */ }
private: private:
Result Write(const void *src, size_t size); Result Write(const void *src, size_t size);
public: public:
@ -49,14 +49,14 @@ namespace ams::kvdb {
class ArchiveSizeHelper { class ArchiveSizeHelper {
private: private:
size_t size; size_t m_size;
public: public:
ArchiveSizeHelper(); ArchiveSizeHelper();
void AddEntry(size_t key_size, size_t value_size); void AddEntry(size_t key_size, size_t value_size);
size_t GetSize() const { size_t GetSize() const {
return this->size; return m_size;
} }
}; };

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,13 +23,13 @@ namespace ams::lr {
class RegisteredLocationResolver { class RegisteredLocationResolver {
NON_COPYABLE(RegisteredLocationResolver); NON_COPYABLE(RegisteredLocationResolver);
private: private:
sf::SharedPointer<IRegisteredLocationResolver> interface; sf::SharedPointer<IRegisteredLocationResolver> m_interface;
public: public:
RegisteredLocationResolver() { /* ... */ } RegisteredLocationResolver() { /* ... */ }
explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : interface(intf) { /* ... */ } explicit RegisteredLocationResolver(sf::SharedPointer<IRegisteredLocationResolver> intf) : m_interface(intf) { /* ... */ }
RegisteredLocationResolver(RegisteredLocationResolver &&rhs) { RegisteredLocationResolver(RegisteredLocationResolver &&rhs) {
this->interface = std::move(rhs.interface); m_interface = std::move(rhs.m_interface);
} }
RegisteredLocationResolver &operator=(RegisteredLocationResolver &&rhs) { RegisteredLocationResolver &operator=(RegisteredLocationResolver &&rhs) {
@ -38,74 +38,74 @@ namespace ams::lr {
} }
void Swap(RegisteredLocationResolver &rhs) { void Swap(RegisteredLocationResolver &rhs) {
std::swap(this->interface, rhs.interface); std::swap(m_interface, rhs.m_interface);
} }
public: public:
/* Actual commands. */ /* Actual commands. */
Result ResolveProgramPath(Path *out, ncm::ProgramId id) { Result ResolveProgramPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->ResolveProgramPath(out, id); return m_interface->ResolveProgramPath(out, id);
} }
Result RegisterProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_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) { 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 { } else {
return this->interface->RegisterProgramPathDeprecated(path, id); return m_interface->RegisterProgramPathDeprecated(path, id);
} }
} }
Result UnregisterProgramPath(ncm::ProgramId id) { Result UnregisterProgramPath(ncm::ProgramId id) {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->UnregisterProgramPath(id); return m_interface->UnregisterProgramPath(id);
} }
void RedirectProgramPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_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) { 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 { } else {
R_ABORT_UNLESS(this->interface->RedirectProgramPathDeprecated(path, id)); R_ABORT_UNLESS(m_interface->RedirectProgramPathDeprecated(path, id));
} }
} }
Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) { Result ResolveHtmlDocumentPath(Path *out, ncm::ProgramId id) {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->ResolveHtmlDocumentPath(out, id); return m_interface->ResolveHtmlDocumentPath(out, id);
} }
Result RegisterHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_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) { 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 { } else {
return this->interface->RegisterHtmlDocumentPathDeprecated(path, id); return m_interface->RegisterHtmlDocumentPathDeprecated(path, id);
} }
} }
Result UnregisterHtmlDocumentPath(ncm::ProgramId id) { Result UnregisterHtmlDocumentPath(ncm::ProgramId id) {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->UnregisterHtmlDocumentPath(id); return m_interface->UnregisterHtmlDocumentPath(id);
} }
void RedirectHtmlDocumentPath(const Path &path, ncm::ProgramId id, ncm::ProgramId owner_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) { 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 { } else {
R_ABORT_UNLESS(this->interface->RedirectHtmlDocumentPathDeprecated(path, id)); R_ABORT_UNLESS(m_interface->RedirectHtmlDocumentPathDeprecated(path, id));
} }
} }
Result Refresh() { Result Refresh() {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->Refresh(); return m_interface->Refresh();
} }
Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) { Result RefreshExcluding(const ncm::ProgramId *excluding_ids, size_t num_ids) {
AMS_ASSERT(this->interface); AMS_ASSERT(m_interface);
return this->interface->RefreshExcluding(sf::InArray<ncm::ProgramId>(excluding_ids, num_ids)); 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 { class CachedHeap final {
NON_COPYABLE(CachedHeap); NON_COPYABLE(CachedHeap);
private: private:
TlsHeapCache *tls_heap_cache; TlsHeapCache *m_tls_heap_cache;
public: public:
constexpr CachedHeap() : tls_heap_cache() { /* ... */ } constexpr CachedHeap() : m_tls_heap_cache() { /* ... */ }
~CachedHeap() { this->Finalize(); } ~CachedHeap() { this->Finalize(); }
ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : tls_heap_cache(rhs.tls_heap_cache) { ALWAYS_INLINE CachedHeap(CachedHeap &&rhs) : m_tls_heap_cache(rhs.m_tls_heap_cache) {
rhs.tls_heap_cache = nullptr; rhs.m_tls_heap_cache = nullptr;
} }
ALWAYS_INLINE CachedHeap &operator=(CachedHeap &&rhs) { ALWAYS_INLINE CachedHeap &operator=(CachedHeap &&rhs) {
this->Reset(); this->Reset();
this->tls_heap_cache = rhs.tls_heap_cache; m_tls_heap_cache = rhs.m_tls_heap_cache;
rhs.tls_heap_cache = nullptr; rhs.m_tls_heap_cache = nullptr;
return *this; return *this;
} }
@ -57,7 +57,7 @@ namespace ams::mem::impl::heap {
void Reset(TlsHeapCache *thc); void Reset(TlsHeapCache *thc);
TlsHeapCache *Release(); 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); static constexpr size_t MinimumAlignment = alignof(u64);
using DestructorHandler = void (*)(void *start, void *end); using DestructorHandler = void (*)(void *start, void *end);
private: private:
TlsHeapCentral *tls_heap_central; TlsHeapCentral *m_tls_heap_central;
bool use_virtual_memory; bool m_use_virtual_memory;
u32 option; u32 m_option;
u8 *start; u8 *m_start;
u8 *end; u8 *m_end;
public: 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(); } ~CentralHeap() { this->Finalize(); }
errno_t Initialize(void *start, size_t size, u32 option); errno_t Initialize(void *start, size_t size, u32 option);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -21,13 +21,13 @@ namespace ams::ncm {
class ContentStorage { class ContentStorage {
NON_COPYABLE(ContentStorage); NON_COPYABLE(ContentStorage);
private: private:
sf::SharedPointer<IContentStorage> interface; sf::SharedPointer<IContentStorage> m_interface;
public: public:
ContentStorage() { /* ... */ } ContentStorage() { /* ... */ }
explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : interface(intf) { /* ... */ } explicit ContentStorage(sf::SharedPointer<IContentStorage> intf) : m_interface(intf) { /* ... */ }
ContentStorage(ContentStorage &&rhs) { ContentStorage(ContentStorage &&rhs) {
this->interface = std::move(rhs.interface); m_interface = std::move(rhs.m_interface);
} }
ContentStorage &operator=(ContentStorage &&rhs) { ContentStorage &operator=(ContentStorage &&rhs) {
@ -36,166 +36,166 @@ namespace ams::ncm {
} }
void swap(ContentStorage &rhs) { void swap(ContentStorage &rhs) {
std::swap(this->interface, rhs.interface); std::swap(m_interface, rhs.m_interface);
} }
public: public:
PlaceHolderId GeneratePlaceHolderId() { PlaceHolderId GeneratePlaceHolderId() {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
PlaceHolderId id; PlaceHolderId id;
R_ABORT_UNLESS(this->interface->GeneratePlaceHolderId(std::addressof(id))); R_ABORT_UNLESS(m_interface->GeneratePlaceHolderId(std::addressof(id)));
return id; return id;
} }
Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) { Result CreatePlaceHolder(PlaceHolderId placeholder_id, ContentId content_id, s64 size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->CreatePlaceHolder(placeholder_id, content_id, size); return m_interface->CreatePlaceHolder(placeholder_id, content_id, size);
} }
Result DeletePlaceHolder(PlaceHolderId placeholder_id) { Result DeletePlaceHolder(PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->DeletePlaceHolder(placeholder_id); return m_interface->DeletePlaceHolder(placeholder_id);
} }
Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) { Result HasPlaceHolder(bool *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->HasPlaceHolder(out, placeholder_id); return m_interface->HasPlaceHolder(out, placeholder_id);
} }
Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) { Result WritePlaceHolder(PlaceHolderId placeholder_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size)); return m_interface->WritePlaceHolder(placeholder_id, offset, sf::InBuffer(buf, size));
} }
Result Register(PlaceHolderId placeholder_id, ContentId content_id) { Result Register(PlaceHolderId placeholder_id, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->Register(placeholder_id, content_id); return m_interface->Register(placeholder_id, content_id);
} }
Result Delete(ContentId content_id) { Result Delete(ContentId content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->Delete(content_id); return m_interface->Delete(content_id);
} }
Result Has(bool *out, ContentId content_id) { Result Has(bool *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->Has(out, content_id); return m_interface->Has(out, content_id);
} }
void GetPath(Path *out, ContentId content_id) { void GetPath(Path *out, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPath(out, content_id)); R_ABORT_UNLESS(m_interface->GetPath(out, content_id));
} }
void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) { void GetPlaceHolderPath(Path *out, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
R_ABORT_UNLESS(this->interface->GetPlaceHolderPath(out, placeholder_id)); R_ABORT_UNLESS(m_interface->GetPlaceHolderPath(out, placeholder_id));
} }
Result CleanupAllPlaceHolder() { Result CleanupAllPlaceHolder() {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->CleanupAllPlaceHolder(); return m_interface->CleanupAllPlaceHolder();
} }
Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) { Result ListPlaceHolder(s32 *out_count, PlaceHolderId *out_list, size_t out_list_size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size)); return m_interface->ListPlaceHolder(out_count, sf::OutArray<PlaceHolderId>(out_list, out_list_size));
} }
Result GetContentCount(s32 *out_count) { Result GetContentCount(s32 *out_count) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetContentCount(out_count); return m_interface->GetContentCount(out_count);
} }
Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) { Result ListContentId(s32 *out_count, ContentId *out_list, size_t out_list_size, s32 offset) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset); return m_interface->ListContentId(out_count, sf::OutArray<ContentId>(out_list, out_list_size), offset);
} }
Result GetSize(s64 *out_size, ContentId content_id) { Result GetSize(s64 *out_size, ContentId content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetSizeFromContentId(out_size, content_id); return m_interface->GetSizeFromContentId(out_size, content_id);
} }
Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) { Result GetSize(s64 *out_size, PlaceHolderId placeholder_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetSizeFromPlaceHolderId(out_size, placeholder_id); return m_interface->GetSizeFromPlaceHolderId(out_size, placeholder_id);
} }
Result DisableForcibly() { Result DisableForcibly() {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->DisableForcibly(); return m_interface->DisableForcibly();
} }
Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) { Result RevertToPlaceHolder(PlaceHolderId placeholder_id, ContentId old_content_id, ContentId new_content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id); return m_interface->RevertToPlaceHolder(placeholder_id, old_content_id, new_content_id);
} }
Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) { Result SetPlaceHolderSize(PlaceHolderId placeholder_id, s64 size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->SetPlaceHolderSize(placeholder_id, size); return m_interface->SetPlaceHolderSize(placeholder_id, size);
} }
Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) { Result ReadContentIdFile(void *dst, size_t size, ContentId content_id, s64 offset) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset); return m_interface->ReadContentIdFile(sf::OutBuffer(dst, size), content_id, offset);
} }
Result GetRightsId(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id) { 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(); const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) { 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 { } else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {}; *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) { 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(); const auto vers = hos::GetVersion();
if (vers >= hos::Version_3_0_0) { 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 { } else {
AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0); AMS_ABORT_UNLESS(vers >= hos::Version_2_0_0);
*out_rights_id = {}; *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) { Result WriteContentForDebug(ContentId content_id, s64 offset, const void *buf, size_t size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size)); return m_interface->WriteContentForDebug(content_id, offset, sf::InBuffer(buf, size));
} }
Result GetFreeSpaceSize(s64 *out_size) { Result GetFreeSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetFreeSpaceSize(out_size); return m_interface->GetFreeSpaceSize(out_size);
} }
Result GetTotalSpaceSize(s64 *out_size) { Result GetTotalSpaceSize(s64 *out_size) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetTotalSpaceSize(out_size); return m_interface->GetTotalSpaceSize(out_size);
} }
Result FlushPlaceHolder() { Result FlushPlaceHolder() {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->FlushPlaceHolder(); return m_interface->FlushPlaceHolder();
} }
Result RepairInvalidFileAttribute() { Result RepairInvalidFileAttribute() {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->RepairInvalidFileAttribute(); return m_interface->RepairInvalidFileAttribute();
} }
Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) { Result GetRightsIdFromPlaceHolderIdWithCache(ncm::RightsId *out_rights_id, PlaceHolderId placeholder_id, ContentId cache_content_id) {
AMS_ASSERT(this->interface != nullptr); AMS_ASSERT(m_interface != nullptr);
return this->interface->GetRightsIdFromPlaceHolderIdWithCache(out_rights_id, placeholder_id, cache_content_id); 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_COPYABLE(InstallTaskBase);
NON_MOVEABLE(InstallTaskBase); NON_MOVEABLE(InstallTaskBase);
private: private:
crypto::Sha256Generator sha256_generator; crypto::Sha256Generator m_sha256_generator;
StorageId install_storage; StorageId m_install_storage;
InstallTaskDataBase *data; InstallTaskDataBase *m_data;
InstallProgress progress; InstallProgress m_progress;
os::SdkMutex progress_mutex; os::SdkMutex m_progress_mutex;
u32 config; u32 m_config;
os::SdkMutex cancel_mutex; os::SdkMutex m_cancel_mutex;
bool cancel_requested; bool m_cancel_requested;
InstallThroughput throughput; InstallThroughput m_throughput;
TimeSpan throughput_start_time; TimeSpan m_throughput_start_time;
os::SdkMutex throughput_mutex; os::SdkMutex m_throughput_mutex;
FirmwareVariationId firmware_variation_id; FirmwareVariationId m_firmware_variation_id;
private: private:
ALWAYS_INLINE Result SetLastResultOnFailure(Result result) { ALWAYS_INLINE Result SetLastResultOnFailure(Result result) {
if (R_FAILED(result)) { if (R_FAILED(result)) {
@ -102,7 +102,7 @@ namespace ams::ncm {
return result; return result;
} }
public: 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() { /* ... */ }; virtual ~InstallTaskBase() { /* ... */ };
public: public:
virtual void Cancel(); virtual void Cancel();
@ -144,10 +144,10 @@ namespace ams::ncm {
virtual Result PrepareDependency(); virtual Result PrepareDependency();
Result PrepareSystemUpdateDependency(); Result PrepareSystemUpdateDependency();
virtual Result PrepareContentMetaIfLatest(const ContentMetaKey &key); /* NOTE: This is not virtual in Nintendo's code. We do so to facilitate downgrades. */ 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); 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(); } virtual Result OnPrepareComplete() { return ResultSuccess(); }
@ -196,7 +196,7 @@ namespace ams::ncm {
public: public:
virtual Result CheckInstallable() { return ResultSuccess(); } 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); 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>{}; struct DataHolder : public InstallContentMeta, public util::IntrusiveListBaseNode<DataHolder>{};
using DataList = util::IntrusiveListBaseTraits<DataHolder>::ListType; using DataList = util::IntrusiveListBaseTraits<DataHolder>::ListType;
private: private:
DataList data_list; DataList m_data_list;
InstallProgressState state; InstallProgressState m_state;
Result last_result; Result m_last_result;
SystemUpdateTaskApplyInfo system_update_task_apply_info; SystemUpdateTaskApplyInfo m_system_update_task_apply_info;
public: public:
MemoryInstallTaskData() : state(InstallProgressState::NotPrepared), last_result(ResultSuccess()) { /* ... */ }; MemoryInstallTaskData() : m_state(InstallProgressState::NotPrepared), m_last_result(ResultSuccess()) { /* ... */ };
~MemoryInstallTaskData() { ~MemoryInstallTaskData() {
this->Cleanup(); this->Cleanup();
} }
@ -104,8 +104,8 @@ namespace ams::ncm {
static_assert(sizeof(EntryInfo) == 0x10); static_assert(sizeof(EntryInfo) == 0x10);
private: private:
Header header; Header m_header;
char path[64]; char m_path[64];
private: private:
static constexpr Header MakeInitialHeader(s32 max_entries) { static constexpr Header MakeInitialHeader(s32 max_entries) {
return { return {

View file

@ -40,13 +40,13 @@ namespace ams::ncm {
class HeapState { class HeapState {
private: private:
os::SdkMutex mutex; os::SdkMutex m_mutex;
lmem::HeapHandle heap_handle; lmem::HeapHandle m_heap_handle;
size_t total_alloc_size; size_t m_total_alloc_size;
size_t peak_total_alloc_size; size_t m_peak_total_alloc_size;
size_t peak_alloc_size; size_t m_peak_alloc_size;
public: 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 Initialize(lmem::HeapHandle heap_handle);
void Allocate(size_t size); void Allocate(size_t size);

View file

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

View file

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

View file

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

View file

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

View file

@ -33,28 +33,28 @@ namespace ams::ncm {
u64 last_accessed; u64 last_accessed;
}; };
private: private:
Entry entries[MaxEntries]; Entry m_entries[MaxEntries];
u64 counter; u64 m_counter;
os::SdkMutex mutex; os::SdkMutex m_mutex;
public: public:
RightsIdCache() : mutex() { RightsIdCache() : m_mutex() {
this->Invalidate(); this->Invalidate();
} }
void Invalidate() { void Invalidate() {
this->counter = 2; m_counter = 2;
for (size_t i = 0; i < MaxEntries; i++) { 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) { void Store(ContentId content_id, ncm::RightsId rights_id) {
std::scoped_lock lk(this->mutex); std::scoped_lock lk(m_mutex);
Entry *eviction_candidate = std::addressof(this->entries[0]); Entry *eviction_candidate = std::addressof(m_entries[0]);
/* Find a suitable existing entry to store our new one at. */ /* Find a suitable existing entry to store our new one at. */
for (size_t i = 1; i < MaxEntries; i++) { 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 */ /* 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)) { 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. */ /* Update the cache. */
eviction_candidate->uuid = content_id.uuid; eviction_candidate->uuid = content_id.uuid;
eviction_candidate->rights_id = rights_id; 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) { 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. */ /* Attempt to locate the content id in the cache. */
for (size_t i = 0; i < MaxEntries; i++) { 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) { if (entry->last_accessed != 1 && content_id == entry->uuid) {
entry->last_accessed = this->counter; entry->last_accessed = m_counter;
this->counter++; m_counter++;
*out_rights_id = entry->rights_id; *out_rights_id = entry->rights_id;
return true; return true;
} }

View file

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

View file

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

View file

@ -28,28 +28,28 @@ namespace ams::os::impl {
class InternalConditionVariable { class InternalConditionVariable {
private: private:
InternalConditionVariableImpl impl; InternalConditionVariableImpl m_impl;
public: public:
constexpr InternalConditionVariable() : impl() { /* ... */ } constexpr InternalConditionVariable() : m_impl() { /* ... */ }
constexpr void Initialize() { constexpr void Initialize() {
this->impl.Initialize(); m_impl.Initialize();
} }
void Signal() { void Signal() {
this->impl.Signal(); m_impl.Signal();
} }
void Broadcast() { void Broadcast() {
this->impl.Broadcast(); m_impl.Broadcast();
} }
void Wait(InternalCriticalSection *cs) { void Wait(InternalCriticalSection *cs) {
this->impl.Wait(cs); m_impl.Wait(cs);
} }
ConditionVariableStatus TimedWait(InternalCriticalSection *cs, const TimeoutHelper &timeout_helper) { 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 { class InternalConditionVariableImpl {
private: private:
u32 value; u32 m_value;
public: public:
constexpr InternalConditionVariableImpl() : value(0) { /* ... */ } constexpr InternalConditionVariableImpl() : m_value(0) { /* ... */ }
constexpr void Initialize() { constexpr void Initialize() {
this->value = 0; m_value = 0;
} }
void Signal(); void Signal();

View file

@ -27,18 +27,18 @@ namespace ams::os::impl {
class InternalCriticalSection { class InternalCriticalSection {
private: private:
InternalCriticalSectionImpl impl; InternalCriticalSectionImpl m_impl;
public: public:
constexpr InternalCriticalSection() : impl() { /* ... */ } constexpr InternalCriticalSection() : m_impl() { /* ... */ }
constexpr void Initialize() { this->impl.Initialize(); } constexpr void Initialize() { m_impl.Initialize(); }
constexpr void Finalize() { this->impl.Finalize(); } constexpr void Finalize() { m_impl.Finalize(); }
void Enter() { return this->impl.Enter(); } void Enter() { return m_impl.Enter(); }
bool TryEnter() { return this->impl.TryEnter(); } bool TryEnter() { return m_impl.TryEnter(); }
void Leave() { return this->impl.Leave(); } 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 void Lock() { return this->Enter(); }
ALWAYS_INLINE bool TryLock() { return this->TryEnter(); } ALWAYS_INLINE bool TryLock() { return this->TryEnter(); }
@ -49,11 +49,11 @@ namespace ams::os::impl {
ALWAYS_INLINE void unlock() { return this->Unlock(); } ALWAYS_INLINE void unlock() { return this->Unlock(); }
InternalCriticalSectionImpl *Get() { InternalCriticalSectionImpl *Get() {
return std::addressof(this->impl); return std::addressof(m_impl);
} }
const InternalCriticalSectionImpl *Get() const { 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; friend class InternalConditionVariableImpl;
private: private:
u32 thread_handle; u32 m_thread_handle;
public: 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() { /* ... */ } constexpr void Finalize() { /* ... */ }
void Enter(); void Enter();

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