diff options
| -rw-r--r-- | tools/idevicebackup2.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/idevicebackup2.c b/tools/idevicebackup2.c index 4b7e79e..d2ec792 100644 --- a/tools/idevicebackup2.c +++ b/tools/idevicebackup2.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <libgen.h> | 30 | #include <libgen.h> |
| 31 | #include <ctype.h> | 31 | #include <ctype.h> |
| 32 | #include <time.h> | 32 | #include <time.h> |
| 33 | #include <sys/statvfs.h> | ||
| 33 | 34 | ||
| 34 | #include <libimobiledevice/libimobiledevice.h> | 35 | #include <libimobiledevice/libimobiledevice.h> |
| 35 | #include <libimobiledevice/lockdown.h> | 36 | #include <libimobiledevice/lockdown.h> |
| @@ -1571,13 +1572,23 @@ checkpoint: | |||
| 1571 | } else if (!strcmp(dlmsg, "DLMessageUploadFiles")) { | 1572 | } else if (!strcmp(dlmsg, "DLMessageUploadFiles")) { |
| 1572 | /* device wants to send files to the computer */ | 1573 | /* device wants to send files to the computer */ |
| 1573 | file_count += mb2_handle_receive_files(message, backup_directory); | 1574 | file_count += mb2_handle_receive_files(message, backup_directory); |
| 1575 | } else if (!strcmp(dlmsg, "DLMessageGetFreeDiskSpace")) { | ||
| 1576 | /* device wants to know how much disk space is available on the computer */ | ||
| 1577 | struct statvfs fs; | ||
| 1578 | memset(&fs, '\0', sizeof(fs)); | ||
| 1579 | int res = statvfs(backup_directory, &fs); | ||
| 1580 | uint64_t freespace = 0; | ||
| 1581 | if (res == 0) { | ||
| 1582 | freespace = fs.f_bavail * fs.f_bsize; | ||
| 1583 | } | ||
| 1584 | mobilebackup2_send_status_response(mobilebackup2, res, NULL, plist_new_uint(freespace)); | ||
| 1574 | } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) { | 1585 | } else if (!strcmp(dlmsg, "DLContentsOfDirectory")) { |
| 1575 | /* list directory contents */ | 1586 | /* list directory contents */ |
| 1576 | mb2_handle_list_directory(message, backup_directory); | 1587 | mb2_handle_list_directory(message, backup_directory); |
| 1577 | } else if (!strcmp(dlmsg, "DLMessageCreateDirectory")) { | 1588 | } else if (!strcmp(dlmsg, "DLMessageCreateDirectory")) { |
| 1578 | /* make a directory */ | 1589 | /* make a directory */ |
| 1579 | mb2_handle_make_directory(message, backup_directory); | 1590 | mb2_handle_make_directory(message, backup_directory); |
| 1580 | } else if (!strcmp(dlmsg, "DLMessageMoveFiles")) { | 1591 | } else if (!strcmp(dlmsg, "DLMessageMoveFiles") || !strcmp(dlmsg, "DLMessageMoveItems")) { |
| 1581 | /* perform a series of rename operations */ | 1592 | /* perform a series of rename operations */ |
| 1582 | plist_t moves = plist_array_get_item(message, 1); | 1593 | plist_t moves = plist_array_get_item(message, 1); |
| 1583 | uint32_t cnt = plist_dict_get_size(moves); | 1594 | uint32_t cnt = plist_dict_get_size(moves); |
| @@ -1623,7 +1634,7 @@ checkpoint: | |||
| 1623 | if (err != MOBILEBACKUP2_E_SUCCESS) { | 1634 | if (err != MOBILEBACKUP2_E_SUCCESS) { |
| 1624 | printf("Could not send status response, error %d\n", err); | 1635 | printf("Could not send status response, error %d\n", err); |
| 1625 | } | 1636 | } |
| 1626 | } else if (!strcmp(dlmsg, "DLMessageRemoveFiles")) { | 1637 | } else if (!strcmp(dlmsg, "DLMessageRemoveFiles") || !strcmp(dlmsg, "DLMessageRemoveItems")) { |
| 1627 | plist_t removes = plist_array_get_item(message, 1); | 1638 | plist_t removes = plist_array_get_item(message, 1); |
| 1628 | uint32_t cnt = plist_array_get_size(removes); | 1639 | uint32_t cnt = plist_array_get_size(removes); |
| 1629 | PRINT_VERBOSE(1, "Removing %d file%s\n", cnt, (cnt == 1) ? "" : "s"); | 1640 | PRINT_VERBOSE(1, "Removing %d file%s\n", cnt, (cnt == 1) ? "" : "s"); |
