allow precise device detection

Change-Id: Ie837500d459c95df0b1a5f849b3eba718cf8cf09
This commit is contained in:
Koushik Dutta 2011-04-16 13:45:53 -07:00
parent 3a7dc29b24
commit ed7d296dfa
8 changed files with 29 additions and 20 deletions

View File

@ -26,7 +26,7 @@ LOCAL_MODULE := recovery
LOCAL_FORCE_STATIC_EXECUTABLE := true
RECOVERY_VERSION := ClockworkMod Recovery v3.0.2.4
RECOVERY_VERSION := ClockworkMod Recovery v3.0.2.5
LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)"
RECOVERY_API_VERSION := 2
LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION)

View File

@ -421,7 +421,7 @@ int format_unknown_device(const char *device, const char* path, const char *fs_t
// device may simply be a name, like "system"
if (device[0] != '/')
return erase_raw_partition(device);
return erase_raw_partition(fs_type, device);
// if this is SDEXT:, don't worry about it if it does not exist.
if (0 == strcmp(path, "/sd-ext"))

View File

@ -146,5 +146,5 @@ int main(int argc, char **argv)
return 2;
}
return backup_raw_partition(argv[1], argv[2]);
return backup_raw_partition(NULL, argv[1], argv[2]);
}

View File

@ -99,5 +99,5 @@ int main(int argc, char **argv)
return 2;
}
return erase_raw_partition(argv[1]);
return erase_raw_partition(NULL, argv[1]);
}

View File

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

View File

@ -69,7 +69,7 @@ __system(const char *command)
return (pid == -1 ? -1 : pstat);
}
static int detect_partition(const char *partition)
static int detect_partition(const char *partitionType, const char *partition)
{
int type = device_flash_type();
if (strstr(partition, "/dev/block/mtd") != NULL)
@ -78,12 +78,21 @@ static int detect_partition(const char *partition)
type = MMC;
else if (strstr(partition, "/dev/block/bml") != NULL)
type = BML;
if (partitionType != NULL) {
if (strstr(partitionType, "mtd") != NULL)
type = MTD;
else if (strstr(partitionType, "emmc") != NULL)
type = MMC;
else if (strstr(partitionType, "bml") != NULL)
type = BML;
}
return type;
}
int restore_raw_partition(const char *partition, const char *filename)
int restore_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_restore_raw_partition(partition, filename);
@ -96,9 +105,9 @@ int restore_raw_partition(const char *partition, const char *filename)
}
}
int backup_raw_partition(const char *partition, const char *filename)
int backup_raw_partition(const char* partitionType, const char *partition, const char *filename)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_backup_raw_partition(partition, filename);
@ -111,9 +120,9 @@ int backup_raw_partition(const char *partition, const char *filename)
}
}
int erase_raw_partition(const char *partition)
int erase_raw_partition(const char* partitionType, const char *partition)
{
int type = detect_partition(partition);
int type = detect_partition(partitionType, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_raw_partition(partition);
@ -128,7 +137,7 @@ int erase_raw_partition(const char *partition)
int erase_partition(const char *partition, const char *filesystem)
{
int type = detect_partition(partition);
int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_erase_partition(partition, filesystem);
@ -143,7 +152,7 @@ int erase_partition(const char *partition, const char *filesystem)
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only)
{
int type = detect_partition(partition);
int type = detect_partition(NULL, partition);
switch (type) {
case MTD:
return cmd_mtd_mount_partition(partition, mount_point, filesystem, read_only);

View File

@ -1,9 +1,9 @@
#ifndef FLASHUTILS_H
#define FLASHUTILS_H
int restore_raw_partition(const char *partition, const char *filename);
int backup_raw_partition(const char *partition, const char *filename);
int erase_raw_partition(const char *partition);
int restore_raw_partition(const char* partitionType, const char *partition, const char *filename);
int backup_raw_partition(const char* partitionType, const char *partition, const char *filename);
int erase_raw_partition(const char* partitionType, const char *partition);
int erase_partition(const char *partition, const char *filesystem);
int mount_partition(const char *partition, const char *mount_point, const char *filesystem, int read_only);
int get_partition_device(const char *partition, char *device);

View File

@ -115,7 +115,7 @@ int nandroid_backup_partition(const char* backup_path, const char* root) {
const char* name = basename(root);
sprintf(tmp, "%s/%s.img", backup_path, name);
ui_print("Backing up %s image...\n", name);
if (0 != (ret = backup_raw_partition(vol->device, tmp))) {
if (0 != (ret = backup_raw_partition(vol->fs_type, vol->device, tmp))) {
ui_print("Error while backing up %s image!", name);
return ret;
}
@ -294,7 +294,7 @@ int nandroid_restore_partition(const char* backup_path, const char* root) {
}
sprintf(tmp, "%s%s.img", backup_path, root);
ui_print("Restoring %s image...\n", name);
if (0 != (ret = restore_raw_partition(vol->device, tmp))) {
if (0 != (ret = restore_raw_partition(vol->fs_type, vol->device, tmp))) {
ui_print("Error while flashing %s image!", name);
return ret;
}