a way around for 'Safe' and 'Prodinfof' partition checks
This commit is contained in:
@@ -10,17 +10,23 @@
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
constexpr u64 NAND_USER_SIZE = 0x680000000; // 26624 MiB
|
||||
constexpr u64 NAND_SYSTEM_SIZE = 0xA0000000; // 2560 MiB
|
||||
constexpr u64 NAND_TOTAL_SIZE = 0x747C00000; // 29820 MiB
|
||||
constexpr u64 NAND_USER_SIZE = 0x680000000; // 26624 MiB
|
||||
constexpr u64 NAND_SYSTEM_SIZE = 0xA0000000; // 2560 MiB
|
||||
constexpr u64 NAND_PRODINFOF_SIZE = 0x00400000; // 4 MiB
|
||||
constexpr u64 NAND_SAFE_SIZE = 0x04000000; // 64 MiB
|
||||
constexpr u64 NAND_TOTAL_SIZE = 0x747C00000; // 29820 MiB
|
||||
|
||||
BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir dump_root_)
|
||||
: nand_root(std::move(nand_root_)), load_root(std::move(load_root_)),
|
||||
dump_root(std::move(dump_root_)),
|
||||
safnand_cache(std::make_unique<RegisteredCache>(
|
||||
GetOrCreateDirectoryRelative(nand_root, "/safe/Contents/registered"))),
|
||||
sysnand_cache(std::make_unique<RegisteredCache>(
|
||||
GetOrCreateDirectoryRelative(nand_root, "/system/Contents/registered"))),
|
||||
usrnand_cache(std::make_unique<RegisteredCache>(
|
||||
GetOrCreateDirectoryRelative(nand_root, "/user/Contents/registered"))),
|
||||
safnand_placeholder(std::make_unique<PlaceholderCache>(
|
||||
GetOrCreateDirectoryRelative(nand_root, "/safe/Contents/placehld"))),
|
||||
sysnand_placeholder(std::make_unique<PlaceholderCache>(
|
||||
GetOrCreateDirectoryRelative(nand_root, "/system/Contents/placehld"))),
|
||||
usrnand_placeholder(std::make_unique<PlaceholderCache>(
|
||||
@@ -28,6 +34,10 @@ BISFactory::BISFactory(VirtualDir nand_root_, VirtualDir load_root_, VirtualDir
|
||||
|
||||
BISFactory::~BISFactory() = default;
|
||||
|
||||
VirtualDir BISFactory::GetSafeNANDContentDirectory() const {
|
||||
return GetOrCreateDirectoryRelative(nand_root, "/safe/Contents");
|
||||
}
|
||||
|
||||
VirtualDir BISFactory::GetSystemNANDContentDirectory() const {
|
||||
return GetOrCreateDirectoryRelative(nand_root, "/system/Contents");
|
||||
}
|
||||
@@ -36,6 +46,10 @@ VirtualDir BISFactory::GetUserNANDContentDirectory() const {
|
||||
return GetOrCreateDirectoryRelative(nand_root, "/user/Contents");
|
||||
}
|
||||
|
||||
RegisteredCache* BISFactory::GetSafeNANDContents() const {
|
||||
return safnand_cache.get();
|
||||
}
|
||||
|
||||
RegisteredCache* BISFactory::GetSystemNANDContents() const {
|
||||
return sysnand_cache.get();
|
||||
}
|
||||
@@ -44,6 +58,10 @@ RegisteredCache* BISFactory::GetUserNANDContents() const {
|
||||
return usrnand_cache.get();
|
||||
}
|
||||
|
||||
PlaceholderCache* BISFactory::GetSafeNANDPlaceholder() const {
|
||||
return safnand_placeholder.get();
|
||||
}
|
||||
|
||||
PlaceholderCache* BISFactory::GetSystemNANDPlaceholder() const {
|
||||
return sysnand_placeholder.get();
|
||||
}
|
||||
@@ -110,6 +128,32 @@ VirtualDir BISFactory::GetImageDirectory() const {
|
||||
return GetOrCreateDirectoryRelative(nand_root, "/user/Album");
|
||||
}
|
||||
|
||||
u64 BISFactory::GetProdinfofNANDFreeSpace() const {
|
||||
const auto prodinfof_dir = GetOrCreateDirectoryRelative(nand_root, "/prodinfof");
|
||||
if (prodinfof_dir == nullptr) {
|
||||
return GetProdinfofNANDTotalSpace();
|
||||
}
|
||||
|
||||
return GetProdinfofNANDTotalSpace() - prodinfof_dir->GetSize();
|
||||
}
|
||||
|
||||
u64 BISFactory::GetProdinfofNANDTotalSpace() const {
|
||||
return NAND_PRODINFOF_SIZE;
|
||||
}
|
||||
|
||||
u64 BISFactory::GetSafeNANDFreeSpace() const {
|
||||
const auto safe_dir = GetOrCreateDirectoryRelative(nand_root, "/safe");
|
||||
if (safe_dir == nullptr) {
|
||||
return GetSafeNANDTotalSpace();
|
||||
}
|
||||
|
||||
return GetSafeNANDTotalSpace() - safe_dir->GetSize();
|
||||
}
|
||||
|
||||
u64 BISFactory::GetSafeNANDTotalSpace() const {
|
||||
return NAND_SAFE_SIZE;
|
||||
}
|
||||
|
||||
u64 BISFactory::GetSystemNANDFreeSpace() const {
|
||||
const auto sys_dir = GetOrCreateDirectoryRelative(nand_root, "/system");
|
||||
if (sys_dir == nullptr) {
|
||||
|
||||
@@ -38,12 +38,15 @@ public:
|
||||
explicit BISFactory(VirtualDir nand_root, VirtualDir load_root, VirtualDir dump_root);
|
||||
~BISFactory();
|
||||
|
||||
VirtualDir GetSafeNANDContentDirectory() const;
|
||||
VirtualDir GetSystemNANDContentDirectory() const;
|
||||
VirtualDir GetUserNANDContentDirectory() const;
|
||||
|
||||
RegisteredCache* GetSafeNANDContents() const;
|
||||
RegisteredCache* GetSystemNANDContents() const;
|
||||
RegisteredCache* GetUserNANDContents() const;
|
||||
|
||||
PlaceholderCache* GetSafeNANDPlaceholder() const;
|
||||
PlaceholderCache* GetSystemNANDPlaceholder() const;
|
||||
PlaceholderCache* GetUserNANDPlaceholder() const;
|
||||
|
||||
@@ -55,6 +58,10 @@ public:
|
||||
|
||||
VirtualDir GetImageDirectory() const;
|
||||
|
||||
u64 GetProdinfofNANDFreeSpace() const;
|
||||
u64 GetProdinfofNANDTotalSpace() const;
|
||||
u64 GetSafeNANDFreeSpace() const;
|
||||
u64 GetSafeNANDTotalSpace() const;
|
||||
u64 GetSystemNANDFreeSpace() const;
|
||||
u64 GetSystemNANDTotalSpace() const;
|
||||
u64 GetUserNANDFreeSpace() const;
|
||||
@@ -68,9 +75,11 @@ private:
|
||||
VirtualDir load_root;
|
||||
VirtualDir dump_root;
|
||||
|
||||
std::unique_ptr<RegisteredCache> safnand_cache;
|
||||
std::unique_ptr<RegisteredCache> sysnand_cache;
|
||||
std::unique_ptr<RegisteredCache> usrnand_cache;
|
||||
|
||||
std::unique_ptr<PlaceholderCache> safnand_placeholder;
|
||||
std::unique_ptr<PlaceholderCache> sysnand_placeholder;
|
||||
std::unique_ptr<PlaceholderCache> usrnand_placeholder;
|
||||
};
|
||||
|
||||
@@ -28,9 +28,11 @@ enum class StorageId : u8 {
|
||||
None = 0,
|
||||
Host = 1,
|
||||
GameCard = 2,
|
||||
NandSystem = 3,
|
||||
NandUser = 4,
|
||||
SdCard = 5,
|
||||
NandProdinfof = 3,
|
||||
NandSafe = 4,
|
||||
NandSystem = 5,
|
||||
NandUser = 6,
|
||||
SdCard = 7,
|
||||
};
|
||||
|
||||
/// File system interface to the RomFS archive
|
||||
|
||||
@@ -122,6 +122,8 @@ VirtualDir SaveDataFactory::GetSaveDataSpaceDirectory(SaveDataSpaceId space) con
|
||||
|
||||
std::string SaveDataFactory::GetSaveDataSpaceIdPath(SaveDataSpaceId space) {
|
||||
switch (space) {
|
||||
case SaveDataSpaceId::SafeMode:
|
||||
return "/safe/";
|
||||
case SaveDataSpaceId::NandSystem:
|
||||
return "/system/";
|
||||
case SaveDataSpaceId::NandUser:
|
||||
|
||||
@@ -449,6 +449,14 @@ u64 FileSystemController::GetFreeSpaceSize(FileSys::StorageId id) const {
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetSystemNANDFreeSpace() + bis_factory->GetUserNANDFreeSpace();
|
||||
case FileSys::StorageId::NandProdinfof:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetProdinfofNANDFreeSpace();
|
||||
case FileSys::StorageId::NandSafe:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetSafeNANDFreeSpace();
|
||||
case FileSys::StorageId::NandSystem:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
@@ -475,6 +483,14 @@ u64 FileSystemController::GetTotalSpaceSize(FileSys::StorageId id) const {
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetFullNANDTotalSpace();
|
||||
case FileSys::StorageId::NandProdinfof:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetProdinfofNANDTotalSpace();
|
||||
case FileSys::StorageId::NandSafe:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
return bis_factory->GetSafeNANDTotalSpace();
|
||||
case FileSys::StorageId::NandSystem:
|
||||
if (bis_factory == nullptr)
|
||||
return 0;
|
||||
@@ -549,6 +565,15 @@ FileSys::PlaceholderCache* FileSystemController::GetGameCardPlaceholder() const
|
||||
return gamecard_placeholder.get();
|
||||
}
|
||||
|
||||
FileSys::RegisteredCache* FileSystemController::GetSafeNANDContents() const {
|
||||
LOG_TRACE(Service_FS, "Opening Safe NAND Contents");
|
||||
|
||||
if (bis_factory == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return bis_factory->GetSafeNANDContents();
|
||||
}
|
||||
|
||||
FileSys::RegisteredCache* FileSystemController::GetSystemNANDContents() const {
|
||||
LOG_TRACE(Service_FS, "Opening System NAND Contents");
|
||||
|
||||
@@ -576,6 +601,15 @@ FileSys::RegisteredCache* FileSystemController::GetSDMCContents() const {
|
||||
return sdmc_factory->GetSDMCContents();
|
||||
}
|
||||
|
||||
FileSys::PlaceholderCache* FileSystemController::GetSafeNANDPlaceholder() const {
|
||||
LOG_TRACE(Service_FS, "Opening Safe NAND Placeholder");
|
||||
|
||||
if (bis_factory == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return bis_factory->GetSafeNANDPlaceholder();
|
||||
}
|
||||
|
||||
FileSys::PlaceholderCache* FileSystemController::GetSystemNANDPlaceholder() const {
|
||||
LOG_TRACE(Service_FS, "Opening System NAND Placeholder");
|
||||
|
||||
@@ -608,10 +642,13 @@ FileSys::RegisteredCache* FileSystemController::GetRegisteredCacheForStorage(
|
||||
switch (id) {
|
||||
case FileSys::StorageId::None:
|
||||
case FileSys::StorageId::Host:
|
||||
case FileSys::StorageId::NandProdinfof:
|
||||
UNIMPLEMENTED();
|
||||
return nullptr;
|
||||
case FileSys::StorageId::GameCard:
|
||||
return GetGameCardContents();
|
||||
case FileSys::StorageId::NandSafe:
|
||||
return GetSafeNANDContents();
|
||||
case FileSys::StorageId::NandSystem:
|
||||
return GetSystemNANDContents();
|
||||
case FileSys::StorageId::NandUser:
|
||||
@@ -628,10 +665,13 @@ FileSys::PlaceholderCache* FileSystemController::GetPlaceholderCacheForStorage(
|
||||
switch (id) {
|
||||
case FileSys::StorageId::None:
|
||||
case FileSys::StorageId::Host:
|
||||
case FileSys::StorageId::NandProdinfof:
|
||||
UNIMPLEMENTED();
|
||||
return nullptr;
|
||||
case FileSys::StorageId::GameCard:
|
||||
return GetGameCardPlaceholder();
|
||||
case FileSys::StorageId::NandSafe:
|
||||
return GetSafeNANDPlaceholder();
|
||||
case FileSys::StorageId::NandSystem:
|
||||
return GetSystemNANDPlaceholder();
|
||||
case FileSys::StorageId::NandUser:
|
||||
@@ -643,6 +683,15 @@ FileSys::PlaceholderCache* FileSystemController::GetPlaceholderCacheForStorage(
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
FileSys::VirtualDir FileSystemController::GetSafeNANDContentDirectory() const {
|
||||
LOG_TRACE(Service_FS, "Opening safe NAND content directory");
|
||||
|
||||
if (bis_factory == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return bis_factory->GetSafeNANDContentDirectory();
|
||||
}
|
||||
|
||||
FileSys::VirtualDir FileSystemController::GetSystemNANDContentDirectory() const {
|
||||
LOG_TRACE(Service_FS, "Opening system NAND content directory");
|
||||
|
||||
@@ -690,6 +739,8 @@ FileSys::VirtualDir FileSystemController::GetSDMCImageDirectory() const {
|
||||
|
||||
FileSys::VirtualDir FileSystemController::GetContentDirectory(ContentStorageId id) const {
|
||||
switch (id) {
|
||||
case ContentStorageId::Safe:
|
||||
return GetSafeNANDContentDirectory();
|
||||
case ContentStorageId::System:
|
||||
return GetSystemNANDContentDirectory();
|
||||
case ContentStorageId::User:
|
||||
|
||||
@@ -43,6 +43,7 @@ class ServiceManager;
|
||||
namespace FileSystem {
|
||||
|
||||
enum class ContentStorageId : u32 {
|
||||
Safe,
|
||||
System,
|
||||
User,
|
||||
SdCard,
|
||||
@@ -91,11 +92,13 @@ public:
|
||||
void SetGameCard(FileSys::VirtualFile file);
|
||||
FileSys::XCI* GetGameCard() const;
|
||||
|
||||
FileSys::RegisteredCache* GetSafeNANDContents() const;
|
||||
FileSys::RegisteredCache* GetSystemNANDContents() const;
|
||||
FileSys::RegisteredCache* GetUserNANDContents() const;
|
||||
FileSys::RegisteredCache* GetSDMCContents() const;
|
||||
FileSys::RegisteredCache* GetGameCardContents() const;
|
||||
|
||||
FileSys::PlaceholderCache* GetSafeNANDPlaceholder() const;
|
||||
FileSys::PlaceholderCache* GetSystemNANDPlaceholder() const;
|
||||
FileSys::PlaceholderCache* GetUserNANDPlaceholder() const;
|
||||
FileSys::PlaceholderCache* GetSDMCPlaceholder() const;
|
||||
@@ -104,6 +107,7 @@ public:
|
||||
FileSys::RegisteredCache* GetRegisteredCacheForStorage(FileSys::StorageId id) const;
|
||||
FileSys::PlaceholderCache* GetPlaceholderCacheForStorage(FileSys::StorageId id) const;
|
||||
|
||||
FileSys::VirtualDir GetSafeNANDContentDirectory() const;
|
||||
FileSys::VirtualDir GetSystemNANDContentDirectory() const;
|
||||
FileSys::VirtualDir GetUserNANDContentDirectory() const;
|
||||
FileSys::VirtualDir GetSDMCContentDirectory() const;
|
||||
|
||||
@@ -842,11 +842,11 @@ void FSP_SRV::OpenBisFileSystem(Kernel::HLERequestContext& ctx) {
|
||||
IPC::RequestParser rp{ctx};
|
||||
|
||||
const auto input_buffer = ctx.ReadBuffer();
|
||||
[[maybe_unused]] const std::string input = Common::StringFromBuffer(input_buffer);
|
||||
[[maybe_unused]] const std::string root_path = Common::StringFromBuffer(input_buffer);
|
||||
|
||||
const auto partition_id = static_cast<FileSys::BisPartitionId>(rp.Pop<u32>());
|
||||
|
||||
LOG_DEBUG(Service_FS, "called with partition_id={}, input_buffer={}", partition_id, input);
|
||||
LOG_DEBUG(Service_FS, "called with partition_id={}, root_path={}", partition_id, root_path);
|
||||
|
||||
auto partition = fsc.OpenBISPartition(partition_id);
|
||||
if (partition.Failed()) {
|
||||
@@ -858,8 +858,10 @@ void FSP_SRV::OpenBisFileSystem(Kernel::HLERequestContext& ctx) {
|
||||
FileSys::StorageId id{};
|
||||
switch (partition_id) {
|
||||
case FileSys::BisPartitionId::CalibrationFile:
|
||||
id = FileSys::StorageId::NandProdinfof;
|
||||
break;
|
||||
case FileSys::BisPartitionId::SafeMode:
|
||||
id = FileSys::StorageId::Host;
|
||||
id = FileSys::StorageId::NandSafe;
|
||||
break;
|
||||
case FileSys::BisPartitionId::System:
|
||||
id = FileSys::StorageId::NandSystem;
|
||||
@@ -960,9 +962,10 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
|
||||
case FileSys::SaveDataSpaceId::NandSystem:
|
||||
id = FileSys::StorageId::NandSystem;
|
||||
break;
|
||||
case FileSys::SaveDataSpaceId::SafeMode:
|
||||
id = FileSys::StorageId::NandSafe;
|
||||
case FileSys::SaveDataSpaceId::TemporaryStorage:
|
||||
case FileSys::SaveDataSpaceId::ProperSystem:
|
||||
case FileSys::SaveDataSpaceId::SafeMode:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user