summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar liamwhite2023-08-25 18:00:15 -0400
committerGravatar GitHub2023-08-26 00:00:15 +0200
commitb923f5aa7e7d59b78b1b42bdcfbb3ec92c092d02 (patch)
tree7dcae67a5ac36bb6a5f322a6611d04b785030135 /src
parentkernel: offset code entry point for 39-bit address space type (#11326) (diff)
downloadyuzu-b923f5aa7e7d59b78b1b42bdcfbb3ec92c092d02.tar.gz
yuzu-b923f5aa7e7d59b78b1b42bdcfbb3ec92c092d02.tar.xz
yuzu-b923f5aa7e7d59b78b1b42bdcfbb3ec92c092d02.zip
registered_cache: create fake CNMT entries for program updates of multiprogram applications (#11319)
Diffstat (limited to 'src')
-rw-r--r--src/core/file_sys/registered_cache.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/core/file_sys/registered_cache.cpp b/src/core/file_sys/registered_cache.cpp
index a28af3594..f70adab82 100644
--- a/src/core/file_sys/registered_cache.cpp
+++ b/src/core/file_sys/registered_cache.cpp
@@ -606,9 +606,9 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
606 const auto result = RemoveExistingEntry(title_id); 606 const auto result = RemoveExistingEntry(title_id);
607 607
608 // Install Metadata File 608 // Install Metadata File
609 const auto res = RawInstallNCA(**meta_iter, copy, overwrite_if_exists, meta_id_data); 609 const auto meta_result = RawInstallNCA(**meta_iter, copy, overwrite_if_exists, meta_id_data);
610 if (res != InstallResult::Success) { 610 if (meta_result != InstallResult::Success) {
611 return res; 611 return meta_result;
612 } 612 }
613 613
614 // Install all the other NCAs 614 // Install all the other NCAs
@@ -621,9 +621,19 @@ InstallResult RegisteredCache::InstallEntry(const NSP& nsp, bool overwrite_if_ex
621 if (nca == nullptr) { 621 if (nca == nullptr) {
622 return InstallResult::ErrorCopyFailed; 622 return InstallResult::ErrorCopyFailed;
623 } 623 }
624 const auto res2 = RawInstallNCA(*nca, copy, overwrite_if_exists, record.nca_id); 624 if (nca->GetStatus() == Loader::ResultStatus::ErrorMissingBKTRBaseRomFS &&
625 if (res2 != InstallResult::Success) { 625 nca->GetTitleId() != title_id) {
626 return res2; 626 // Create fake cnmt for patch to multiprogram application
627 const auto sub_nca_result =
628 InstallEntry(*nca, TitleType::Update, overwrite_if_exists, copy);
629 if (sub_nca_result != InstallResult::Success) {
630 return sub_nca_result;
631 }
632 continue;
633 }
634 const auto nca_result = RawInstallNCA(*nca, copy, overwrite_if_exists, record.nca_id);
635 if (nca_result != InstallResult::Success) {
636 return nca_result;
627 } 637 }
628 } 638 }
629 639
@@ -663,6 +673,8 @@ InstallResult RegisteredCache::InstallEntry(const NCA& nca, TitleType type,
663} 673}
664 674
665bool RegisteredCache::RemoveExistingEntry(u64 title_id) const { 675bool RegisteredCache::RemoveExistingEntry(u64 title_id) const {
676 bool removed_data = false;
677
666 const auto delete_nca = [this](const NcaID& id) { 678 const auto delete_nca = [this](const NcaID& id) {
667 const auto path = GetRelativePathFromNcaID(id, false, true, false); 679 const auto path = GetRelativePathFromNcaID(id, false, true, false);
668 680
@@ -706,11 +718,18 @@ bool RegisteredCache::RemoveExistingEntry(u64 title_id) const {
706 const auto deleted_html = delete_nca(html_id); 718 const auto deleted_html = delete_nca(html_id);
707 const auto deleted_legal = delete_nca(legal_id); 719 const auto deleted_legal = delete_nca(legal_id);
708 720
709 return deleted_meta && (deleted_meta || deleted_program || deleted_data || 721 removed_data |= (deleted_meta || deleted_program || deleted_data || deleted_control ||
710 deleted_control || deleted_html || deleted_legal); 722 deleted_html || deleted_legal);
711 } 723 }
712 724
713 return false; 725 // If patch entries for any program exist in yuzu meta, remove them
726 for (u8 i = 0; i < 0x10; i++) {
727 const auto meta_dir = dir->CreateDirectoryRelative("yuzu_meta");
728 const auto filename = GetCNMTName(TitleType::Update, title_id + i);
729 removed_data |= meta_dir->DeleteFile(filename);
730 }
731
732 return removed_data;
714} 733}
715 734
716InstallResult RegisteredCache::RawInstallNCA(const NCA& nca, const VfsCopyFunction& copy, 735InstallResult RegisteredCache::RawInstallNCA(const NCA& nca, const VfsCopyFunction& copy,