fix up bmlutils some more

Change-Id: Ia11e917a6c0dc8164d599e02154f9f7b2934ed65
This commit is contained in:
Koushik Dutta 2010-12-12 16:54:41 -08:00
parent 03a4f5ba0d
commit 134ead7537
3 changed files with 27 additions and 11 deletions

View File

@ -39,7 +39,7 @@ LOCAL_MODULE := recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true
RECOVERY_VERSION := ClockworkMod Recovery v2.5.1.5
RECOVERY_VERSION := ClockworkMod Recovery v2.5.1.8
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)

View File

@ -23,14 +23,8 @@
extern int __system(const char *command);
#define BML_UNLOCK_ALL 0x8A29 ///< unlock all partition RO -> RW
int cmd_bml_restore_raw_partition(const char *partition, const char *filename)
static int restore_internal(const char* bml, const char* filename)
{
char *bml;
if (strcmp(partition, "boot") == 0 || strcmp(partition, "recovery") == 0)
bml = "/dev/block/bml7";
else
return 6;
char buf[4096];
int dstfd, srcfd, bytes_read, bytes_written, total_read = 0;
if (filename == NULL)
@ -54,14 +48,33 @@ int cmd_bml_restore_raw_partition(const char *partition, const char *filename)
if (write(dstfd, buf, 4096) < 4096)
return 5;
} while(bytes_read == 4096);
close(dstfd);
close(srcfd);
return 0;
}
int cmd_bml_restore_raw_partition(const char *partition, const char *filename)
{
char *bml;
if (strcmp(partition, "boot") == 0 || strcmp(partition, "recovery") == 0)
bml = "/dev/block/bml7";
else
return 6;
int ret = restore_internal("/dev/block/bml7", filename);
if (ret != 0)
return ret;
ret = restore_internal("/dev/block/bml8", filename);
return ret;
}
int cmd_bml_backup_raw_partition(const char *partition, const char *filename)
{
char tmp[PATH_MAX];
sprintf("dd of=%s if=/dev/block/bml7 bs=4096", filename);
sprintf(tmp, "dd of=%s if=/dev/block/bml7 bs=4096", filename);
return __system(tmp);
}

View File

@ -147,5 +147,8 @@ int main(int argc, char **argv)
return 2;
}
return restore_raw_partition(argv[1], argv[2]);
int ret = restore_raw_partition(argv[1], argv[2]);
if (ret != 0)
fprintf(stderr, "failed with error: %d\n", ret);
return ret;
}