fix erroneous detection of device flash type when device is explicitly provided. fix bugs in mount generation.

Change-Id: I54a35390550b1384f12c4b12267029d77bef8fa3
diff --git a/Android.mk b/Android.mk
index 44759b6..dc962a0 100644
--- a/Android.mk
+++ b/Android.mk
@@ -26,7 +26,7 @@
 
 LOCAL_FORCE_STATIC_EXECUTABLE := true
 
-RECOVERY_VERSION := ClockworkMod Recovery v3.0.1.4
+RECOVERY_VERSION := ClockworkMod Recovery v3.0.1.9
 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 30b2f3e..717d8d2 100644
--- a/extendedcommands.c
+++ b/extendedcommands.c
@@ -519,7 +519,7 @@
 
 		for (i = 0; i < num_volumes; ++i) {
 			Volume* v = &device_volumes[i];
-			if(strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) != 0)
+			if(strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) != 0 && strcmp("emmc", v->fs_type) != 0 && strcmp("bml", v->fs_type) != 0)
 			{
 				sprintf(&mount_menue[mountable_volumes].mount, "mount %s", v->mount_point);
 				sprintf(&mount_menue[mountable_volumes].unmount, "unmount %s", v->mount_point);
@@ -529,7 +529,7 @@
 				format_menue[formatable_volumes].v = &device_volumes[i];
 				++formatable_volumes;
 		    }
-		    else if (strcmp("ramdisk", v->fs_type) != 0 && strcmp("mtd", v->fs_type) == 0)
+		    else if (strcmp("ramdisk", v->fs_type) != 0 && strcmp("misc", v->mount_point) != 0 && strcmp("mtd", v->fs_type) == 0)
 		    {
 				sprintf(&format_menue[formatable_volumes].txt, "format %s", v->mount_point);
 				format_menue[formatable_volumes].v = &device_volumes[i];
diff --git a/flashutils/flashutils.c b/flashutils/flashutils.c
index b71d4fa..0b1467e 100644
--- a/flashutils/flashutils.c
+++ b/flashutils/flashutils.c
@@ -69,9 +69,21 @@
     return (pid == -1 ? -1 : pstat);
 }
 
-int restore_raw_partition(const char *partition, const char *filename)
+static int detect_partition(const char *partition)
 {
     int type = device_flash_type();
+    if (strstr(partition, "/dev/block/mtd") != NULL)
+        type = MTD;
+    else if (strstr(partition, "/dev/block/mmc") != NULL)
+        type = MMC;
+    else if (strstr(partition, "/dev/block/bml") != NULL)
+        type = BML;
+        
+    return type;
+}
+int restore_raw_partition(const char *partition, const char *filename)
+{
+    int type = detect_partition(partition);
     switch (type) {
         case MTD:
             return cmd_mtd_restore_raw_partition(partition, filename);
@@ -86,7 +98,7 @@
 
 int backup_raw_partition(const char *partition, const char *filename)
 {
-    int type = device_flash_type();
+    int type = detect_partition(partition);
     switch (type) {
         case MTD:
             return cmd_mtd_backup_raw_partition(partition, filename);
@@ -101,7 +113,7 @@
 
 int erase_raw_partition(const char *partition)
 {
-    int type = device_flash_type();
+    int type = detect_partition(partition);
     switch (type) {
         case MTD:
             return cmd_mtd_erase_raw_partition(partition);
@@ -116,7 +128,7 @@
 
 int erase_partition(const char *partition, const char *filesystem)
 {
-    int type = device_flash_type();
+    int type = detect_partition(partition);
     switch (type) {
         case MTD:
             return cmd_mtd_erase_partition(partition, filesystem);
@@ -131,7 +143,7 @@
 
 int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only)
 {
-    int type = device_flash_type();
+    int type = detect_partition(partition);
     switch (type) {
         case MTD:
             return cmd_mtd_mount_partition(partition, mount_point, filesystem, read_only);
diff --git a/mmcutils/mmcutils.c b/mmcutils/mmcutils.c
index fc3de5b..da87567 100644
--- a/mmcutils/mmcutils.c
+++ b/mmcutils/mmcutils.c
@@ -579,18 +579,23 @@
 
 int cmd_mmc_restore_raw_partition(const char *partition, const char *filename)
 {
-    mmc_scan_partitions();
-    const MmcPartition *p;
-    p = mmc_find_partition_by_name(partition);
-    if (p == NULL)
-        return -1;
-    return mmc_raw_copy(p, filename);
+    if (partition[0] != '/') {
+        mmc_scan_partitions();
+        const MmcPartition *p;
+        p = mmc_find_partition_by_name(partition);
+        if (p == NULL)
+            return -1;
+        return mmc_raw_copy(p, filename);
+    }
+    else {
+        return mmc_raw_dump_internal(filename, partition);
+    }
 }
 
 int cmd_mmc_backup_raw_partition(const char *partition, const char *filename)
 {
-    mmc_scan_partitions();
     if (partition[0] != '/') {
+        mmc_scan_partitions();
         const MmcPartition *p;
         p = mmc_find_partition_by_name(partition);
         if (p == NULL)
@@ -604,13 +609,6 @@
 
 int cmd_mmc_erase_raw_partition(const char *partition)
 {
-    mmc_scan_partitions();
-    const MmcPartition *p;
-    p = mmc_find_partition_by_name(partition);
-    if (p == NULL)
-        return -1;
-
-    // TODO: implement raw wipe
     return 0;
 }