summaryrefslogtreecommitdiffstats
path: root/updater/install.c
diff options
context:
space:
mode:
authorDees_Troy <dees_troy@teamw.in>2013-07-01 22:24:01 +0200
committerGerrit Code Review <gerrit@5.9.244.119>2013-07-01 22:24:01 +0200
commit243f9d899c682a7ffbdfd093a796582ff1053e75 (patch)
treedb379dccf61c11e2936d37fe8cb498c1880e1673 /updater/install.c
parentMerge "Fix CFLAGS for Samsung decrypt" into twrp2.5 (diff)
parentFix write_raw_image to work with mmc (diff)
downloadandroid_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar.gz
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar.bz2
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar.lz
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar.xz
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.tar.zst
android_bootable_recovery-243f9d899c682a7ffbdfd093a796582ff1053e75.zip
Diffstat (limited to '')
-rw-r--r--updater/install.c60
1 files changed, 4 insertions, 56 deletions
diff --git a/updater/install.c b/updater/install.c
index f981017bf..c5aa77c49 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -727,66 +727,14 @@ Value* WriteRawImageFn(const char* name, State* state, int argc, Expr* argv[]) {
goto done;
}
- mtd_scan_partitions();
- const MtdPartition* mtd = mtd_find_partition_by_name(partition);
- if (mtd == NULL) {
- fprintf(stderr, "%s: no mtd partition named \"%s\"\n", name, partition);
+ char* filename = contents->data;
+ if (0 == restore_raw_partition(NULL, partition, filename))
+ result = strdup(partition);
+ else {
result = strdup("");
goto done;
}
- MtdWriteContext* ctx = mtd_write_partition(mtd);
- if (ctx == NULL) {
- fprintf(stderr, "%s: can't write mtd partition \"%s\"\n",
- name, partition);
- result = strdup("");
- goto done;
- }
-
- bool success;
-
- if (contents->type == VAL_STRING) {
- // we're given a filename as the contents
- char* filename = contents->data;
- FILE* f = fopen(filename, "rb");
- if (f == NULL) {
- fprintf(stderr, "%s: can't open %s: %s\n",
- name, filename, strerror(errno));
- result = strdup("");
- goto done;
- }
-
- success = true;
- char* buffer = malloc(BUFSIZ);
- int read;
- while (success && (read = fread(buffer, 1, BUFSIZ, f)) > 0) {
- int wrote = mtd_write_data(ctx, buffer, read);
- success = success && (wrote == read);
- }
- free(buffer);
- fclose(f);
- } else {
- // we're given a blob as the contents
- ssize_t wrote = mtd_write_data(ctx, contents->data, contents->size);
- success = (wrote == contents->size);
- }
- if (!success) {
- fprintf(stderr, "mtd_write_data to %s failed: %s\n",
- partition, strerror(errno));
- }
-
- if (mtd_erase_blocks(ctx, -1) == -1) {
- fprintf(stderr, "%s: error erasing blocks of %s\n", name, partition);
- }
- if (mtd_write_close(ctx) != 0) {
- fprintf(stderr, "%s: error closing write of %s\n", name, partition);
- }
-
- printf("%s %s partition\n",
- success ? "wrote" : "failed to write", partition);
-
- result = success ? partition : strdup("");
-
done:
if (result != partition) FreeValue(partition_value);
FreeValue(contents);