Merge branch 'gingerbread' of git://github.com/CyanogenMod/android_bootable_recovery into gingerbread

This commit is contained in:
Arif Ali 2011-10-28 01:30:05 +01:00
commit 7691202e89
4 changed files with 59 additions and 21 deletions

View File

@ -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

View File

@ -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;
@ -704,7 +706,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");
@ -783,12 +785,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)
{
@ -811,10 +819,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;
}
}
@ -1039,9 +1071,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);

View 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();

View File

@ -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];