Implement blank prodinfo creation.

This is a complete implementation of what PR #532 seeks to do
(thanks @ThatNerdyPikachu). However, it currently blackscreens.

This is because we can't actually mitm settings, because settings
must be able to complete its initialization before the sd card
can be mounted. Thus we end up with a circular dependency and
the console blackscreens. This problem may yet be solvable, but
it's unclear immediately how this dependency might be solved. In any
event, this serves as a reference to use in the event that a solution
arises.
This commit is contained in:
Michael Scire
2019-05-10 05:27:30 -07:00
parent bb6cc6532b
commit 3bba035b84
4 changed files with 211 additions and 71 deletions

View File

@@ -32,6 +32,7 @@
#include "fs_save_utils.hpp"
#include "fs_subdirectory_filesystem.hpp"
#include "fs_directory_savedata_filesystem.hpp"
#include "fs_file_storage.hpp"
#include "../debug.hpp"
@@ -261,11 +262,24 @@ Result FsMitmService::OpenBisStorage(Out<std::shared_ptr<IStorageInterface>> out
const bool is_sysmodule = TitleIdIsSystem(this->title_id);
const bool has_bis_write_flag = Utils::HasFlag(this->title_id, "bis_write");
const bool has_cal0_read_flag = Utils::HasFlag(this->title_id, "cal_read");
const bool has_blank_cal0_flag = Utils::HasGlobalFlag("blank_prodinfo");
if (bis_partition_id == BisStorageId_Boot0) {
storage = std::make_shared<IStorageInterface>(new Boot0Storage(bis_storage, this->title_id));
} else if (bis_partition_id == BisStorageId_Prodinfo) {
/* PRODINFO should *never* be writable. */
if (is_sysmodule || has_cal0_read_flag) {
if (has_blank_cal0_flag) {
FsFile file;
if (R_FAILED((rc = Utils::OpenBlankProdInfoFile(&file)))) {
return rc;
}
storage = std::make_shared<IStorageInterface>(new FileStorage(new ProxyFile(&file)));
if (out_storage.IsDomain()) {
out_domain_id = file.s.object_id;
}
return rc;
} else if (is_sysmodule || has_cal0_read_flag) {
storage = std::make_shared<IStorageInterface>(new ROProxyStorage(bis_storage));
} else {
/* Do not allow non-sysmodules to read *or* write CAL0. */