make tar backups opt in.

Change-Id: Ib01131f3a65ce4114e73abe2c7ba42263d281844
This commit is contained in:
Koushik Dutta 2011-06-10 09:45:52 -07:00
parent 94caefedb7
commit 38a921435a
4 changed files with 42 additions and 7 deletions

View File

@ -1105,9 +1105,9 @@ int bml_check_volume(const char *path) {
void process_volumes() {
create_fstab();
if (volume_for_path("/sdcard") == NULL) {
rmdir("/sdcard");
symlink("/data/media", "/sdcard");
if (is_data_media()) {
setup_data_media();
}
return;

View File

@ -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;
}

18
roots.c
View File

@ -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);

View File

@ -42,4 +42,7 @@ int get_num_volumes();
Volume* get_device_volumes();
int is_data_media();
void setup_data_media();
#endif // RECOVERY_ROOTS_H_