support backup and restore on internal sdcard
Change-Id: I6295b5bb7ada967ca223758be58d555c1a2ff462
This commit is contained in:
parent
f0e81c4643
commit
89ed0b7355
@ -37,7 +37,7 @@ else
|
||||
RECOVERY_NAME := CWM-based Recovery
|
||||
endif
|
||||
|
||||
RECOVERY_VERSION := $(RECOVERY_NAME) v5.0.2.6
|
||||
RECOVERY_VERSION := $(RECOVERY_NAME) v5.0.2.7
|
||||
|
||||
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
|
||||
RECOVERY_API_VERSION := 2
|
||||
|
@ -333,10 +333,10 @@ void show_choose_zip_menu(const char *mount_point)
|
||||
install_zip(file);
|
||||
}
|
||||
|
||||
void show_nandroid_restore_menu()
|
||||
void show_nandroid_restore_menu(const char* path)
|
||||
{
|
||||
if (ensure_path_mounted("/sdcard") != 0) {
|
||||
LOGE ("Can't mount /sdcard\n");
|
||||
if (ensure_path_mounted(path) != 0) {
|
||||
LOGE("Can't mount %s\n", path);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -345,7 +345,9 @@ void show_nandroid_restore_menu()
|
||||
NULL
|
||||
};
|
||||
|
||||
char* file = choose_file_menu("/sdcard/clockworkmod/backup/", NULL, headers);
|
||||
char tmp[PATH_MAX];
|
||||
sprintf(tmp, "%s/clockworkmod/backup/", path);
|
||||
char* file = choose_file_menu(tmp, NULL, headers);
|
||||
if (file == NULL)
|
||||
return;
|
||||
|
||||
@ -713,7 +715,7 @@ void show_partition_menu()
|
||||
|
||||
}
|
||||
|
||||
void show_nandroid_advanced_restore_menu()
|
||||
void show_nandroid_advanced_restore_menu(const char* path)
|
||||
{
|
||||
if (ensure_path_mounted("/sdcard") != 0) {
|
||||
LOGE ("Can't mount /sdcard\n");
|
||||
@ -792,12 +794,18 @@ void show_nandroid_menu()
|
||||
NULL
|
||||
};
|
||||
|
||||
static char* list[] = { "Backup",
|
||||
"Restore",
|
||||
"Advanced Restore",
|
||||
static char* list[] = { "backup",
|
||||
"restore",
|
||||
"advanced restore",
|
||||
"backup to internal sdcard",
|
||||
"restore from internal sdcard",
|
||||
"advanced restore from internal sdcard",
|
||||
NULL
|
||||
};
|
||||
|
||||
if (volume_for_path("/emmc") == NULL)
|
||||
INSTALL_MENU_ITEMS[3] = NULL;
|
||||
|
||||
int chosen_item = get_menu_selection(headers, list, 0, 0);
|
||||
switch (chosen_item)
|
||||
{
|
||||
@ -820,10 +828,34 @@ void show_nandroid_menu()
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
show_nandroid_restore_menu();
|
||||
show_nandroid_restore_menu("/sdcard");
|
||||
break;
|
||||
case 2:
|
||||
show_nandroid_advanced_restore_menu();
|
||||
show_nandroid_advanced_restore_menu("/sdcard");
|
||||
break;
|
||||
case 3:
|
||||
{
|
||||
char backup_path[PATH_MAX];
|
||||
time_t t = time(NULL);
|
||||
struct tm *tmp = localtime(&t);
|
||||
if (tmp == NULL)
|
||||
{
|
||||
struct timeval tp;
|
||||
gettimeofday(&tp, NULL);
|
||||
sprintf(backup_path, "/emmc/clockworkmod/backup/%d", tp.tv_sec);
|
||||
}
|
||||
else
|
||||
{
|
||||
strftime(backup_path, sizeof(backup_path), "/emmc/clockworkmod/backup/%F.%H.%M.%S", tmp);
|
||||
}
|
||||
nandroid_backup(backup_path);
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
show_nandroid_restore_menu("/emmc");
|
||||
break;
|
||||
case 5:
|
||||
show_nandroid_advanced_restore_menu("/emmc");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1048,9 +1080,8 @@ void create_fstab()
|
||||
write_fstab_root("/boot", file);
|
||||
write_fstab_root("/cache", file);
|
||||
write_fstab_root("/data", file);
|
||||
if (has_datadata()) {
|
||||
write_fstab_root("/datadata", file);
|
||||
}
|
||||
write_fstab_root("/datadata", file);
|
||||
write_fstab_root("/emmc", file);
|
||||
write_fstab_root("/system", file);
|
||||
write_fstab_root("/sdcard", file);
|
||||
write_fstab_root("/sd-ext", file);
|
||||
|
@ -17,7 +17,10 @@ int
|
||||
do_nandroid_restore();
|
||||
|
||||
void
|
||||
show_nandroid_restore_menu();
|
||||
show_nandroid_restore_menu(const char* path);
|
||||
|
||||
void
|
||||
show_nandroid_advanced_restore_menu(const char* path);
|
||||
|
||||
void
|
||||
show_nandroid_menu();
|
||||
|
16
nandroid.c
16
nandroid.c
@ -228,13 +228,17 @@ int nandroid_backup(const char* backup_path)
|
||||
{
|
||||
ui_set_background(BACKGROUND_ICON_INSTALLING);
|
||||
|
||||
if (ensure_path_mounted("/sdcard") != 0)
|
||||
return print_and_error("Can't mount /sdcard\n");
|
||||
if (ensure_path_mounted(backup_path) != 0) {
|
||||
return print_and_error("Can't mount backup path.\n");
|
||||
}
|
||||
|
||||
Volume* volume = volume_for_path(backup_path);
|
||||
if (NULL == volume)
|
||||
return print_and_error("Unable to find volume for backup path.\n");
|
||||
int ret;
|
||||
struct statfs s;
|
||||
if (0 != (ret = statfs("/sdcard", &s)))
|
||||
return print_and_error("Unable to stat /sdcard\n");
|
||||
if (0 != (ret = statfs(volume->mount_point, &s)))
|
||||
return print_and_error("Unable to stat backup path.\n");
|
||||
uint64_t bavail = s.f_bavail;
|
||||
uint64_t bsize = s.f_bsize;
|
||||
uint64_t sdcard_free = bavail * bsize;
|
||||
@ -513,8 +517,8 @@ int nandroid_restore(const char* backup_path, int restore_boot, int restore_syst
|
||||
ui_show_indeterminate_progress();
|
||||
yaffs_files_total = 0;
|
||||
|
||||
if (ensure_path_mounted("/sdcard") != 0)
|
||||
return print_and_error("Can't mount /sdcard\n");
|
||||
if (ensure_path_mounted(backup_path) != 0)
|
||||
return print_and_error("Can't mount backup path\n");
|
||||
|
||||
char tmp[PATH_MAX];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user