From 357a2f51097cef529ae53d5609aebfbbe3d0c1b3 Mon Sep 17 00:00:00 2001 From: Prashant Somashekar Date: Sat, 26 Nov 2011 09:53:41 -0500 Subject: [PATCH 1/2] extendedcommands/nandroid: remove internal options if no sdcard and is_data_media -force /data as backup_path if volume for /sdcard is null and the same is true Change-Id: I927b723cde5b519d81402c6d841f2424627253e8 Conflicts: nandroid.c --- extendedcommands.c | 2 +- nandroid.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/extendedcommands.c b/extendedcommands.c index e6d87e9..44e7117 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -825,7 +825,7 @@ void show_nandroid_menu() NULL }; - if (volume_for_path("/emmc") == NULL) + if (volume_for_path("/emmc") == NULL || volume_for_path("/sdcard") == NULL && is_data_media()) list[3] = NULL; int chosen_item = get_menu_selection(headers, list, 0, 0); diff --git a/nandroid.c b/nandroid.c index 56c633d..ad44ae6 100644 --- a/nandroid.c +++ b/nandroid.c @@ -233,6 +233,12 @@ int nandroid_backup(const char* backup_path) } Volume* volume = volume_for_path(backup_path); + if (NULL == volume) { + if (strstr(backup_path, "/sdcard") == backup_path && is_data_media()) + volume = volume_for_path("/data"); + else + return print_and_error("Unable to find volume for backup path.\n"); + } int ret; struct statfs s; if (NULL != volume) { From f0c389ddcdf3f48c2190b87aa17e2584e6512d31 Mon Sep 17 00:00:00 2001 From: Prashant Somashekar Date: Sat, 26 Nov 2011 13:55:00 -0500 Subject: [PATCH 2/2] nandroid/root/extendedcommands: attenuate for /data not being auto in fstab Change-Id: I0e7bec03bb29f1ae72f23321f89cf704e54ff4d9 --- extendedcommands.c | 3 +++ nandroid.c | 8 ++++++-- roots.c | 5 ++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/extendedcommands.c b/extendedcommands.c index 44e7117..729778c 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -453,6 +453,9 @@ int format_device(const char *device, const char *path, const char *fs_type) { LOGE("unknown volume \"%s\"\n", path); return -1; } + if (strstr(path, "/data") == path && volume_for_path("/sdcard") == NULL && is_data_media()) { + return format_unknown_device(NULL, path, NULL); + } if (strcmp(fs_type, "ramdisk") == 0) { // you can't format the ramdisk. LOGE("can't format_volume \"%s\"", path); diff --git a/nandroid.c b/nandroid.c index ad44ae6..76d0962 100644 --- a/nandroid.c +++ b/nandroid.c @@ -436,8 +436,10 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* mou printf("Found new backup image: %s\n", tmp); } - // If the fs_type of this volume is "auto", let's revert to using a - // rm -rf, rather than trying to do a ext3/ext4/whatever format. + // If the fs_type of this volume is "auto" or mount_point is /data + // and vol for /sdcard is NULL and is_data_media, let's revert + // to using a rm -rf, rather than trying to do a + // ext3/ext4/whatever format. // This is because some phones (like DroidX) will freak out if you // reformat the /system or /data partitions, and not boot due to // a locked bootloader. @@ -449,6 +451,8 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* mou // Or of volume does not exist (.android_secure), just rm -rf. if (vol == NULL || 0 == strcmp(vol->fs_type, "auto")) backup_filesystem = NULL; + else if (0 == strcmp(vol->mount_point, "/data") && volume_for_path("/sdcard") == NULL && is_data_media()) + backup_filesystem = NULL; } ensure_directory(mount_point); diff --git a/roots.c b/roots.c index 4835ce8..4997350 100644 --- a/roots.c +++ b/roots.c @@ -197,7 +197,7 @@ int try_mount(const char* device, const char* mount_point, const char* fs_type, int is_data_media() { Volume *data = volume_for_path("/data"); - return data != NULL && strcmp(data->fs_type, "auto") == 0 && volume_for_path("/sdcard") == NULL; + return data != NULL && strcmp(data->fs_type, "auto") == 0 || volume_for_path("/sdcard") == NULL; } void setup_data_media() { @@ -334,6 +334,9 @@ int format_volume(const char* volume) { LOGE("unknown volume \"%s\"\n", volume); return -1; } + if (strstr(volume, "/data") == volume && volume_for_path("/sdcard") == NULL && is_data_media()) { + return format_unknown_device(NULL, volume, NULL); + } if (strcmp(v->fs_type, "ramdisk") == 0) { // you can't format the ramdisk. LOGE("can't format_volume \"%s\"", volume);