mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2024-11-30 18:34:38 +01:00
ams_mitm: add titles dir compat shim (to remove in 0.10.1)
This commit is contained in:
parent
16c638756c
commit
90367aea0d
3
Makefile
3
Makefile
@ -58,6 +58,7 @@ dist: all
|
||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/contents/0100000000000037
|
||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/fatal_errors
|
||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/config_templates
|
||||
mkdir -p atmosphere-$(AMSVER)/atmosphere/config
|
||||
cp fusee/fusee-primary/fusee-primary.bin atmosphere-$(AMSVER)/atmosphere/reboot_payload.bin
|
||||
cp fusee/fusee-mtc/fusee-mtc.bin atmosphere-$(AMSVER)/atmosphere/fusee-mtc.bin
|
||||
cp fusee/fusee-secondary/fusee-secondary.bin atmosphere-$(AMSVER)/atmosphere/fusee-secondary.bin
|
||||
@ -66,7 +67,7 @@ dist: all
|
||||
cp sept/sept-secondary/sept-secondary.bin atmosphere-$(AMSVER)/sept/sept-secondary.bin
|
||||
cp sept/sept-secondary/sept-secondary_00.enc atmosphere-$(AMSVER)/sept/sept-secondary_00.enc
|
||||
cp sept/sept-secondary/sept-secondary_01.enc atmosphere-$(AMSVER)/sept/sept-secondary_01.enc
|
||||
cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/BCT.ini
|
||||
cp common/defaults/BCT.ini atmosphere-$(AMSVER)/atmosphere/config/BCT.ini
|
||||
cp common/defaults/override_config.ini atmosphere-$(AMSVER)/atmosphere/config_templates/override_config.ini
|
||||
cp common/defaults/system_settings.ini atmosphere-$(AMSVER)/atmosphere/config_templates/system_settings.ini
|
||||
cp -r common/defaults/kip_patches atmosphere-$(AMSVER)/atmosphere/kip_patches
|
||||
|
@ -51,7 +51,7 @@ static char g_bct0_buffer[BCTO_MAX_SIZE];
|
||||
"[stratosphere]\n"
|
||||
|
||||
static const char *load_config(void) {
|
||||
if (!read_from_file(g_bct0_buffer, BCTO_MAX_SIZE, "atmosphere/BCT.ini")) {
|
||||
if (!read_from_file(g_bct0_buffer, BCTO_MAX_SIZE, "atmosphere/config/BCT.ini")) {
|
||||
print(SCREEN_LOG_LEVEL_DEBUG, "Failed to read BCT0 from SD!\n");
|
||||
print(SCREEN_LOG_LEVEL_DEBUG, "Using default BCT0!\n");
|
||||
memcpy(g_bct0_buffer, DEFAULT_BCT0, sizeof(DEFAULT_BCT0));
|
||||
|
@ -101,7 +101,7 @@ int main(int argc, void **argv) {
|
||||
/* Load BCT0 from SD if needed. */
|
||||
if (strcmp(g_stage2_args->bct0, "") == 0) {
|
||||
uint32_t bct_tmp_buf[sizeof(g_stage2_args->bct0) / sizeof(uint32_t)] = {0};
|
||||
if (!read_from_file(bct_tmp_buf, sizeof(bct_tmp_buf) - 1, "atmosphere/BCT.ini")) {
|
||||
if (!read_from_file(bct_tmp_buf, sizeof(bct_tmp_buf) - 1, "atmosphere/config/BCT.ini")) {
|
||||
fatal_error("Failed to read BCT0 from SD!\n");
|
||||
}
|
||||
memcpy(g_stage2_args->bct0, bct_tmp_buf, sizeof(bct_tmp_buf));
|
||||
|
@ -40,6 +40,14 @@ namespace ams::mitm::fs {
|
||||
}
|
||||
}
|
||||
|
||||
void FormatAtmosphereSdPath(char *dst_path, size_t dst_path_size, const char *subdir, const char *src_path) {
|
||||
if (src_path[0] == '/') {
|
||||
std::snprintf(dst_path, dst_path_size, "/atmosphere/%s%s", subdir, src_path);
|
||||
} else {
|
||||
std::snprintf(dst_path, dst_path_size, "/atmosphere/%s/%s", subdir, src_path);
|
||||
}
|
||||
}
|
||||
|
||||
void FormatAtmosphereSdPath(char *dst_path, size_t dst_path_size, ncm::ProgramId program_id, const char *src_path) {
|
||||
if (src_path[0] == '/') {
|
||||
std::snprintf(dst_path, dst_path_size, "/atmosphere/contents/%016lx%s", static_cast<u64>(program_id), src_path);
|
||||
@ -146,6 +154,15 @@ namespace ams::mitm::fs {
|
||||
return fsFsOpenDirectory(fs, fixed_path, mode, out);
|
||||
}
|
||||
|
||||
/* TODO: Remove this in Atmosphere 0.10.1. */
|
||||
Result RenameProgramDirectoryForCompatibility(const char *dir_name) {
|
||||
R_TRY(EnsureSdInitialized());
|
||||
char titles_fixed_path[ams::fs::EntryNameLengthMax + 1];
|
||||
char contents_fixed_path[ams::fs::EntryNameLengthMax + 1];
|
||||
FormatAtmosphereSdPath(titles_fixed_path, sizeof(titles_fixed_path), "titles", dir_name);
|
||||
FormatAtmosphereSdPath(contents_fixed_path, sizeof(contents_fixed_path), "contents", dir_name);
|
||||
return fsFsRenameDirectory(&g_sd_filesystem, titles_fixed_path, contents_fixed_path);
|
||||
}
|
||||
|
||||
bool HasSdRomfsContent(ncm::ProgramId program_id) {
|
||||
/* Check if romfs.bin is present. */
|
||||
|
@ -38,6 +38,9 @@ namespace ams::mitm::fs {
|
||||
Result OpenAtmosphereSdRomfsDirectory(FsDir *out, ncm::ProgramId program_id, const char *path, u32 mode);
|
||||
Result OpenAtmosphereRomfsDirectory(FsDir *out, ncm::ProgramId program_id, const char *path, u32 mode, FsFileSystem *fs);
|
||||
|
||||
/* TODO: Remove this in Atmosphere 0.10.1. */
|
||||
Result RenameProgramDirectoryForCompatibility(const char *dir_name);
|
||||
|
||||
bool HasSdRomfsContent(ncm::ProgramId program_id);
|
||||
|
||||
Result SaveAtmosphereSdFile(FsFile *out, ncm::ProgramId program_id, const char *path, void *data, size_t size);
|
||||
|
@ -65,6 +65,17 @@ namespace ams::mitm {
|
||||
/* Emummc file protection. */
|
||||
FsFile g_emummc_file;
|
||||
|
||||
constexpr inline bool IsHexadecimal(const char *str) {
|
||||
while (*str) {
|
||||
if (std::isxdigit(static_cast<unsigned char>(*str))) {
|
||||
str++;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void GetBackupFileName(char *dst, size_t dst_size, const char *serial_number, const char *fn) {
|
||||
if (strlen(serial_number) > 0) {
|
||||
std::snprintf(dst, dst_size, "automatic_backups/%s_%s", serial_number, fn);
|
||||
@ -167,6 +178,23 @@ namespace ams::mitm {
|
||||
}
|
||||
}
|
||||
|
||||
void RenameTitlesDirectoryProgramFoldersForCompatibility() {
|
||||
FsDir titles_dir;
|
||||
if (R_FAILED(mitm::fs::OpenAtmosphereSdDirectory(&titles_dir, "/titles", ams::fs::OpenDirectoryMode_Directory))) {
|
||||
return;
|
||||
}
|
||||
ON_SCOPE_EXIT { fsDirClose(&titles_dir); };
|
||||
|
||||
ams::fs::DirectoryEntry dir_entry;
|
||||
s64 read_entries;
|
||||
while (R_SUCCEEDED(fsDirRead(&titles_dir, &read_entries, 1, &dir_entry)) && read_entries == 1) {
|
||||
if (strlen(dir_entry.name) == 2 * sizeof(ncm::ProgramId) && IsHexadecimal(dir_entry.name)) {
|
||||
/* We found a program directory, try to rename it. Failure is allowed. */
|
||||
mitm::fs::RenameProgramDirectoryForCompatibility(dir_entry.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Initialization implementation */
|
||||
void InitializeThreadFunc(void *arg) {
|
||||
/* Wait for the SD card to be ready. */
|
||||
@ -182,6 +210,10 @@ namespace ams::mitm {
|
||||
/* Backup Calibration Binary and BIS keys. */
|
||||
CreateAutomaticBackups();
|
||||
|
||||
/* Rename program folders in the titles directory. */
|
||||
/* TODO: Remove this in Atmosphere 0.10.1. */
|
||||
RenameTitlesDirectoryProgramFoldersForCompatibility();
|
||||
|
||||
/* If we're emummc, persist a write-handle to prevent other processes from touching the image. */
|
||||
if (emummc::IsActive()) {
|
||||
if (const char *emummc_file_path = emummc::GetFilePath(); emummc_file_path != nullptr) {
|
||||
|
@ -291,7 +291,7 @@ namespace ams::settings::fwdbg {
|
||||
Result LoadSdCardKeyValueStore() {
|
||||
/* Open file. */
|
||||
FsFile config_file;
|
||||
if (R_FAILED(ams::mitm::fs::OpenAtmosphereSdFile(&config_file, "/system_settings.ini", fs::OpenMode_Read))) {
|
||||
if (R_FAILED(ams::mitm::fs::OpenAtmosphereSdFile(&config_file, "/config/system_settings.ini", fs::OpenMode_Read))) {
|
||||
/* It's okay if the file isn't readable/present, because we already loaded defaults. */
|
||||
return ResultSuccess();
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ namespace ams::cfg {
|
||||
}
|
||||
|
||||
void RefreshOverrideConfiguration() {
|
||||
ParseIniFile(OverrideConfigIniHandler, "/atmosphere/override_config.ini", nullptr);
|
||||
ParseIniFile(OverrideConfigIniHandler, "/atmosphere/config/override_config.ini", nullptr);
|
||||
}
|
||||
|
||||
ContentSpecificOverrideConfig GetContentOverrideConfig(ncm::ProgramId program_id) {
|
||||
|
Loading…
Reference in New Issue
Block a user