From 9f52e5f23b0eaf24cb5acd10d3c0c0af4d2c6727 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Sun, 2 Jan 2011 14:11:24 -0800 Subject: [PATCH] fix android secure formatting Change-Id: I617b8c453aad6d306cf8ddbc1a067c59ead56573 --- Android.mk | 2 +- extendedcommands.c | 40 +++++++++++++++++++++------------------- roots.c | 3 +++ 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/Android.mk b/Android.mk index 748f70c..3dac199 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v3.0.0.4 +RECOVERY_VERSION := ClockworkMod Recovery v3.0.0.5 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 f2f1d6c..a96ce27 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -460,26 +460,8 @@ int format_unknown_device(const char *device, const char* path, const char *fs_t // device may simply be a name, like "system" if (device[0] != '/') return erase_partition(device, fs_type); - - if (strcmp("ext3", fs_type) == 0) { - LOGI("Formatting ext3 device.\n"); - if (0 != ensure_path_unmounted(path)) { - LOGE("Error while unmounting %s.\n", path); - return -12; - } - return format_ext3_device(device); - } - - if (strcmp("ext2", fs_type) == 0) { - LOGI("Formatting ext2 device.\n"); - if (0 != ensure_path_unmounted(path)) { - LOGE("Error while unmounting %s.\n", path); - return -12; - } - return format_ext2_device(device); - } - // if this is SDEXT:, don't worry about it. + // if this is SDEXT:, don't worry about it if it does not exist. if (0 == strcmp(path, "/sd-ext")) { struct stat st; @@ -491,6 +473,26 @@ int format_unknown_device(const char *device, const char* path, const char *fs_t } } + if (NULL != fs_type) { + if (strcmp("ext3", fs_type) == 0) { + LOGI("Formatting ext3 device.\n"); + if (0 != ensure_path_unmounted(path)) { + LOGE("Error while unmounting %s.\n", path); + return -12; + } + return format_ext3_device(device); + } + + if (strcmp("ext2", fs_type) == 0) { + LOGI("Formatting ext2 device.\n"); + if (0 != ensure_path_unmounted(path)) { + LOGE("Error while unmounting %s.\n", path); + return -12; + } + return format_ext2_device(device); + } + } + if (0 != ensure_path_mounted(path)) { ui_print("Error mounting %s!\n", path); diff --git a/roots.c b/roots.c index 4f76de5..028fbc4 100644 --- a/roots.c +++ b/roots.c @@ -213,8 +213,11 @@ int format_volume(const char* volume) { return -1; } if (strcmp(v->mount_point, volume) != 0) { +#if 0 LOGE("can't give path \"%s\" to format_volume\n", volume); return -1; +#endif + return format_unknown_device(v->device, volume, NULL); } if (ensure_path_unmounted(volume) != 0) {