From d771acbed0695ef5ec40ac930be200b3393cc8e0 Mon Sep 17 00:00:00 2001 From: Koushik Dutta Date: Thu, 11 Nov 2010 00:00:45 -0800 Subject: [PATCH] Modify apply_patch to fail if trying to patch mtd on non-mtd devices. Change-Id: I09c5bb5d12d838fdc4c4c6eb380021c9b3f3e33e --- Android.mk | 1 + applypatch/applypatch.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/Android.mk b/Android.mk index 817bef8..ce17ff3 100644 --- a/Android.mk +++ b/Android.mk @@ -78,6 +78,7 @@ ifdef BOARD_USES_BMLUTILS else ifdef BOARD_USES_MMCUTILS BOARD_FLASH_LIBRARY := libmmcutils else + LOCAL_CFLAGS += -DBOARD_USES_MTDUTILS BOARD_FLASH_LIBRARY := libmtdutils endif diff --git a/applypatch/applypatch.c b/applypatch/applypatch.c index 99d3661..a0493e0 100644 --- a/applypatch/applypatch.c +++ b/applypatch/applypatch.c @@ -114,6 +114,7 @@ void FreeFileContents(FileContents* file) { // hash of the data, and we'll do the load expecting to find one of // those hashes. int LoadMTDContents(const char* filename, FileContents* file) { +#ifdef BOARD_USES_MTDUTILS char* copy = strdup(filename); const char* magic = strtok(copy, ":"); if (strcmp(magic, "MTD") != 0) { @@ -256,6 +257,10 @@ int LoadMTDContents(const char* filename, FileContents* file) { free(sha1sum); return 0; +#else + printf("mtd utils not supported.\n"); + return -1; +#endif } @@ -296,6 +301,7 @@ int SaveFileContents(const char* filename, FileContents file) { // "MTD:[:...]". Return 0 on success. int WriteToMTDPartition(unsigned char* data, size_t len, const char* target_mtd) { +#ifdef BOARD_USES_MTDUTILS char* partition = strchr(target_mtd, ':'); if (partition == NULL) { printf("bad MTD target name \"%s\"\n", target_mtd); @@ -348,6 +354,11 @@ int WriteToMTDPartition(unsigned char* data, size_t len, free(partition); return 0; +#else + printf("mtd utils not supported.\n"); + return -1; +#endif + }