Unmount partitions after restore (except for CACHE:).
Wipe sd-ext on data wipe. Fix bug where wiping SDEXT: did not work.
This commit is contained in:
parent
7fe4d7bbcb
commit
2f73e58ef8
@ -410,8 +410,19 @@ int confirm_format()
|
||||
return chosen_item == 7;
|
||||
}
|
||||
|
||||
int format_mmc_device(char* root)
|
||||
int format_non_mtd_device(const char* root)
|
||||
{
|
||||
// if this is SDEXT:, don't worry about it.
|
||||
if (0 == strcmp(root, "SDEXT:"))
|
||||
{
|
||||
struct stat st;
|
||||
if (0 != stat("/dev/block/mmcblk0p2", &st))
|
||||
{
|
||||
ui_print("No app2sd partition found. Skipping format of /sd-ext.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
char path[PATH_MAX];
|
||||
translate_root_path(root, path, PATH_MAX);
|
||||
if (0 != ensure_root_path_mounted(root))
|
||||
@ -523,7 +534,7 @@ void show_partition_menu()
|
||||
if (!confirm_format())
|
||||
continue;
|
||||
ui_print("Formatting %s...\n", mmcs[chosen_item][1]);
|
||||
if (0 != format_mmc_device(mmcs[chosen_item][1]))
|
||||
if (0 != format_non_mtd_device(mmcs[chosen_item][1]))
|
||||
ui_print("Error formatting %s!\n", mmcs[chosen_item][1]);
|
||||
else
|
||||
ui_print("Done.\n");
|
||||
@ -676,6 +687,9 @@ void show_nandroid_advanced_restore_menu()
|
||||
case 3:
|
||||
nandroid_restore(file, 0, 0, 0, 1, 0);
|
||||
break;
|
||||
case 4:
|
||||
nandroid_restore(file, 0, 0, 0, 0, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ void
|
||||
show_choose_zip_menu();
|
||||
|
||||
int
|
||||
do_nandroid_backup(char* backup_name);
|
||||
do_nandroid_backup(const char* backup_name);
|
||||
|
||||
int
|
||||
do_nandroid_restore();
|
||||
@ -38,4 +38,4 @@ void
|
||||
show_advanced_menu();
|
||||
|
||||
int
|
||||
format_mmc_device(char* root);
|
||||
format_non_mtd_device(const char* root);
|
||||
|
20
nandroid.c
20
nandroid.c
@ -75,7 +75,7 @@ void compute_directory_stats(char* directory)
|
||||
ui_show_progress(1, 0);
|
||||
}
|
||||
|
||||
int nandroid_backup_partition(char* backup_path, char* root) {
|
||||
int nandroid_backup_partition(const char* backup_path, char* root) {
|
||||
int ret = 0;
|
||||
char mount_point[PATH_MAX];
|
||||
translate_root_path(root, mount_point, PATH_MAX);
|
||||
@ -98,7 +98,7 @@ int nandroid_backup_partition(char* backup_path, char* root) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nandroid_backup(char* backup_path)
|
||||
int nandroid_backup(const char* backup_path)
|
||||
{
|
||||
ui_set_background(BACKGROUND_ICON_INSTALLING);
|
||||
|
||||
@ -171,7 +171,7 @@ int nandroid_backup(char* backup_path)
|
||||
|
||||
typedef int (*format_function)(char* root);
|
||||
|
||||
int nandroid_restore_partition_internal(char* backup_path, char* root, format_function formatter) {
|
||||
int nandroid_restore_partition(const char* backup_path, const char* root) {
|
||||
int ret = 0;
|
||||
char mount_point[PATH_MAX];
|
||||
translate_root_path(root, mount_point, PATH_MAX);
|
||||
@ -182,7 +182,7 @@ int nandroid_restore_partition_internal(char* backup_path, char* root, format_fu
|
||||
ui_print("Can't unmount %s!\n", mount_point);
|
||||
return ret;
|
||||
}
|
||||
if (0 != (ret = formatter(root))) {
|
||||
if (0 != (ret = format_root_device(root))) {
|
||||
ui_print("Error while formatting %s!\n", root);
|
||||
return ret;
|
||||
}
|
||||
@ -198,14 +198,14 @@ int nandroid_restore_partition_internal(char* backup_path, char* root, format_fu
|
||||
ui_print("Error while restoring %s!\n", mount_point);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (0 != strcmp(root, "CACHE")) {
|
||||
ensure_root_path_unmounted(root);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nandroid_restore_partition(char* backup_path, char* root) {
|
||||
return nandroid_restore_partition_internal(backup_path, root, format_root_device);
|
||||
}
|
||||
|
||||
int nandroid_restore(char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext)
|
||||
int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext)
|
||||
{
|
||||
ui_set_background(BACKGROUND_ICON_INSTALLING);
|
||||
ui_show_indeterminate_progress();
|
||||
@ -247,7 +247,7 @@ int nandroid_restore(char* backup_path, int restore_boot, int restore_system, in
|
||||
sprintf(tmp, "%s/sd-ext.img", backup_path);
|
||||
if (0 != (ret = statfs(tmp, &s)))
|
||||
ui_print("sd-ext.img not found. Skipping restore of /sd-ext.");
|
||||
else if (0 != (ret = nandroid_restore_partition_internal(backup_path, "SDEXT:", format_mmc_device)))
|
||||
else if (0 != (ret = nandroid_restore_partition(backup_path, "SDEXT:")))
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define NANDROID_H
|
||||
|
||||
int nandroid_main(int argc, char** argv);
|
||||
int nandroid_backup(char* backup_path);
|
||||
int nandroid_restore(char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext);
|
||||
int nandroid_backup(const char* backup_path);
|
||||
int nandroid_restore(const char* backup_path, int restore_boot, int restore_system, int restore_data, int restore_cache, int restore_sdext);
|
||||
|
||||
#endif
|
@ -385,6 +385,7 @@ wipe_data(int confirm) {
|
||||
device_wipe_data();
|
||||
erase_root("DATA:");
|
||||
erase_root("CACHE:");
|
||||
erase_root("SDEXT:");
|
||||
ui_print("Data wipe complete.\n");
|
||||
}
|
||||
|
||||
|
7
roots.c
7
roots.c
@ -27,6 +27,8 @@
|
||||
#include "roots.h"
|
||||
#include "common.h"
|
||||
|
||||
#include "extendedcommands.h"
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *device;
|
||||
@ -366,7 +368,6 @@ format_root_device(const char *root)
|
||||
}
|
||||
}
|
||||
}
|
||||
//TODO: handle other device types (sdcard, etc.)
|
||||
LOGW("format_root_device: can't handle non-mtd device \"%s\"\n", root);
|
||||
return -1;
|
||||
|
||||
return format_non_mtd_device(root);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user