From 598cfc7e9d98a0f3572598b68ad27107831f19cf Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sun, 20 Jun 2010 09:42:47 -0700 Subject: [PATCH] Remove any references to mmcblk0. Add recovery.log failure hook into ROM Manager. --- Android.mk | 2 +- extendedcommands.c | 25 +++++++++++++++++++++++-- nandroid.c | 2 +- recovery.c | 6 +++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Android.mk b/Android.mk index 78f24b5..6903494 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v2.0.0.4 +RECOVERY_VERSION := ClockworkMod Recovery v2.0.0.6 LOCAL_CFLAGS := -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/extendedcommands.c b/extendedcommands.c index d4e20fd..ff6bb88 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -365,7 +365,9 @@ void show_nandroid_restore_menu() void show_mount_usb_storage_menu() { - __system("echo /dev/block/mmcblk0 > /sys/devices/platform/usb_mass_storage/lun0/file"); + char command[PATH_MAX]; + sprintf(command, "echo %s > /sys/devices/platform/usb_mass_storage/lun0/file", SDCARD_DEVICE_PRIMARY); + __system(command); static char* headers[] = { "USB Mass Storage device", "Leaving this menu unmount", "your SD card from your PC.", @@ -417,7 +419,7 @@ int format_non_mtd_device(const char* root) if (0 == strcmp(root, "SDEXT:")) { struct stat st; - if (0 != stat("/dev/block/mmcblk0p2", &st)) + if (0 != stat(SDEXT_DEVICE, &st)) { ui_print("No app2sd partition found. Skipping format of /sd-ext.\n"); return 0; @@ -753,6 +755,7 @@ void show_advanced_menu() static char* list[] = { "Reboot Recovery", "Wipe Battery Stats", + "Report Error", "Key Test", NULL }; @@ -771,6 +774,9 @@ void show_advanced_menu() wipe_battery_stats(); break; case 2: + handle_failure(1); + break; + case 3: { ui_print("Outputting key codes.\n"); ui_print("Go back to end debugging.\n"); @@ -791,6 +797,8 @@ void show_advanced_menu() void write_fstab_root(char *root_path, FILE *file) { RootInfo *info = get_root_info_for_path(root_path); + if (info == NULL) + return; MtdPartition *mtd = get_root_mtd_partition(root_path); if (mtd != NULL) { @@ -808,10 +816,23 @@ void write_fstab_root(char *root_path, FILE *file) void create_fstab() { FILE *file = fopen("/etc/fstab", "w"); + if (file == NULL) + return; write_fstab_root("CACHE:", file); write_fstab_root("DATA:", file); write_fstab_root("SYSTEM:", file); write_fstab_root("SDCARD:", file); write_fstab_root("SDEXT:", file); fclose(file); +} + +void handle_failure(int ret) +{ + if (ret == 0) + return; + if (0 != ensure_root_path_mounted("SDCARD:")) + return; + mkdir("/sdcard/clockworkmod"); + copyfile("/tmp/recovery.log", "/sdcard/clockworkmod/recovery.log"); + ui_print("/tmp/recovery.log was copied to /sdcard/clockworkmod/recovery.log. Please open ROM Manager to report the issue."); } \ No newline at end of file diff --git a/nandroid.c b/nandroid.c index e9234da..7d7aad9 100644 --- a/nandroid.c +++ b/nandroid.c @@ -154,7 +154,7 @@ int nandroid_backup(const char* backup_path) return ret; struct stat st; - if (0 != stat("/dev/block/mmcblk0p2", &st)) + if (0 == stat(SDEXT_DEVICE, &st)) { ui_print("No sd-ext found. Skipping backup of sd-ext.\n"); } diff --git a/recovery.c b/recovery.c index 4a513b4..cf8560d 100644 --- a/recovery.c +++ b/recovery.c @@ -567,10 +567,14 @@ main(int argc, char **argv) if (extendedcommand_file_exists()) { LOGI("Running extendedcommand...\n"); - if (0 == run_and_remove_extendedcommand()) { + int ret; + if (0 == (ret = run_and_remove_extendedcommand())) { status = INSTALL_SUCCESS; ui_set_show_text(0); } + else { + handle_failure(ret); + } } else { LOGI("Skipping execution of extendedcommand, file not found...\n"); }