aboutsummaryrefslogtreecommitdiffstats
path: root/updater
diff options
context:
space:
mode:
authorKoushik Dutta <koushd@gmail.com>2010-12-18 18:18:44 -0800
committerKoushik Dutta <koushd@gmail.com>2010-12-18 18:18:44 -0800
commit8637c7375792bb773b80266a077a057e257325fe (patch)
tree33d82baf9a433736629724643245bd70c54f8923 /updater
parentdf1e4067821353af7a006ef4d70b7001ad3bd924 (diff)
downloadbootable_recovery-8637c7375792bb773b80266a077a057e257325fe.zip
bootable_recovery-8637c7375792bb773b80266a077a057e257325fe.tar.gz
bootable_recovery-8637c7375792bb773b80266a077a057e257325fe.tar.bz2
revert updater changes except what is necesary to do a write_raw_image on emmc devices.
Change-Id: I674c7b5873b7758bf15f0b55c34ec01513e6f23c
Diffstat (limited to 'updater')
-rw-r--r--updater/install.c55
1 files changed, 43 insertions, 12 deletions
diff --git a/updater/install.c b/updater/install.c
index 478055d..d89aa28 100644
--- a/updater/install.c
+++ b/updater/install.c
@@ -1,6 +1,5 @@
/*
* 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.
@@ -32,10 +31,8 @@
#include "edify/expr.h"
#include "mincrypt/sha.h"
#include "minzip/DirUtil.h"
-#include "mounts.h"
-#include "flashutils/flashutils.h"
+#include "mtdutils/mounts.h"
#include "mtdutils/mtdutils.h"
-#include "mmcutils/mmcutils.h"
#include "updater.h"
#include "applypatch/applypatch.h"
@@ -81,11 +78,23 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) {
mkdir(mount_point, 0755);
- if (strcmp(partition_type, "MTD") == 0 || strcmp(partition_type, "MMC") == 0) {
- if (0 == mount_partition(location, mount_point, get_default_filesystem(), 0))
- result = mount_point;
- else
+ if (strcmp(partition_type, "MTD") == 0) {
+ mtd_scan_partitions();
+ const MtdPartition* mtd;
+ mtd = mtd_find_partition_by_name(location);
+ if (mtd == NULL) {
+ fprintf(stderr, "%s: no mtd partition named \"%s\"",
+ name, location);
result = strdup("");
+ goto done;
+ }
+ if (mtd_mount_partition(mtd, mount_point, fs_type, 0 /* rw */) != 0) {
+ fprintf(stderr, "mtd mount of %s failed: %s\n",
+ location, strerror(errno));
+ result = strdup("");
+ goto done;
+ }
+ result = mount_point;
} else {
if (mount(location, mount_point, fs_type,
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) {
@@ -195,11 +204,33 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) {
goto done;
}
- if (strcmp(partition_type, "MTD") == 0 || strcmp(partition_type, "MMC") == 0) {
- if (0 != erase_partition(location, NULL)) {
+ if (strcmp(partition_type, "MTD") == 0) {
+ mtd_scan_partitions();
+ const MtdPartition* mtd = mtd_find_partition_by_name(location);
+ if (mtd == NULL) {
+ fprintf(stderr, "%s: no mtd partition named \"%s\"",
+ name, location);
+ result = strdup("");
+ goto done;
+ }
+ MtdWriteContext* ctx = mtd_write_partition(mtd);
+ if (ctx == NULL) {
+ fprintf(stderr, "%s: can't write \"%s\"", name, location);
result = strdup("");
goto done;
}
+ if (mtd_erase_blocks(ctx, -1) == -1) {
+ mtd_write_close(ctx);
+ fprintf(stderr, "%s: failed to erase \"%s\"", name, location);
+ result = strdup("");
+ goto done;
+ }
+ if (mtd_write_close(ctx) != 0) {
+ fprintf(stderr, "%s: failed to close \"%s\"", name, location);
+ result = strdup("");
+ goto done;
+ }
+ result = location;
#ifdef USE_EXT4
} else if (strcmp(fs_type, "ext4") == 0) {
reset_ext4fs_info();
@@ -216,7 +247,7 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) {
fprintf(stderr, "%s: unsupported fs_type \"%s\" partition_type \"%s\"",
name, fs_type, partition_type);
}
- result = location;
+
done:
free(fs_type);
free(partition_type);
@@ -652,7 +683,7 @@ Value* WriteRawImageFn(const char* name, State* state, int argc, Expr* argv[]) {
if (0 == restore_raw_partition(partition, filename))
result = strdup(partition);
else
- result = strdup("");
+ result = success ? partition : strdup("");
done:
if (result != partition) free(partition);