diff --git a/Android.mk b/Android.mk index 2e0ffc6..2fe241a 100644 --- a/Android.mk +++ b/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := recovery LOCAL_FORCE_STATIC_EXECUTABLE := true -RECOVERY_VERSION := ClockworkMod Recovery v4.0.0.2 +RECOVERY_VERSION := ClockworkMod Recovery v4.0.0.4 LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/nandroid.c b/nandroid.c index 5a32a76..ae10ca8 100644 --- a/nandroid.c +++ b/nandroid.c @@ -98,13 +98,13 @@ static void compute_directory_stats(const char* directory) } typedef void (*file_event_callback)(const char* filename); -typedef int (*nandroid_backup_handler)(const char* backup_path, const char* backup_file_image, const file_event_callback callback); +typedef int (*nandroid_backup_handler)(const char* backup_path, const char* backup_file_image, int callback); -static int mkyaffs2image_wrapper(const char* backup_path, const char* backup_file_image, const file_event_callback callback) { +static int mkyaffs2image_wrapper(const char* backup_path, const char* backup_file_image, int callback) { return mkyaffs2image(backup_path, backup_file_image, 0, callback); } -static int tar_compress_wrapper(const char* backup_path, const char* backup_file_image, const file_event_callback callback) { +static int tar_compress_wrapper(const char* backup_path, const char* backup_file_image, int callback) { char tmp[PATH_MAX]; if (strcmp(backup_path, "/data") == 0 && volume_for_path("/sdcard") == NULL) sprintf(tmp, "cd $(dirname %s) ; tar cvf %s --exclude 'media' $(basename %s) ; exit $?", backup_path, backup_file_image, backup_path); @@ -119,7 +119,7 @@ static int tar_compress_wrapper(const char* backup_path, const char* backup_file while (fgets(tmp, PATH_MAX, fp) != NULL) { tmp[PATH_MAX - 1] = NULL; - if (NULL != callback) + if (callback) yaffs_callback(tmp); } @@ -163,10 +163,7 @@ int nandroid_backup_partition_extended(const char* backup_path, const char* moun char* name = basename(mount_point); struct stat file_info; - file_event_callback callback = NULL; - if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) { - callback = yaffs_callback; - } + int callback = stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info) == 0; ui_print("Backing up %s...\n", name); if (0 != (ret = ensure_path_mounted(mount_point) != 0)) { @@ -318,13 +315,13 @@ static void ensure_directory(const char* dir) { __system(tmp); } -typedef int (*nandroid_restore_handler)(const char* backup_file_image, const char* backup_path, file_event_callback callback); +typedef int (*nandroid_restore_handler)(const char* backup_file_image, const char* backup_path, int callback); -static int unyaffs_wrapper(const char* backup_file_image, const char* backup_path, file_event_callback callback) { +static int unyaffs_wrapper(const char* backup_file_image, const char* backup_path, int callback) { return unyaffs(backup_file_image, backup_path, callback); } -static int tar_extract_wrapper(const char* backup_file_image, const char* backup_path, file_event_callback callback) { +static int tar_extract_wrapper(const char* backup_file_image, const char* backup_path, int callback) { char tmp[PATH_MAX]; sprintf(tmp, "cd $(dirname %s) ; tar xvf %s ; exit $?", backup_path, backup_file_image); @@ -336,8 +333,8 @@ static int tar_extract_wrapper(const char* backup_file_image, const char* backup } while (fgets(path, PATH_MAX, fp) != NULL) { - if (NULL != callback) - callback(path); + if (callback) + yaffs_callback(path); } return __pclose(fp); @@ -388,10 +385,7 @@ int nandroid_restore_partition_extended(const char* backup_path, const char* mou ensure_directory(mount_point); - file_event_callback callback = NULL; - if (0 != stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info)) { - callback = yaffs_callback; - } + int callback = stat("/sdcard/clockworkmod/.hidenandroidprogress", &file_info) == 0; ui_print("Restoring %s...\n", name); /* diff --git a/roots.c b/roots.c index fa7a5df..527fc59 100644 --- a/roots.c +++ b/roots.c @@ -286,6 +286,10 @@ int ensure_path_unmounted(const char* path) { int format_volume(const char* volume) { Volume* v = volume_for_path(volume); if (v == NULL) { + // no /sdcard? let's assume /data/media + if (strstr(volume, "/sdcard") == volume && is_data_media()) { + return format_unknown_device(NULL, volume, NULL); + } // silent failure for sd-ext if (strcmp(volume, "/sd-ext") == 0) return -1;