aboutsummaryrefslogtreecommitdiffstats
path: root/flashutils
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2011-04-16 13:45:53 -0700
committerKoushik Dutta <koushd@gmail.com>2011-04-16 13:45:53 -0700
commited7d296dfabd9d0297514518f41ead36130302e7 (patch)
tree6a55f3495f54ebe7b9cbb5b496e7c30c44ff6807 /flashutils
parent3a7dc29b243b747ddff59fa05e87e19b14ceb478 (diff)
downloadbootable_recovery-ed7d296dfabd9d0297514518f41ead36130302e7.zip
bootable_recovery-ed7d296dfabd9d0297514518f41ead36130302e7.tar.gz
bootable_recovery-ed7d296dfabd9d0297514518f41ead36130302e7.tar.bz2
allow precise device detection
Change-Id: Ie837500d459c95df0b1a5f849b3eba718cf8cf09
Diffstat (limited to 'flashutils')
-rw-r--r--flashutils/dump_image.c2
-rw-r--r--flashutils/erase_image.c2
-rw-r--r--flashutils/flash_image.c2
-rw-r--r--flashutils/flashutils.c29
-rw-r--r--flashutils/flashutils.h6
5 files changed, 25 insertions, 16 deletions
diff --git a/flashutils/dump_image.c b/flashutils/dump_image.c
index 4db1f74..64c4e1c 100644
--- a/flashutils/dump_image.c
+++ b/flashutils/dump_image.c
@@ -146,5 +146,5 @@ int main(int argc, char **argv)
return 2;
}
- return backup_raw_partition(argv[1], argv[2]);
+ return backup_raw_partition(NULL, argv[1], argv[2]);
}
diff --git a/flashutils/erase_image.c b/flashutils/erase_image.c
index c495255..b09a424 100644
--- a/flashutils/erase_image.c
+++ b/flashutils/erase_image.c
@@ -99,5 +99,5 @@ int main(int argc, char **argv)
return 2;
}
- return erase_raw_partition(argv[1]);
+ return erase_raw_partition(NULL, argv[1]);
}
diff --git a/flashutils/flash_image.c b/flashutils/flash_image.c
index 3966c42..e9fa570 100644
--- a/flashutils/flash_image.c
+++ b/flashutils/flash_image.c
@@ -147,7 +147,7 @@ int main(int argc, char **argv)
return 2;
}
- int ret = restore_raw_partition(argv[1], argv[2]);
+ int ret = restore_raw_partition(NULL, argv[1], argv[2]);
if (ret != 0)
fprintf(stderr, "failed with error: %d\n", ret);
return ret;
diff --git a/flashutils/flashutils.c b/flashutils/flashutils.c
index 0b1467e..5d906c9 100644
--- a/flashutils/flashutils.c
+++ b/flashutils/flashutils.c
@@ -69,7 +69,7 @@ __system(const char *command)
return (pid == -1 ? -1 : pstat);
}
-static int detect_partition(const char *partition)
+static int detect_partition(const char *partitionType, const char *partition)
{
int type = device_flash_type();
if (strstr(partition, "/dev/block/mtd") != NULL)
@@ -78,12 +78,21 @@ static int detect_partition(const char *partition)
type = MMC;
else if (strstr(partition, "/dev/block/bml") != NULL)
type = BML;
-
+
+ if (partitionType != NULL) {
+ if (strstr(partitionType, "mtd") != NULL)
+ type = MTD;
+ else if (strstr(partitionType, "emmc") != NULL)
+ type = MMC;
+ else if (strstr(partitionType, "bml") != NULL)
+ type = BML;
+ }
+
return type;
}
-int restore_raw_partition(const char *partition, const char *filename)
+int restore_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
- int type = detect_partition(partition);
+ int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_restore_raw_partition(partition, filename);
@@ -96,9 +105,9 @@ int restore_raw_partition(const char *partition, const char *filename)
}
}
-int backup_raw_partition(const char *partition, const char *filename)
+int backup_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
- int type = detect_partition(partition);
+ int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_backup_raw_partition(partition, filename);
@@ -111,9 +120,9 @@ int backup_raw_partition(const char *partition, const char *filename)
}
}
-int erase_raw_partition(const char *partition)
+int erase_raw_partition(const char* partitionType, const char *partition)
{
- int type = detect_partition(partition);
+ int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_raw_partition(partition);
@@ -128,7 +137,7 @@ int erase_raw_partition(const char *partition)
int erase_partition(const char *partition, const char *filesystem)
{
- int type = detect_partition(partition);
+ int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_partition(partition, filesystem);
@@ -143,7 +152,7 @@ int erase_partition(const char *partition, const char *filesystem)
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only)
{
- int type = detect_partition(partition);
+ int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_mount_partition(partition, mount_point, filesystem, read_only);
diff --git a/flashutils/flashutils.h b/flashutils/flashutils.h
index d5dadcb..4c63c67 100644
--- a/flashutils/flashutils.h
+++ b/flashutils/flashutils.h
@@ -1,9 +1,9 @@
#ifndef FLASHUTILS_H
#define FLASHUTILS_H
-int restore_raw_partition(const char *partition, const char *filename);
-int backup_raw_partition(const char *partition, const char *filename);
-int erase_raw_partition(const char *partition);
+int restore_raw_partition(const char* partitionType, const char *partition, const char *filename);
+int backup_raw_partition(const char* partitionType, const char *partition, const char *filename);
+int erase_raw_partition(const char* partitionType, const char *partition);
int erase_partition(const char *partition, const char *filesystem);
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only);
int get_partition_device(const char *partition, char *device);