diff --git a/bmlutils/Android.mk b/bmlutils/Android.mk index 38da88c..87f71eb 100644 --- a/bmlutils/Android.mk +++ b/bmlutils/Android.mk @@ -8,11 +8,4 @@ LOCAL_SRC_FILES := bmlutils.c LOCAL_MODULE := libbmlutils include $(BUILD_STATIC_LIBRARY) -include $(CLEAR_VARS) -LOCAL_MODULE := redbend_ua -LOCAL_MODULE_CLASS := RECOVERY_EXECUTABLES -LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/sbin -LOCAL_SRC_FILES := $(LOCAL_MODULE) -include $(BUILD_PREBUILT) - endif \ No newline at end of file diff --git a/bmlutils/redbend_ua b/bmlutils/redbend_ua deleted file mode 100644 index 61040c6..0000000 Binary files a/bmlutils/redbend_ua and /dev/null differ diff --git a/updater/Android.mk b/updater/Android.mk index cbe98a1..ae90211 100644 --- a/updater/Android.mk +++ b/updater/Android.mk @@ -4,6 +4,7 @@ LOCAL_PATH := $(call my-dir) updater_src_files := \ install.c \ + ../mounts.c \ updater.c # @@ -18,13 +19,10 @@ LOCAL_MODULE_TAGS := eng LOCAL_SRC_FILES := $(updater_src_files) -ifdef BOARD_USES_BMLUTILS - LOCAL_CFLAGS += -DBOARD_USES_BMLUTILS - LOCAL_STATIC_LIBRARIES += libbmlutils -endif +LOCAL_STATIC_LIBRARIES += $(BOARD_FLASH_LIBRARY) LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) -LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libmmcutils libminzip libz +LOCAL_STATIC_LIBRARIES += libapplypatch libedify libminzip libz LOCAL_STATIC_LIBRARIES += libmincrypt libbz LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. diff --git a/updater/install.c b/updater/install.c index 82cddb1..c71781a 100644 --- a/updater/install.c +++ b/updater/install.c @@ -32,12 +32,18 @@ #include "edify/expr.h" #include "mincrypt/sha.h" #include "minzip/DirUtil.h" -#include "mtdutils/mounts.h" +#include "mounts.h" #include "mtdutils/mtdutils.h" #include "mmcutils/mmcutils.h" #include "updater.h" #include "applypatch/applypatch.h" +#ifndef BOARD_USES_MMCUTILS +#define DEFAULT_FILESYSTEM "yaffs2" +#else +#define DEFAULT_FILESYSTEM "ext3" +#endif + // mount(type, location, mount_point) // // what: type="MTD" location="" to mount a yaffs2 filesystem @@ -69,40 +75,11 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { mkdir(mount_point, 0755); - if (strcmp(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); + if (strcmp(type, "MTD") == 0 || strcmp(type, "MMC") == 0) { + if (0 == mount_partition(location, mount_point, DEFAULT_FILESYSTEM, 0)) + result = mount_point; + else result = strdup(""); - goto done; - } - if (mtd_mount_partition(mtd, mount_point, "yaffs2", 0 /* rw */) != 0) { - fprintf(stderr, "mtd mount of %s failed: %s\n", - location, strerror(errno)); - result = strdup(""); - 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) { @@ -204,43 +181,8 @@ Value* FormatFn(const char* name, State* state, int argc, Expr* argv[]) { goto done; } - if (strcmp(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; - } - } 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)) - { + if (strcmp(type, "MTD") == 0 || strcmp(type, "MMC") == 0) { + if (0 != erase_partition(location, NULL)) { result = strdup(""); goto done; } @@ -679,80 +621,10 @@ Value* WriteRawImageFn(const char* name, State* state, int argc, Expr* argv[]) { goto done; } -#ifdef BOARD_USES_BMLUTILS - if (0 == write_raw_image(name, filename)) { - result = partition; - } - result = strdup("Failure"); -#else - 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); + if (0 == restore_raw_partition(partition, filename)) + result = strdup(partition); + else result = strdup(""); - goto MMC; - } - - 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; - - 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); - if (!success) { - fprintf(stderr, "mtd_write_data to %s failed: %s\n", - partition, strerror(errno)); - } - } - free(buffer); - fclose(f); - - 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 from %s\n", - 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: if (result != partition) free(partition);