[recovery]: Add support for OTA upgrade on mmc devices.
Change-Id: I8f230dfa5be4e9f142765797d949e10434e1fdeb
diff --git a/updater/install.c b/updater/install.c
index 5117706..000b525 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 The Android Open Source Project
+ * Copyright (c) 2010, Code Aurora Forum. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +34,7 @@
#include "minzip/DirUtil.h"
#include "mtdutils/mounts.h"
#include "mtdutils/mtdutils.h"
+#include "mmcutils/mmcutils.h"
#include "updater.h"
#include "applypatch/applypatch.h"
@@ -84,6 +86,23 @@
goto done;
}
result = mount_point;
+ } else if (strcmp(type, "MMC") == 0) {
+ mmc_scan_partitions();
+ const MmcPartition* mmc;
+ mmc = mmc_find_partition_by_name(location);
+ if (mmc == NULL) {
+ fprintf(stderr, "%s: no mmc partition named \"%s\"",
+ name, location);
+ result = strdup("");
+ goto done;
+ }
+ if (mmc_mount_partition(mmc, mount_point, 0 /* rw */) != 0) {
+ fprintf(stderr, "mmc mount of %s failed: %s\n",
+ location, strerror(errno));
+ result = strdup("");
+ goto done;
+ }
+ result = mount_point;
} else {
if (mount(location, mount_point, type,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) {
@@ -211,11 +230,24 @@
result = strdup("");
goto done;
}
- result = location;
+ } else if (strcmp(type, "MMC") == 0) {
+ mmc_scan_partitions();
+ const MmcPartition* mmc = mmc_find_partition_by_name(location);
+ if (mmc == NULL) {
+ fprintf(stderr, "%s: no mmc partition named \"%s\"",
+ name, location);
+ result = strdup("");
+ goto done;
+ }
+ if (mmc_format_ext3(mmc))
+ {
+ result = strdup("");
+ goto done;
+ }
} else {
fprintf(stderr, "%s: unsupported type \"%s\"", name, type);
}
-
+ result = location;
done:
free(type);
if (result != location) free(location);
@@ -660,7 +692,7 @@
if (mtd == NULL) {
fprintf(stderr, "%s: no mtd partition named \"%s\"\n", name, partition);
result = strdup("");
- goto done;
+ goto MMC;
}
MtdWriteContext* ctx = mtd_write_partition(mtd);
@@ -706,6 +738,22 @@
success ? "wrote" : "failed to write", partition, filename);
result = success ? partition : strdup("");
+ goto done;
+
+MMC:
+ mmc_scan_partitions();
+ const MmcPartition* mmc = mmc_find_partition_by_name(partition);
+ if (mmc == NULL) {
+ fprintf(stderr, "%s: no mmc partition named \"%s\"\n", name, partition);
+ result = strdup("");
+ goto done;
+ }
+ if (mmc_raw_copy(mmc, filename)) {
+ fprintf(stderr, "%s: error erasing mmc partition named \"%s\"\n", name, partition);
+ result = strdup("");
+ goto done;
+ }
+ result = partition;
#endif
done: