summaryrefslogtreecommitdiffstats
path: root/tools/idevicebackup2.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/idevicebackup2.c')
-rw-r--r--tools/idevicebackup2.c66
1 files changed, 33 insertions, 33 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c
index b0f9d55..4b7e79e 100644
--- a/tools/idevicebackup2.c
+++ b/tools/idevicebackup2.c
@@ -253,8 +253,8 @@ static plist_t mobilebackup_factory_info_plist_new()
253 /* gather data from lockdown */ 253 /* gather data from lockdown */
254 plist_t value_node = NULL; 254 plist_t value_node = NULL;
255 plist_t root_node = NULL; 255 plist_t root_node = NULL;
256 char *uuid = NULL; 256 char *udid = NULL;
257 char *uuid_uppercase = NULL; 257 char *udid_uppercase = NULL;
258 258
259 plist_t ret = plist_new_dict(); 259 plist_t ret = plist_new_dict();
260 260
@@ -299,16 +299,16 @@ static plist_t mobilebackup_factory_info_plist_new()
299 /* FIXME Sync Settings? */ 299 /* FIXME Sync Settings? */
300 300
301 value_node = plist_dict_get_item(root_node, "UniqueDeviceID"); 301 value_node = plist_dict_get_item(root_node, "UniqueDeviceID");
302 idevice_get_uuid(phone, &uuid); 302 idevice_get_udid(phone, &udid);
303 plist_dict_insert_item(ret, "Target Identifier", plist_new_string(uuid)); 303 plist_dict_insert_item(ret, "Target Identifier", plist_new_string(udid));
304 304
305 plist_dict_insert_item(ret, "Target Type", plist_new_string("Device")); 305 plist_dict_insert_item(ret, "Target Type", plist_new_string("Device"));
306 306
307 /* uppercase */ 307 /* uppercase */
308 uuid_uppercase = str_toupper(uuid); 308 udid_uppercase = str_toupper(udid);
309 plist_dict_insert_item(ret, "Unique Identifier", plist_new_string(uuid_uppercase)); 309 plist_dict_insert_item(ret, "Unique Identifier", plist_new_string(udid_uppercase));
310 free(uuid_uppercase); 310 free(udid_uppercase);
311 free(uuid); 311 free(udid);
312 312
313 char *data_buf = NULL; 313 char *data_buf = NULL;
314 uint64_t data_size = 0; 314 uint64_t data_size = 0;
@@ -446,11 +446,11 @@ static int plist_write_to_filename(plist_t plist, const char *filename, enum pli
446 return 1; 446 return 1;
447} 447}
448 448
449static int mb2_status_check_snapshot_state(const char *path, const char *uuid, const char *matches) 449static int mb2_status_check_snapshot_state(const char *path, const char *udid, const char *matches)
450{ 450{
451 int ret = -1; 451 int ret = -1;
452 plist_t status_plist = NULL; 452 plist_t status_plist = NULL;
453 char *file_path = build_path(path, uuid, "Status.plist", NULL); 453 char *file_path = build_path(path, udid, "Status.plist", NULL);
454 454
455 plist_read_from_filename(&status_plist, file_path); 455 plist_read_from_filename(&status_plist, file_path);
456 free(file_path); 456 free(file_path);
@@ -488,7 +488,7 @@ static int mobilebackup_info_is_current_device(plist_t info)
488 /* get basic device information in one go */ 488 /* get basic device information in one go */
489 lockdownd_get_value(client, NULL, NULL, &root_node); 489 lockdownd_get_value(client, NULL, NULL, &root_node);
490 490
491 /* verify UUID */ 491 /* verify UDID */
492 value_node = plist_dict_get_item(root_node, "UniqueDeviceID"); 492 value_node = plist_dict_get_item(root_node, "UniqueDeviceID");
493 node = plist_dict_get_item(info, "Target Identifier"); 493 node = plist_dict_get_item(info, "Target Identifier");
494 494
@@ -1171,7 +1171,7 @@ static void print_usage(int argc, char **argv)
1171 printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n\n"); 1171 printf(" unback\tunpack a completed backup in DIRECTORY/_unback_/\n\n");
1172 printf("options:\n"); 1172 printf("options:\n");
1173 printf(" -d, --debug\t\tenable communication debugging\n"); 1173 printf(" -d, --debug\t\tenable communication debugging\n");
1174 printf(" -u, --uuid UUID\ttarget specific device by its 40-digit device UUID\n"); 1174 printf(" -u, --udid UDID\ttarget specific device by its 40-digit device UDID\n");
1175 printf(" -h, --help\t\tprints usage information\n"); 1175 printf(" -h, --help\t\tprints usage information\n");
1176 printf("\n"); 1176 printf("\n");
1177} 1177}
@@ -1180,9 +1180,9 @@ int main(int argc, char *argv[])
1180{ 1180{
1181 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR; 1181 idevice_error_t ret = IDEVICE_E_UNKNOWN_ERROR;
1182 int i; 1182 int i;
1183 char uuid[41]; 1183 char udid[41];
1184 uint16_t port = 0; 1184 uint16_t port = 0;
1185 uuid[0] = 0; 1185 udid[0] = 0;
1186 int cmd = -1; 1186 int cmd = -1;
1187 int cmd_flags = 0; 1187 int cmd_flags = 0;
1188 int is_full_backup = 0; 1188 int is_full_backup = 0;
@@ -1207,13 +1207,13 @@ int main(int argc, char *argv[])
1207 idevice_set_debug_level(1); 1207 idevice_set_debug_level(1);
1208 continue; 1208 continue;
1209 } 1209 }
1210 else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--uuid")) { 1210 else if (!strcmp(argv[i], "-u") || !strcmp(argv[i], "--udid")) {
1211 i++; 1211 i++;
1212 if (!argv[i] || (strlen(argv[i]) != 40)) { 1212 if (!argv[i] || (strlen(argv[i]) != 40)) {
1213 print_usage(argc, argv); 1213 print_usage(argc, argv);
1214 return 0; 1214 return 0;
1215 } 1215 }
1216 strcpy(uuid, argv[i]); 1216 strcpy(udid, argv[i]);
1217 continue; 1217 continue;
1218 } 1218 }
1219 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) { 1219 else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
@@ -1277,10 +1277,10 @@ int main(int argc, char *argv[])
1277 return -1; 1277 return -1;
1278 } 1278 }
1279 1279
1280 if (uuid[0] != 0) { 1280 if (udid[0] != 0) {
1281 ret = idevice_new(&phone, uuid); 1281 ret = idevice_new(&phone, udid);
1282 if (ret != IDEVICE_E_SUCCESS) { 1282 if (ret != IDEVICE_E_SUCCESS) {
1283 printf("No device found with uuid %s, is it plugged in?\n", uuid); 1283 printf("No device found with udid %s, is it plugged in?\n", udid);
1284 return -1; 1284 return -1;
1285 } 1285 }
1286 } 1286 }
@@ -1291,18 +1291,18 @@ int main(int argc, char *argv[])
1291 printf("No device found, is it plugged in?\n"); 1291 printf("No device found, is it plugged in?\n");
1292 return -1; 1292 return -1;
1293 } 1293 }
1294 char *newuuid = NULL; 1294 char *newudid = NULL;
1295 idevice_get_uuid(phone, &newuuid); 1295 idevice_get_udid(phone, &newudid);
1296 strcpy(uuid, newuuid); 1296 strcpy(udid, newudid);
1297 free(newuuid); 1297 free(newudid);
1298 } 1298 }
1299 1299
1300 /* backup directory must contain an Info.plist */ 1300 /* backup directory must contain an Info.plist */
1301 char *info_path = build_path(backup_directory, uuid, "Info.plist", NULL); 1301 char *info_path = build_path(backup_directory, udid, "Info.plist", NULL);
1302 if (cmd == CMD_RESTORE) { 1302 if (cmd == CMD_RESTORE) {
1303 if (stat(info_path, &st) != 0) { 1303 if (stat(info_path, &st) != 0) {
1304 free(info_path); 1304 free(info_path);
1305 printf("ERROR: Backup directory \"%s\" is invalid. No Info.plist found for UUID %s.\n", backup_directory, uuid); 1305 printf("ERROR: Backup directory \"%s\" is invalid. No Info.plist found for UDID %s.\n", backup_directory, udid);
1306 return -1; 1306 return -1;
1307 } 1307 }
1308 } 1308 }
@@ -1430,7 +1430,7 @@ checkpoint:
1430 PRINT_VERBOSE(1, "Starting backup...\n"); 1430 PRINT_VERBOSE(1, "Starting backup...\n");
1431 1431
1432 /* make sure backup device sub-directory exists */ 1432 /* make sure backup device sub-directory exists */
1433 char *devbackupdir = build_path(backup_directory, uuid, NULL); 1433 char *devbackupdir = build_path(backup_directory, udid, NULL);
1434 __mkdir(devbackupdir, 0755); 1434 __mkdir(devbackupdir, 0755);
1435 free(devbackupdir); 1435 free(devbackupdir);
1436 1436
@@ -1453,7 +1453,7 @@ checkpoint:
1453 /* request backup from device with manifest from last backup */ 1453 /* request backup from device with manifest from last backup */
1454 PRINT_VERBOSE(1, "Requesting backup from device...\n"); 1454 PRINT_VERBOSE(1, "Requesting backup from device...\n");
1455 1455
1456 err = mobilebackup2_send_request(mobilebackup2, "Backup", uuid, NULL, NULL); 1456 err = mobilebackup2_send_request(mobilebackup2, "Backup", udid, NULL, NULL);
1457 if (err == MOBILEBACKUP2_E_SUCCESS) { 1457 if (err == MOBILEBACKUP2_E_SUCCESS) {
1458 if (is_full_backup) { 1458 if (is_full_backup) {
1459 PRINT_VERBOSE(1, "Full backup mode.\n"); 1459 PRINT_VERBOSE(1, "Full backup mode.\n");
@@ -1475,7 +1475,7 @@ checkpoint:
1475 /* TODO: verify battery on AC enough battery remaining */ 1475 /* TODO: verify battery on AC enough battery remaining */
1476 1476
1477 /* verify if Status.plist says we read from an successful backup */ 1477 /* verify if Status.plist says we read from an successful backup */
1478 if (!mb2_status_check_snapshot_state(backup_directory, uuid, "finished")) { 1478 if (!mb2_status_check_snapshot_state(backup_directory, udid, "finished")) {
1479 printf("ERROR: Cannot ensure we restore from a successful backup. Aborting.\n"); 1479 printf("ERROR: Cannot ensure we restore from a successful backup. Aborting.\n");
1480 cmd = CMD_LEAVE; 1480 cmd = CMD_LEAVE;
1481 break; 1481 break;
@@ -1495,7 +1495,7 @@ checkpoint:
1495 plist_dict_insert_item(opts, "RestorePreserveSettings", plist_new_bool((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0)); 1495 plist_dict_insert_item(opts, "RestorePreserveSettings", plist_new_bool((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0));
1496 PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No")); 1496 PRINT_VERBOSE(1, "Preserve settings of device: %s\n", ((cmd_flags & CMD_FLAG_RESTORE_SETTINGS) == 0 ? "Yes":"No"));
1497 1497
1498 err = mobilebackup2_send_request(mobilebackup2, "Restore", uuid, uuid, opts); 1498 err = mobilebackup2_send_request(mobilebackup2, "Restore", udid, udid, opts);
1499 plist_free(opts); 1499 plist_free(opts);
1500 if (err != MOBILEBACKUP2_E_SUCCESS) { 1500 if (err != MOBILEBACKUP2_E_SUCCESS) {
1501 if (err == MOBILEBACKUP2_E_BAD_VERSION) { 1501 if (err == MOBILEBACKUP2_E_BAD_VERSION) {
@@ -1510,7 +1510,7 @@ checkpoint:
1510 break; 1510 break;
1511 case CMD_INFO: 1511 case CMD_INFO:
1512 PRINT_VERBOSE(1, "Requesting backup info from device...\n"); 1512 PRINT_VERBOSE(1, "Requesting backup info from device...\n");
1513 err = mobilebackup2_send_request(mobilebackup2, "Info", uuid, NULL, NULL); 1513 err = mobilebackup2_send_request(mobilebackup2, "Info", udid, NULL, NULL);
1514 if (err != MOBILEBACKUP2_E_SUCCESS) { 1514 if (err != MOBILEBACKUP2_E_SUCCESS) {
1515 printf("Error requesting backup info from device, error code %d\n", err); 1515 printf("Error requesting backup info from device, error code %d\n", err);
1516 cmd = CMD_LEAVE; 1516 cmd = CMD_LEAVE;
@@ -1518,7 +1518,7 @@ checkpoint:
1518 break; 1518 break;
1519 case CMD_LIST: 1519 case CMD_LIST:
1520 PRINT_VERBOSE(1, "Requesting backup list from device...\n"); 1520 PRINT_VERBOSE(1, "Requesting backup list from device...\n");
1521 err = mobilebackup2_send_request(mobilebackup2, "List", uuid, NULL, NULL); 1521 err = mobilebackup2_send_request(mobilebackup2, "List", udid, NULL, NULL);
1522 if (err != MOBILEBACKUP2_E_SUCCESS) { 1522 if (err != MOBILEBACKUP2_E_SUCCESS) {
1523 printf("Error requesting backup list from device, error code %d\n", err); 1523 printf("Error requesting backup list from device, error code %d\n", err);
1524 cmd = CMD_LEAVE; 1524 cmd = CMD_LEAVE;
@@ -1526,7 +1526,7 @@ checkpoint:
1526 break; 1526 break;
1527 case CMD_UNBACK: 1527 case CMD_UNBACK:
1528 PRINT_VERBOSE(1, "Starting to unpack backup...\n"); 1528 PRINT_VERBOSE(1, "Starting to unpack backup...\n");
1529 err = mobilebackup2_send_request(mobilebackup2, "Unback", uuid, NULL, NULL); 1529 err = mobilebackup2_send_request(mobilebackup2, "Unback", udid, NULL, NULL);
1530 if (err != MOBILEBACKUP2_E_SUCCESS) { 1530 if (err != MOBILEBACKUP2_E_SUCCESS) {
1531 printf("Error requesting unback operation from device, error code %d\n", err); 1531 printf("Error requesting unback operation from device, error code %d\n", err);
1532 cmd = CMD_LEAVE; 1532 cmd = CMD_LEAVE;
@@ -1765,7 +1765,7 @@ files_out:
1765 switch (cmd) { 1765 switch (cmd) {
1766 case CMD_BACKUP: 1766 case CMD_BACKUP:
1767 PRINT_VERBOSE(1, "Received %d files from device.\n", file_count); 1767 PRINT_VERBOSE(1, "Received %d files from device.\n", file_count);
1768 if (mb2_status_check_snapshot_state(backup_directory, uuid, "finished")) { 1768 if (mb2_status_check_snapshot_state(backup_directory, udid, "finished")) {
1769 PRINT_VERBOSE(1, "Backup Successful.\n"); 1769 PRINT_VERBOSE(1, "Backup Successful.\n");
1770 } else { 1770 } else {
1771 if (quit_flag) { 1771 if (quit_flag) {