diff --git a/libraries/libstratosphere/source/fs/fs_sd_card.cpp b/libraries/libstratosphere/source/fs/fs_sd_card.cpp index 66c22c2c5..576116ef9 100644 --- a/libraries/libstratosphere/source/fs/fs_sd_card.cpp +++ b/libraries/libstratosphere/source/fs/fs_sd_card.cpp @@ -43,10 +43,9 @@ namespace ams::fs { } - Result MountSdCard(const char *name) { /* Validate the mount name. */ - R_TRY(impl::CheckMountName(name)); + R_TRY(impl::CheckMountNameAllowingReserved(name)); /* Open the SD card. This uses libnx bindings. */ FsFileSystem fs; diff --git a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp index 62eeeac0e..405a43cc1 100644 --- a/stratosphere/ams_mitm/source/amsmitm_initialization.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_initialization.cpp @@ -139,6 +139,9 @@ namespace ams::mitm { /* Open global SD card file system, so that other threads can begin using the SD. */ mitm::fs::OpenGlobalSdCardFileSystem(); + /* Mount the sd card at a convenient mountpoint. */ + ams::fs::MountSdCard(ams::fs::impl::SdCardFileSystemMountName); + /* Initialize the reboot manager (load a payload off the SD). */ /* Discard result, since it doesn't need to succeed. */ mitm::bpc::LoadRebootPayload(); diff --git a/stratosphere/ams_mitm/source/amsmitm_main.cpp b/stratosphere/ams_mitm/source/amsmitm_main.cpp index c4a80d387..537132531 100644 --- a/stratosphere/ams_mitm/source/amsmitm_main.cpp +++ b/stratosphere/ams_mitm/source/amsmitm_main.cpp @@ -82,6 +82,7 @@ void __appInit(void) { R_ABORT_UNLESS(fsInitialize()); R_ABORT_UNLESS(pmdmntInitialize()); R_ABORT_UNLESS(pminfoInitialize()); + ncm::Initialize(); spl::InitializeForFs(); }); @@ -97,6 +98,7 @@ void __appInit(void) { void __appExit(void) { /* Cleanup services. */ spl::Finalize(); + ncm::Finalize(); pminfoExit(); pmdmntExit(); fsExit(); diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp index 1eed1e633..e19a7c544 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_module.cpp @@ -27,7 +27,13 @@ namespace ams::mitm::sysupdater { constexpr size_t MaxServers = 1; constexpr size_t MaxSessions = SystemUpdateMaxSessions; - using ServerOptions = sf::hipc::DefaultServerManagerOptions; + + struct ServerOptions { + static constexpr size_t PointerBufferSize = 1_KB; + static constexpr size_t MaxDomains = 0; + static constexpr size_t MaxDomainObjects = 0; + }; + sf::hipc::ServerManager g_server_manager; } diff --git a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp index a301e51e5..b061d5b5e 100644 --- a/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp +++ b/stratosphere/ams_mitm/source/sysupdater/sysupdater_service.cpp @@ -78,9 +78,29 @@ namespace ams::mitm::sysupdater { return info.version >= MinimumVersionForExFatDriver && ((info.attributes & ncm::ContentMetaAttribute_IncludesExFatDriver) != 0); } + Result FormatUserPackagePath(ncm::Path *out, const ncm::Path &user_path) { + /* Ensure that the user path is valid. */ + R_UNLESS(user_path.str[0] == '/', fs::ResultInvalidPath()); + + /* Print as @Sdcard:/ */ + std::snprintf(out->str, sizeof(out->str), "%s:%s/", ams::fs::impl::SdCardFileSystemMountName, user_path.str); + + /* Normalize, if the user provided an ending / */ + const size_t len = std::strlen(out->str); + if (out->str[len - 1] == '/' && out->str[len - 2] == '/') { + out->str[len - 1] = '\x00'; + } + + return ResultSuccess(); + } + } - Result SystemUpdateService::GetUpdateInformation(sf::Out out, const ncm::Path &package_root) { + Result SystemUpdateService::GetUpdateInformation(sf::Out out, const ncm::Path &path) { + /* Adjust the path. */ + ncm::Path package_root; + R_TRY(FormatUserPackagePath(std::addressof(package_root), path)); + /* Create a new update information. */ UpdateInformation update_info = {}; @@ -115,15 +135,14 @@ namespace ams::mitm::sysupdater { /* Create a reader. */ const auto reader = ncm::PackagedContentMetaReader(content_meta_buffer.Get(), content_meta_buffer.GetSize()); + /* Get the version from the header. */ + update_info.version = reader.GetHeader()->version; + /* Iterate over infos to find the system update info. */ for (size_t i = 0; i < reader.GetContentMetaCount(); ++i) { const auto &meta_info = *reader.GetContentMetaInfo(i); switch (meta_info.type) { - case ncm::ContentMetaType::SystemUpdate: - /* Set the version. */ - update_info.version = meta_info.version; - break; case ncm::ContentMetaType::BootImagePackage: /* Detect exFAT support. */ update_info.exfat_supported |= IsExFatDriverSupported(meta_info);