mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-22 11:56:42 +00:00
Implement dumping of partitions
This commit is contained in:
parent
f93cc0ff44
commit
a6eaa1ec51
7 changed files with 85 additions and 18 deletions
|
@ -108,4 +108,6 @@ extern menu_entry fs_menu_startdir[];
|
|||
|
||||
extern gpt_entry_rule gpt_fs_rules[];
|
||||
|
||||
extern menu_entry mmcmenu_start[];
|
||||
extern menu_entry mmcmenu_start[];
|
||||
|
||||
extern menu_entry mmcmenu_filemenu[];
|
|
@ -81,5 +81,13 @@ gpt_entry_rule gpt_fs_rules[] = {
|
|||
|
||||
menu_entry mmcmenu_start[] = {
|
||||
{"Back", COLOR_ORANGE, ISMENU},
|
||||
{"RESERVED\n", COLOR_ORANGE, ISMENU}
|
||||
{"RESERVED\n", COLOR_ORANGE, ISMENU},
|
||||
{"BOOT0/1", COLOR_BLUE, isBOOT | ISMENU}
|
||||
};
|
||||
|
||||
menu_entry mmcmenu_filemenu[] = {
|
||||
{"Part:", COLOR_ORANGE, ISSKIP | ISMENU},
|
||||
{NULL, COLOR_VIOLET, ISSKIP | ISMENU},
|
||||
{"\nBack", COLOR_WHITE, ISMENU},
|
||||
{"Dump to SD", COLOR_YELLOW, ISMENU}
|
||||
};
|
|
@ -50,4 +50,5 @@ typedef struct {
|
|||
u8 property;
|
||||
} gpt_entry_rule;
|
||||
|
||||
#define isFS 0x80
|
||||
#define isFS 0x80
|
||||
#define isBOOT 0x2
|
|
@ -68,11 +68,24 @@ int dump_emmc_part(char *path, sdmmc_storage_t *mmcstorage, emmc_part_t *part){
|
|||
return 0;
|
||||
}
|
||||
|
||||
int existsCheck(char *path){
|
||||
int res = 0;
|
||||
|
||||
if (fsutil_checkfile(path)){
|
||||
gfx_printf("File already exists! Overwrite?\nVol +/- to cancel\n");
|
||||
res = gfx_makewaitmenu("Power to continue", 3);
|
||||
gfx_printf("\r \r");
|
||||
return res;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dump_emmc_parts(u16 parts, u8 mmctype){
|
||||
char *path;
|
||||
char basepath[] = "sd:/tegraexplorer/dumps";
|
||||
char basepath[] = "sd:/tegraexplorer/partition_dumps";
|
||||
f_mkdir("sd:/tegraexplorer");
|
||||
f_mkdir("sd:/tegraexplorer/dumps");
|
||||
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
||||
|
||||
connect_mmc(mmctype);
|
||||
gfx_clearscreen();
|
||||
|
@ -92,29 +105,44 @@ int dump_emmc_parts(u16 parts, u8 mmctype){
|
|||
|
||||
emummc_storage_set_mmc_partition(&storage, i + 1);
|
||||
utils_copystring(fsutil_getnextloc(basepath, bootPart.name), &path);
|
||||
|
||||
if (!existsCheck(path))
|
||||
continue;
|
||||
|
||||
gfx_printf("Dumping %s\n", bootPart.name);
|
||||
|
||||
dump_emmc_part(path, &storage, &bootPart);
|
||||
free(path);
|
||||
}
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
}
|
||||
|
||||
if (parts & PART_PKG2){
|
||||
for (int i = 0; i < 6; i++){
|
||||
if (connect_part(pkg2names[i])){
|
||||
gfx_errDisplay("dump_emmc_parts", ERR_PART_NOT_FOUND, 0);
|
||||
return -1;
|
||||
}
|
||||
utils_copystring(fsutil_getnextloc(basepath, pkg2names[i]), &path);
|
||||
gfx_printf("Dumping %s\n", pkg2names[i]);
|
||||
|
||||
utils_copystring(fsutil_getnextloc(basepath, system_part->name), &path);
|
||||
gfx_printf("Dumping %s\n", system_part->name);
|
||||
|
||||
dump_emmc_part(path, &storage, system_part);
|
||||
dump_emmc_specific(pkg2names[i], path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
||||
gfx_printf("\nDone!");
|
||||
btn_wait();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dump_emmc_specific(char *part, char *path){
|
||||
if (!existsCheck(path))
|
||||
return 0;
|
||||
|
||||
emummc_storage_set_mmc_partition(&storage, 0);
|
||||
if (connect_part(part)){
|
||||
gfx_errDisplay("dump_emmc_specific", ERR_PART_NOT_FOUND, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
dump_emmc_part(path, &storage, system_part);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -29,6 +29,8 @@
|
|||
#include "../utils/utils.h"
|
||||
#include "../gfx/menu.h"
|
||||
#include "../fs/fsmenu.h"
|
||||
#include "emmcoperations.h"
|
||||
#include "../fs/fsutils.h"
|
||||
|
||||
menu_entry *mmcMenuEntries = NULL;
|
||||
|
||||
|
@ -71,7 +73,7 @@ void addEntry(emmc_part_t *part, u8 property, int spot){
|
|||
}
|
||||
|
||||
int fillMmcMenu(short mmcType){
|
||||
int count = 2, i;
|
||||
int count = 3, i;
|
||||
|
||||
if (mmcMenuEntries != NULL)
|
||||
clearfileobjects(&mmcMenuEntries);
|
||||
|
@ -83,7 +85,7 @@ int fillMmcMenu(short mmcType){
|
|||
|
||||
createfileobjects(count, &mmcMenuEntries);
|
||||
|
||||
for (i = 0; i < 2; i++){
|
||||
for (i = 0; i < 3; i++){
|
||||
utils_copystring(mmcmenu_start[i].name, &mmcMenuEntries[i].name);
|
||||
mmcMenuEntries[i].property = mmcmenu_start[i].property;
|
||||
mmcMenuEntries[i].storage = mmcmenu_start[i].storage;
|
||||
|
@ -112,7 +114,33 @@ int makeMmcMenu(short mmcType){
|
|||
if (mmcMenuEntries[selection].property & ISDIR){
|
||||
if (!mount_mmc(mmcMenuEntries[selection].name, mmcMenuEntries[selection].storage))
|
||||
fileexplorer("emmc:/", 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mmcmenu_filemenu[1].name != NULL)
|
||||
free(mmcmenu_filemenu[1].name);
|
||||
|
||||
utils_copystring(mmcMenuEntries[selection].name, &mmcmenu_filemenu[1].name);
|
||||
|
||||
if ((menu_make(mmcmenu_filemenu, 4, "-- RAW PARTITION --")) < 3){
|
||||
break;
|
||||
}
|
||||
|
||||
if (mmcMenuEntries[selection].property & isBOOT){
|
||||
dump_emmc_parts(PART_BOOT, (u8)mmcType);
|
||||
}
|
||||
else {
|
||||
f_mkdir("sd:/tegraexplorer");
|
||||
f_mkdir("sd:/tegraexplorer/partition_dumps");
|
||||
|
||||
gfx_clearscreen();
|
||||
gfx_printf("Dumping %s...\n", mmcMenuEntries[selection].name);
|
||||
|
||||
if (!dump_emmc_specific(mmcMenuEntries[selection].name, fsutil_getnextloc("sd:/tegraexplorer/partition_dumps", mmcMenuEntries[selection].name))){
|
||||
gfx_printf("\nDone!");
|
||||
btn_wait();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,4 +2,5 @@
|
|||
#include "../../utils/types.h"
|
||||
|
||||
int dump_emmc_parts(u16 parts, u8 mmctype);
|
||||
int restore_bis_using_file(char *path, u8 mmctype);
|
||||
int restore_bis_using_file(char *path, u8 mmctype);
|
||||
int dump_emmc_specific(char *part, char *path);
|
|
@ -6,7 +6,6 @@
|
|||
#include "../../utils/util.h"
|
||||
#include "../../mem/minerva.h"
|
||||
#include "../../soc/gpio.h"
|
||||
#include "gfxutils.h"
|
||||
|
||||
extern void sd_unmount();
|
||||
extern bool sd_inited;
|
||||
|
|
Loading…
Reference in a new issue