mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-08 13:11:49 +00:00
sysupdater: make GetUpdateInformation work on hardware.
This commit is contained in:
parent
a6218ed814
commit
3324dd52ef
5 changed files with 37 additions and 8 deletions
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<MaxServers, ServerOptions, MaxSessions> g_server_manager;
|
||||
|
||||
}
|
||||
|
|
|
@ -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:<user_path>/ */
|
||||
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';
|
||||
}
|
||||
|
||||
Result SystemUpdateService::GetUpdateInformation(sf::Out<UpdateInformation> out, const ncm::Path &package_root) {
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Result SystemUpdateService::GetUpdateInformation(sf::Out<UpdateInformation> 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);
|
||||
|
|
Loading…
Reference in a new issue