diff --git a/libraries/libstratosphere/include/stratosphere/fssystem.hpp b/libraries/libstratosphere/include/stratosphere/fssystem.hpp
index 101667352..d870584fa 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem.hpp
@@ -13,10 +13,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
-
#pragma once
#include
#include
+#include
#include
#include
#include
@@ -46,8 +46,8 @@
#include
#include
#include
-#include
-#include
+#include
+#include
#include
#include
#include
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/dbm/fssystem_dbm_utils.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/dbm/fssystem_dbm_utils.hpp
deleted file mode 100644
index fe7bfe879..000000000
--- a/libraries/libstratosphere/include/stratosphere/fssystem/dbm/fssystem_dbm_utils.hpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) Atmosphère-NX
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-#pragma once
-#include
-
-namespace ams::fssystem::dbm {
-
- namespace {
-
- constexpr inline s32 CountLeadingZeros(u32 val) {
- return util::CountLeadingZeros(val);
- }
-
- constexpr inline s32 CountLeadingOnes(u32 val) {
- return CountLeadingZeros(~val);
- }
-
- inline u32 ReadU32(const u8 *buf, size_t index) {
- u32 val;
- std::memcpy(std::addressof(val), buf + index, sizeof(u32));
- return val;
- }
-
- inline void WriteU32(u8 *buf, size_t index, u32 val) {
- std::memcpy(buf + index, std::addressof(val), sizeof(u32));
- }
-
- }
-
-}
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_save_types.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bitmap_utils.hpp
similarity index 56%
rename from libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_save_types.hpp
rename to libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bitmap_utils.hpp
index 352255213..23ca55902 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_save_types.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_bitmap_utils.hpp
@@ -15,12 +15,26 @@
*/
#pragma once
#include
-#include
-#include
-#include
-#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
+
+ constexpr inline s32 CountLeadingZeros(u32 val) {
+ return util::CountLeadingZeros(val);
+ }
+
+ constexpr inline s32 CountLeadingOnes(u32 val) {
+ return CountLeadingZeros(~val);
+ }
+
+ inline u32 ReadU32(const u8 *buf, size_t index) {
+ u32 val;
+ std::memcpy(std::addressof(val), buf + index, sizeof(u32));
+ return val;
+ }
+
+ inline void WriteU32(u8 *buf, size_t index, u32 val) {
+ std::memcpy(buf + index, std::addressof(val), sizeof(u32));
+ }
constexpr inline bool IsPowerOfTwo(s32 val) {
return util::IsPowerOfTwo(val);
@@ -28,14 +42,15 @@ namespace ams::fssystem::save {
constexpr inline u32 ILog2(u32 val) {
AMS_ASSERT(val > 0);
- return (BITSIZEOF(u32) - 1 - dbm::CountLeadingZeros(val));
+ return (BITSIZEOF(u32) - 1 - util::CountLeadingZeros(val));
}
- constexpr inline u32 CeilPowerOfTwo(u32 val) {
+ constexpr inline u32 CeilingPowerOfTwo(u32 val) {
if (val == 0) {
return 1;
}
- return ((1u << (BITSIZEOF(u32) - 1)) >> (dbm::CountLeadingZeros(val - 1) - 1));
+
+ return util::CeilingPowerOfTwo(val);
}
}
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp
similarity index 98%
rename from libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp
rename to libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp
index fb875c2d1..2bdd81585 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_block_cache_buffered_storage.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_block_cache_buffered_storage.hpp
@@ -19,11 +19,10 @@
#include
#include
#include
-#include
#include
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
constexpr inline size_t IntegrityMinLayerCount = 2;
constexpr inline size_t IntegrityMaxLayerCount = 7;
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_buffered_storage.hpp
similarity index 98%
rename from libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp
rename to libraries/libstratosphere/include/stratosphere/fssystem/fssystem_buffered_storage.hpp
index 9fdaec99f..4288f9d62 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_buffered_storage.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_buffered_storage.hpp
@@ -20,7 +20,7 @@
#include
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
class BufferedStorage : public ::ams::fs::IStorage {
NON_COPYABLE(BufferedStorage);
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp
similarity index 97%
rename from libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp
rename to libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp
index 1ba245e06..ea45400cd 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_hierarchical_integrity_verification_storage.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_hierarchical_integrity_verification_storage.hpp
@@ -19,11 +19,10 @@
#include
#include
#include
-#include
-#include
-#include
+#include
+#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
struct HierarchicalIntegrityVerificationLevelInformation {
fs::Int64 offset;
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp
index cc888a49c..15d1e5f71 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_romfs_storage.hpp
@@ -19,7 +19,7 @@
#include
#include
#include
-#include
+#include
namespace ams::fssystem {
@@ -28,8 +28,8 @@ namespace ams::fssystem {
class IntegrityRomFsStorage : public ::ams::fs::IStorage, public ::ams::fs::impl::Newable {
private:
- save::HierarchicalIntegrityVerificationStorage m_integrity_storage;
- save::FileSystemBufferManagerSet m_buffers;
+ HierarchicalIntegrityVerificationStorage m_integrity_storage;
+ FileSystemBufferManagerSet m_buffers;
os::SdkRecursiveMutex m_mutex;
Hash m_master_hash;
std::unique_ptr m_master_hash_storage;
@@ -37,7 +37,7 @@ namespace ams::fssystem {
IntegrityRomFsStorage() : m_mutex() { /* ... */ }
virtual ~IntegrityRomFsStorage() override { this->Finalize(); }
- Result Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
+ Result Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf);
void Finalize();
virtual Result Read(s64 offset, void *buffer, size_t size) override {
@@ -66,7 +66,7 @@ namespace ams::fssystem {
return m_integrity_storage.Commit();
}
- save::FileSystemBufferManagerSet *GetBuffers() {
+ FileSystemBufferManagerSet *GetBuffers() {
return m_integrity_storage.GetBuffers();
}
};
diff --git a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp
similarity index 93%
rename from libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp
rename to libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp
index b162af5e5..5e0aa3254 100644
--- a/libraries/libstratosphere/include/stratosphere/fssystem/save/fssystem_integrity_verification_storage.hpp
+++ b/libraries/libstratosphere/include/stratosphere/fssystem/fssystem_integrity_verification_storage.hpp
@@ -19,12 +19,9 @@
#include
#include
#include
-#include
-#include
-#include
-#include
+#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
class IntegrityVerificationStorage : public ::ams::fs::IStorage {
NON_COPYABLE(IntegrityVerificationStorage);
diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp
similarity index 99%
rename from libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp
rename to libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp
index bb79b54da..f2d6d2b9e 100644
--- a/libraries/libstratosphere/source/fssystem/save/fssystem_block_cache_buffered_storage.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_block_cache_buffered_storage.cpp
@@ -15,7 +15,7 @@
*/
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
BlockCacheBufferedStorage::BlockCacheBufferedStorage() : m_mutex(), m_data_storage(), m_last_result(ResultSuccess()), m_data_size(), m_verification_block_size(), m_verification_block_shift(), m_flags(), m_buffer_level(-1), m_block_cache_manager()
{
diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp
similarity index 99%
rename from libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp
rename to libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp
index 57f5153d2..96433aaea 100644
--- a/libraries/libstratosphere/source/fssystem/save/fssystem_buffered_storage.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_buffered_storage.cpp
@@ -15,7 +15,7 @@
*/
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
namespace {
diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp
similarity index 99%
rename from libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp
rename to libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp
index 80f46c398..02ebe77c5 100644
--- a/libraries/libstratosphere/source/fssystem/save/fssystem_hierarchical_integrity_verification_storage.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_hierarchical_integrity_verification_storage.cpp
@@ -15,7 +15,7 @@
*/
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
namespace {
diff --git a/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp
index 4354bf149..63580fb4e 100644
--- a/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_integrity_romfs_storage.cpp
@@ -17,7 +17,7 @@
namespace ams::fssystem {
- Result IntegrityRomFsStorage::Initialize(save::HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, save::HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf) {
+ Result IntegrityRomFsStorage::Initialize(HierarchicalIntegrityVerificationInformation level_hash_info, Hash master_hash, HierarchicalIntegrityVerificationStorage::HierarchicalStorageInformation storage_info, fs::IBufferManager *bm, IHash256GeneratorFactory *hgf) {
/* Validate preconditions. */
AMS_ASSERT(bm != nullptr);
diff --git a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp b/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp
similarity index 99%
rename from libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp
rename to libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp
index 6910ecff8..7618bae7a 100644
--- a/libraries/libstratosphere/source/fssystem/save/fssystem_integrity_verification_storage.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_integrity_verification_storage.cpp
@@ -15,7 +15,7 @@
*/
#include
-namespace ams::fssystem::save {
+namespace ams::fssystem {
Result IntegrityVerificationStorage::Initialize(fs::SubStorage hs, fs::SubStorage ds, s64 verif_block_size, s64 upper_layer_verif_block_size, fs::IBufferManager *bm, fssystem::IHash256GeneratorFactory *hgf, const fs::HashSalt &salt, bool is_real_data, fs::StorageType storage_type) {
/* Validate preconditions. */
diff --git a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp
index 36305c894..d1f9c460f 100644
--- a/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp
+++ b/libraries/libstratosphere/source/fssystem/fssystem_nca_file_system_driver.cpp
@@ -549,7 +549,7 @@ namespace ams::fssystem {
R_TRY(base_storage->GetSize(std::addressof(base_size)));
/* Create buffered storage. */
- auto buffered_storage = fssystem::AllocateShared();
+ auto buffered_storage = fssystem::AllocateShared();
R_UNLESS(buffered_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
/* Initialize the buffered storage. */
@@ -655,7 +655,7 @@ namespace ams::fssystem {
R_TRY(this->CreateAesCtrStorage(std::addressof(decrypted_storage), std::move(enc_storage), offset + meta_offset, sparse_info.MakeAesCtrUpperIv(upper_iv), AlignmentStorageRequirement_None));
/* Create meta storage. */
- auto meta_storage = fssystem::AllocateShared();
+ auto meta_storage = fssystem::AllocateShared();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
/* Initialize the meta storage. */
@@ -789,7 +789,7 @@ namespace ams::fssystem {
R_TRY(this->CreateAesCtrStorage(std::addressof(decrypted_storage), std::move(enc_storage), offset + meta_offset, upper_iv, AlignmentStorageRequirement_None));
/* Create meta storage. */
- auto meta_storage = fssystem::AllocateShared();
+ auto meta_storage = fssystem::AllocateShared();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
/* Initialize the meta storage. */
@@ -921,7 +921,7 @@ namespace ams::fssystem {
R_UNLESS(patch_info.indirect_offset + patch_info.indirect_size <= base_size, fs::ResultNcaBaseStorageOutOfRangeE());
/* Allocate the meta storage. */
- auto meta_storage = fssystem::AllocateShared();
+ auto meta_storage = fssystem::AllocateShared();
R_UNLESS(meta_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
/* Initialize the meta storage. */
@@ -954,7 +954,7 @@ namespace ams::fssystem {
AMS_ASSERT(util::IsAligned(indirect_data_size, NcaHeader::XtsBlockSize));
/* Create the indirect data storage. */
- auto indirect_data_storage = fssystem::AllocateShared();
+ auto indirect_data_storage = fssystem::AllocateShared();
R_UNLESS(indirect_data_storage != nullptr, fs::ResultAllocationFailureInAllocateShared());
/* Initialize the indirect data storage. */
@@ -1061,15 +1061,15 @@ namespace ams::fssystem {
AMS_ASSERT(base_storage != nullptr);
/* Define storage types. */
- using VerificationStorage = save::HierarchicalIntegrityVerificationStorage;
+ using VerificationStorage = HierarchicalIntegrityVerificationStorage;
using StorageInfo = VerificationStorage::HierarchicalStorageInformation;
/* Validate the meta info. */
- save::HierarchicalIntegrityVerificationInformation level_hash_info;
+ HierarchicalIntegrityVerificationInformation level_hash_info;
std::memcpy(std::addressof(level_hash_info), std::addressof(meta_info.level_hash_info), sizeof(level_hash_info));
- R_UNLESS(save::IntegrityMinLayerCount <= level_hash_info.max_layers, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
- R_UNLESS(level_hash_info.max_layers <= save::IntegrityMaxLayerCount, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
+ R_UNLESS(IntegrityMinLayerCount <= level_hash_info.max_layers, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
+ R_UNLESS(level_hash_info.max_layers <= IntegrityMaxLayerCount, fs::ResultInvalidHierarchicalIntegrityVerificationLayerCount());
/* Get the base storage size. */
s64 base_storage_size;