From 9ad8ba21b31cebc66dccdd341798357f54c64b87 Mon Sep 17 00:00:00 2001 From: Brandon Bennett Date: Sat, 7 May 2011 23:42:58 -0600 Subject: [PATCH 1/2] Allow per device unsafe-to-format partition list The change switches is_safe_to_format() from a hard coded list to a list that can be overwritten by system property. Change-Id: Ie536044a912c3e88462831851d288a60fdc30e2b --- extendedcommands.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index e5daa5a..2e3fa51 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -490,8 +490,19 @@ typedef struct { int is_safe_to_format(char* name) { - return !(strcmp(name, "/misc") == 0 || strcmp(name, "/radio") == 0 - || strcmp(name, "/bootloader") == 0 || strcmp(name, "/recovery") == 0); + char str[255]; + char* partition; + property_get("ro.recovery.format_ignore_partitions", str, "/misc,/radio,/bootloader,/recovery"); + + partition = strtok(str, ", "); + while (partition != NULL) { + if (strcmp(name, partition) == 0) { + return 0; + } + partition = strtok(NULL, ", "); + } + + return 1; } void show_partition_menu() From 49553c75612acf2e0c8731d9d9eff26dc0f18a19 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Fri, 13 May 2011 13:01:26 -0700 Subject: [PATCH 2/2] Do not close the zip archive prematurely. It may be accessed later for a firmware update. Change-Id: I31c298f75bbcdc7998221aa2b3aa334926343139 --- install.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/install.c b/install.c index ad2c21d..8194c35 100644 --- a/install.c +++ b/install.c @@ -127,10 +127,10 @@ try_update_binary(const char *path, ZipArchive *zip) { } bool ok = mzExtractZipEntryToFile(zip, binary_entry, fd); close(fd); - mzCloseZipArchive(zip); if (!ok) { LOGE("Can't copy %s\n", ASSUMED_UPDATE_BINARY_NAME); + mzCloseZipArchive(zip); return 1; } @@ -239,13 +239,13 @@ try_update_binary(const char *path, ZipArchive *zip) { waitpid(pid, &status, 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { LOGE("Error in %s\n(Status %d)\n", path, WEXITSTATUS(status)); + mzCloseZipArchive(zip); return INSTALL_ERROR; } if (firmware_type != NULL) { + mzCloseZipArchive(zip); return handle_firmware_update(firmware_type, firmware_filename, zip); - } else { - return INSTALL_SUCCESS; } return INSTALL_SUCCESS; }