1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
|
static int check_backup_size() {
// these are the size stats for backup_path we previously refreshed by calling Get_Size_Via_statfs()
int total_mb = (int)(Total_Size / 1048576LLU);
int used_mb = (int)(Used_Size / 1048576LLU);
int free_mb = (int)(Free_Size / 1048576LLU);
int free_percent = free_mb * 100 / total_mb;
Before_Used_Size = Used_Size; // save Used_Size to refresh data written stats later
Backup_Size = 0;
// backable partitions
static const char* Partitions_List[] = {"/recovery",
"/boot",
"/wimax",
"/modem",
"/radio",
"/efs",
"/misc",
"/system",
"/preload",
"/data",
"/datadata",
"/cache",
"/sd-ext",
NULL
};
int preload_status = 0;
if ((is_custom_backup && backup_preload) || (!is_custom_backup && nandroid_add_preload))
preload_status = 1;
int backup_status[] = {backup_recovery,
backup_boot,
backup_wimax,
backup_modem,
backup_modem,
backup_efs,
backup_misc,
backup_system,
preload_status,
backup_data,
backup_data,
backup_cache,
backup_sdext,
};
// calculate needed space for backup
// assume recovery and wimax always use a raw backup mode (Is_Image() = 0)
char skipped_parts[1024];
sprintf(skipped_parts, "test:");
int ret = 0;
struct statfs s;
Volume* vol;
int i;
for(i=0; Partitions_List[i] != NULL; i++) {
if (!backup_status[i])
continue;
// size of /data will be calculated later for /data/media devices to substract sdcard size from it
LOGI("1-%s\n", Partitions_List[i]); // debug
if (strcmp(Partitions_List[i], "/data") == 0 && is_data_media()) {
LOGI("2-%s\n", Partitions_List[i]); // debug
continue;
}
// redondant but keep for compatibility:
// has_datadata() does a volume_for_path() != NULL check
LOGI("3-%s\n", Partitions_List[i]); // debug
if (strcmp(Partitions_List[i], "/datadata") == 0 && !has_datadata()) {
LOGI("4-%s\n", Partitions_List[i]); // debug
continue;
}
LOGI("5-%s\n", Partitions_List[i]); // debug
vol = volume_for_path(Partitions_List[i]);
LOGI("6-%s\n", Partitions_List[i]); // debug
if (vol == NULL || 0 != stat(vol->device, &s)) continue;
LOGI("6.1-%s\n", Partitions_List[i]); // debug
if (Is_Image(Partitions_List[i]) == 0) {
LOGI("7-%s\n", Partitions_List[i]); // debug
if (Find_Partition_Size(Partitions_List[i]) == 0) {
Backup_Size += Total_Size;
LOGI("%s backup size (/proc)=%lluMb\n", Partitions_List[i], Total_Size / 1048576LLU); // debug
} else {
ret++;
LOGI("8.0-%s - %s\n", Partitions_List[i], skipped_parts); // debug
strcat(skipped_parts, " - ");
LOGI("8.1-%s\n", skipped_parts); // debug
strcat(skipped_parts, Partitions_List[i]);
LOGI("8.2-%s\n", skipped_parts); // debug
}
} else if (Is_File_System(Partitions_List[i]) == 0) {
// Get_Size_Via_statfs() will ensure vol->mount_point != NULL
if (0 == ensure_path_mounted(vol->mount_point) && 0 == Get_Size_Via_statfs(vol->mount_point)) {
Backup_Size += Used_Size;
LOGI("%s backup size (stat)=%lluMb\n", Partitions_List[i], Used_Size / 1048576LLU); // debug
} else {
ret++;
LOGI("9-%s\n", Partitions_List[i]); // debug
strcat(skipped_parts, " - ");
strcat(skipped_parts, Partitions_List[i]);
}
} else {
ret++;
LOGI("10-%s\n", Partitions_List[i]); // debug
strcat(skipped_parts, " - Unknown file system: ");
strcat(skipped_parts, Partitions_List[i]);
}
}
...
|