diff --git a/Android.mk b/Android.mk index 91f3a66..745473f 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.0 +RECOVERY_VERSION := ClockworkMod Recovery v4.0.0.2 LOCAL_CFLAGS += -DRECOVERY_VERSION="$(RECOVERY_VERSION)" RECOVERY_API_VERSION := 2 LOCAL_CFLAGS += -DRECOVERY_API_VERSION=$(RECOVERY_API_VERSION) diff --git a/extendedcommands.c b/extendedcommands.c index 1f882c5..3f9f8a0 100644 --- a/extendedcommands.c +++ b/extendedcommands.c @@ -1096,7 +1096,11 @@ int bml_check_volume(const char *path) { void process_volumes() { create_fstab(); - + + if (is_data_media()) { + setup_data_media(); + } + return; // dead code. diff --git a/nandroid.c b/nandroid.c index 8cee3be..5a32a76 100644 --- a/nandroid.c +++ b/nandroid.c @@ -139,6 +139,17 @@ static nandroid_backup_handler get_backup_handler(const char *backup_path) { return NULL; } + if (strcmp(backup_path, "/data") == 0 && is_data_media()) { + return tar_compress_wrapper; + } + + char str[255]; + char* partition; + property_get("ro.cwm.prefer_tar", str, "false"); + if (strcmp("true", str) != 0) { + return mkyaffs2image_wrapper; + } + if (strcmp("yaffs2", mv->filesystem) == 0) { return mkyaffs2image_wrapper; } @@ -345,6 +356,17 @@ static nandroid_restore_handler get_restore_handler(const char *backup_path) { return NULL; } + if (strcmp(backup_path, "/data") == 0 && is_data_media()) { + return tar_extract_wrapper; + } + + char str[255]; + char* partition; + property_get("ro.cwm.prefer_tar", str, "false"); + if (strcmp("true", str) != 0) { + return unyaffs_wrapper; + } + if (strcmp("yaffs2", mv->filesystem) == 0) { return unyaffs_wrapper; } diff --git a/recovery.c b/recovery.c index 2e77ec6..c11ea25 100644 --- a/recovery.c +++ b/recovery.c @@ -786,10 +786,6 @@ main(int argc, char **argv) { return busybox_driver(argc, argv); } __system("/sbin/postrecoveryboot.sh"); - if (volume_for_path("/sdcard") == NULL) { - rmdir("/sdcard"); - symlink("/data/media", "/sdcard"); - } int is_user_initiated_recovery = 0; time_t start = time(NULL); diff --git a/roots.c b/roots.c index 49b7729..fa7a5df 100644 --- a/roots.c +++ b/roots.c @@ -164,17 +164,27 @@ int try_mount(const char* device, const char* mount_point, const char* fs_type, return ret; } +int is_data_media() { + Volume *data = volume_for_path("/data"); + return data != NULL && strcmp(data->fs_type, "auto") == 0 && volume_for_path("/sdcard") == NULL; +} + +void setup_data_media() { + rmdir("/sdcard"); + mkdir("/data/media", 0755); + symlink("/data/media", "/sdcard"); +} + int ensure_path_mounted(const char* path) { Volume* v = volume_for_path(path); if (v == NULL) { // no /sdcard? let's assume /data/media - if (strstr(path, "/sdcard") == path) { + if (strstr(path, "/sdcard") == path && is_data_media()) { LOGW("using /data/media, no /sdcard found.\n"); int ret; if (0 != (ret = ensure_path_mounted("/data"))) return ret; - rmdir("/sdcard"); - symlink("/data/media", "/sdcard"); + setup_data_media(); return 0; } LOGE("unknown volume for path [%s]\n", path); @@ -245,7 +255,7 @@ int ensure_path_unmounted(const char* path) { Volume* v = volume_for_path(path); if (v == NULL) { // no /sdcard? let's assume /data/media - if (strstr(path, "/sdcard") == path) { + if (strstr(path, "/sdcard") == path && is_data_media()) { return ensure_path_unmounted("/data"); } LOGE("unknown volume for path [%s]\n", path); diff --git a/roots.h b/roots.h index 7132fed..7914307 100644 --- a/roots.h +++ b/roots.h @@ -42,4 +42,7 @@ int get_num_volumes(); Volume* get_device_volumes(); +int is_data_media(); +void setup_data_media(); + #endif // RECOVERY_ROOTS_H_