Use raw partition functions for emmc
Change-Id: Ia5d9f18d43228a08f12633d432b299def8e26ae1
diff --git a/mmcutils/mmcutils.c b/mmcutils/mmcutils.c
index 7e283ef..e0efe55 100644
--- a/mmcutils/mmcutils.c
+++ b/mmcutils/mmcutils.c
@@ -278,9 +278,30 @@
return g_mmc_state.partition_count;
}
+static const MmcPartition *
+mmc_find_partition_by_device_index(const char *device_index)
+{
+ if (g_mmc_state.partitions != NULL) {
+ int i;
+ for (i = 0; i < g_mmc_state.partitions_allocd; i++) {
+ MmcPartition *p = &g_mmc_state.partitions[i];
+ if (p->device_index !=NULL && p->name != NULL) {
+ if (strcmp(p->device_index, device_index) == 0) {
+ return p;
+ }
+ }
+ }
+ }
+ return NULL;
+}
+
const MmcPartition *
mmc_find_partition_by_name(const char *name)
{
+ if (name[0] == '/') {
+ return mmc_find_partition_by_device_index(name);
+ }
+
if (g_mmc_state.partitions != NULL) {
int i;
for (i = 0; i < g_mmc_state.partitions_allocd; i++) {
diff --git a/nandroid.c b/nandroid.c
index 7afdc81..45417fb 100644
--- a/nandroid.c
+++ b/nandroid.c
@@ -109,7 +109,8 @@
// see if we need a raw backup (mtd)
char tmp[PATH_MAX];
int ret;
- if (strcmp(vol->fs_type, "mtd") == 0) {
+ if (strcmp(vol->fs_type, "mtd") == 0 ||
+ strcmp(vol->fs_type, "emmc") == 0) {
const char* name = basename(root);
sprintf(tmp, "%s/%s.img", backup_path, name);
ui_print("Backing up %s image...\n", name);
@@ -280,7 +281,8 @@
// see if we need a raw restore (mtd)
char tmp[PATH_MAX];
- if (strcmp(vol->fs_type, "mtd") == 0) {
+ if (strcmp(vol->fs_type, "mtd") == 0 ||
+ strcmp(vol->fs_type, "emmc") == 0) {
int ret;
const char* name = basename(root);
ui_print("Erasing %s before restore...\n", name);
diff --git a/roots.c b/roots.c
index 028fbc4..d4c0033 100644
--- a/roots.c
+++ b/roots.c
@@ -248,6 +248,10 @@
return 0;
}
+ if (strcmp(v->fs_type, "emmc") == 0) {
+ return erase_raw_partition(v->device);
+ }
+
if (strcmp(v->fs_type, "ext4") == 0) {
reset_ext4fs_info();
int result = make_ext4fs(v->device, NULL, NULL, 0, 0, 0);