From 6771aca715e719e7503926fa3f45b53a741f9c11 Mon Sep 17 00:00:00 2001 From: "Koushik K. Dutta" Date: Sat, 3 Apr 2010 23:28:39 -0700 Subject: [PATCH] copy extended command and run it, rather than load and delete. --- Android.mk | 2 +- extendedcommands.c | 13 ++++++++----- nandroid.c | 11 +++++++++-- recovery.c | 1 + 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Android.mk b/Android.mk index a40b25d..5e8438a 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v1.8.0.5 +RECOVERY_VERSION := ClockworkMod Recovery v1.8.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 fc0eb89..d157fc4 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -569,7 +569,7 @@ int run_script_from_buffer(char* script_data, int script_len, char* filename) return 0; } -int run_script(char* filename, int delete_file) +int run_script(char* filename) { struct stat file_info; if (0 != stat(filename, &file_info)) { @@ -584,8 +584,6 @@ int run_script(char* filename, int delete_file) // supposedly not necessary, but let's be safe. script_data[script_len] = '\0'; fclose(file); - if (delete_file) - remove(filename); int ret = run_script_from_buffer(script_data, script_len, filename); free(script_data); @@ -595,6 +593,10 @@ int run_script(char* filename, int delete_file) int run_and_remove_extendedcommand() { __system("touch /tmp/.installscript"); + char tmp[PATH_MAX]; + sprintf(tmp, "cp %s /tmp/%s", EXTENDEDCOMMAND_SCRIPT, basename(EXTENDEDCOMMAND_SCRIPT)); + __system(tmp); + remove(EXTENDEDCOMMAND_SCRIPT); int i = 0; for (i = 20; i > 0; i--) { ui_print("Waiting for SD Card to mount (%ds)\n", i); @@ -608,7 +610,8 @@ int run_and_remove_extendedcommand() ui_print("Timed out waiting for SD card... continuing anyways."); } - return run_script(EXTENDEDCOMMAND_SCRIPT, 1); + sprintf(tmp, "/tmp/%s", basename(EXTENDEDCOMMAND_SCRIPT)); + return run_script(tmp); } int amend_main(int argc, char** argv) @@ -623,7 +626,7 @@ int amend_main(int argc, char** argv) if (register_update_commands(&ctx)) { LOGE("Can't install update commands\n"); } - return run_script(argv[1], 0); + return run_script(argv[1]); } void show_nandroid_advanced_restore_menu() diff --git a/nandroid.c b/nandroid.c index 8772ed0..8485f47 100644 --- a/nandroid.c +++ b/nandroid.c @@ -144,9 +144,16 @@ int nandroid_backup(char* backup_path) struct stat st; if (0 != stat("/dev/block/mmcblk0p2", &st)) + { ui_print("No sd-ext found. Skipping backup of sd-ext.\n"); - else if (0 != (ret = ensure_root_path_mounted("SDEXT:")) || 0 != (ret = nandroid_backup_partition(backup_path, "SDEXT:"))) - return ret; + } + else + { + if (0 != ensure_root_path_mounted("SDEXT:")) + ui_print("Could not mount sd-ext. sd-ext backup may not be supported on this device. Skipping backup of sd-ext."); + else if (0 != (ret = nandroid_backup_partition(backup_path, "SDEXT:"))) + return ret; + } ui_print("Generating md5 sum...\n"); sprintf(tmp, "nandroid-md5.sh %s", backup_path); diff --git a/recovery.c b/recovery.c index ef1aff4..5743bd3 100644 --- a/recovery.c +++ b/recovery.c @@ -541,6 +541,7 @@ main(int argc, char **argv) if (wipe_cache && erase_root("CACHE:")) status = INSTALL_ERROR; if (status != INSTALL_SUCCESS) ui_print("Cache wipe failed.\n"); } else { + LOGI("Running extendedcommand...\n"); status = INSTALL_ERROR; // No command specified // we are starting up in user initiated recovery here // let's set up some default options