From f05bbae5f00c57f3d08936159212d3e20678a8d6 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 16:37:04 +0200 Subject: Fix crash due to not passing client handle for callback as userdata --- src/restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 5d45296..44dc2aa 100644 --- a/src/restore.c +++ b/src/restore.c @@ -225,7 +225,7 @@ int restore_open_with_timeout(struct idevicerestore_client_t* client) { } } - device_error = idevice_event_subscribe(&restore_device_callback, NULL); + device_error = idevice_event_subscribe(&restore_device_callback, client); if (device_error != IDEVICE_E_SUCCESS) { error("ERROR: Unable to subscribe to device events\n"); return -1; -- cgit v1.1-32-gdbae From 515f26d28667b4790a4c1db1126f68b015ed1bce Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 16:37:57 +0200 Subject: Fix idevice handle being NULL which leads to failure to connect to ASR --- src/restore.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 44dc2aa..e4652bf 100644 --- a/src/restore.c +++ b/src/restore.c @@ -606,6 +606,7 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit info("Device has successfully entered restore mode\n"); restore = client->restore->client; + device = client->restore->device; // start the restore process restore_error = restored_start_restore(restore); -- cgit v1.1-32-gdbae From 232e116e48612ffec0351704a431f4174544887e Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 16:59:36 +0200 Subject: Correctly set QUIT flag during restore --- src/restore.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index e4652bf..40b24d3 100644 --- a/src/restore.c +++ b/src/restore.c @@ -178,7 +178,7 @@ void restore_device_callback(const idevice_event_t* event, void* userdata) { } else if (event->event == IDEVICE_DEVICE_REMOVE) { restore_device_connected = 0; - client->flags &= FLAG_QUIT; + client->flags |= FLAG_QUIT; } } @@ -575,7 +575,7 @@ int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idev return -1; } } else { - client->flags &= 1; + client->flags |= FLAG_QUIT; } } else { @@ -667,7 +667,7 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit // an unrecoverable error, so we need to bail. if (error < 0) { error("ERROR: Unable to successfully restore device\n"); - client->flags &= FLAG_QUIT; + client->flags |= FLAG_QUIT; } plist_free(message); -- cgit v1.1-32-gdbae From 9a404feafc3a738d5aad999491c6c0fd23b4da01 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:35:13 +0200 Subject: Add more known status messages and report them --- src/restore.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 40b24d3..4b5d0fd 100644 --- a/src/restore.c +++ b/src/restore.c @@ -348,8 +348,27 @@ int restore_handle_progress_msg(restored_client_t client, plist_t msg) { } int restore_handle_status_msg(restored_client_t client, plist_t msg) { + uint64_t value = 0; info("Got status message\n"); debug_plist(msg); + + plist_t node = plist_dict_get_item(msg, "Status"); + plist_get_uint_val(node, &value); + + switch(value) { + case 0: + info("Status: Restore Finished\n"); + break; + case 6: + info("Status: Disk Failure\n"); + break; + case 14: + info("Status: Fail\n"); + break; + default: + info("Unknown status message.\n"); + } + return 0; } @@ -366,8 +385,7 @@ int restore_send_filesystem(idevice_t device, const char* filesystem) { } info("Connected to ASR\n"); - // we don't really need to do anything with this, - // we're just clearing the output buffer + /* receive Initiate command message */ if (asr_receive(asr, &data) < 0) { error("ERROR: Unable to receive data from ASR\n"); asr_close(asr); -- cgit v1.1-32-gdbae From 853e499d97d2dd0c2b9dcc0ff3398f0295832132 Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:37:31 +0200 Subject: Add more known progress messages and report them --- src/restore.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 4b5d0fd..0916665 100644 --- a/src/restore.c +++ b/src/restore.c @@ -29,6 +29,7 @@ #include "common.h" #include "restore.h" +#define WAIT_FOR_STORAGE 11 #define CREATE_PARTITION_MAP 12 #define CREATE_FILESYSTEM 13 #define RESTORE_IMAGE 14 @@ -39,6 +40,8 @@ #define UPDATE_BASEBAND 20 #define FINIALIZE_NAND 21 #define MODIFY_BOOTARGS 26 +#define LOAD_KERNEL_CACHE 27 +#define PARTITION_NAND_DEVICE 28 #define WAIT_FOR_NAND 29 #define UNMOUNT_FILESYSTEM 30 #define WAIT_FOR_DEVICE 33 @@ -271,6 +274,9 @@ int restore_open_with_timeout(struct idevicerestore_client_t* client) { const char* restore_progress_string(unsigned int operation) { switch (operation) { + case WAIT_FOR_STORAGE: + return "Waiting for Storage Device..."; + case CREATE_PARTITION_MAP: return "Creating partition map"; @@ -304,12 +310,18 @@ const char* restore_progress_string(unsigned int operation) { case UNMOUNT_FILESYSTEM: return "Unmounting filesystems"; + case PARTITION_NAND_DEVICE: + return "Partition NAND device"; + case WAIT_FOR_NAND: return "Waiting for NAND..."; case WAIT_FOR_DEVICE: return "Waiting for Device..."; + case LOAD_KERNEL_CACHE: + return "Loading kernelcache..."; + case LOAD_NOR: return "Loading NOR data to flash"; @@ -339,7 +351,6 @@ int restore_handle_progress_msg(restored_client_t client, plist_t msg) { if ((progress > 0) && (progress < 100)) { print_progress_bar((double) progress); - } else { info("%s\n", restore_progress_string(operation)); } -- cgit v1.1-32-gdbae From 9433af8a8c8f6d8718712d59547d3c333402551b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:38:53 +0200 Subject: Only debug a plist if debugging flag was set --- src/restore.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 0916665..0170ac3 100644 --- a/src/restore.c +++ b/src/restore.c @@ -559,7 +559,8 @@ int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* } plist_dict_insert_item(dict, "NorImageData", norimage_array); - debug_plist(dict); + if (idevicerestore_debug) + debug_plist(dict); ret = restored_send(restore, dict); if (ret != RESTORE_E_SUCCESS) { @@ -610,7 +611,8 @@ int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idev } else { // Unknown DataType!! debug("Unknown data request received\n"); - debug_plist(message); + if (idevicerestore_debug) + debug_plist(message); } } return 0; @@ -659,7 +661,8 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit node = plist_dict_get_item(message, "MsgType"); if (!node || plist_get_node_type(node) != PLIST_STRING) { debug("Unknown message received\n"); - debug_plist(message); + if (idevicerestore_debug) + debug_plist(message); plist_free(message); message = NULL; continue; @@ -689,7 +692,8 @@ int restore_device(struct idevicerestore_client_t* client, plist_t build_identit // at least the "previous error logs" messages usually end up here else { debug("Unknown message type received\n"); - debug_plist(message); + if (idevicerestore_debug) + debug_plist(message); } // finally, if any of these message handlers returned -1 then we encountered -- cgit v1.1-32-gdbae From ae0451c0b1de4419dd97614a4068a8f37522412e Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:39:29 +0200 Subject: Fix typo in nor data message --- src/restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index 0170ac3..d40d294 100644 --- a/src/restore.c +++ b/src/restore.c @@ -564,7 +564,7 @@ int restore_send_nor(restored_client_t restore, struct idevicerestore_client_t* ret = restored_send(restore, dict); if (ret != RESTORE_E_SUCCESS) { - error("ERROR: Unable to send kernelcache data\n"); + error("ERROR: Unable to send NOR image data data\n"); plist_free(dict); return -1; } -- cgit v1.1-32-gdbae From c41bfdcfc9c8da11249422c70de6bc0884ebd32b Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Fri, 9 Jul 2010 23:39:58 +0200 Subject: Correctly check when to send the NORData --- src/restore.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/restore.c') diff --git a/src/restore.c b/src/restore.c index d40d294..bb3ed96 100644 --- a/src/restore.c +++ b/src/restore.c @@ -599,12 +599,14 @@ int restore_handle_data_request_msg(struct idevicerestore_client_t* client, idev } else if (!strcmp(type, "NORData")) { - if(client->flags & FLAG_EXCLUDE > 0) { + if((client->flags & FLAG_EXCLUDE) == 0) { + info("Sending NORData\n"); if(restore_send_nor(restore, client, build_identity) < 0) { error("ERROR: Unable to send NOR data\n"); return -1; } } else { + info("Not sending NORData... Quitting...\n"); client->flags |= FLAG_QUIT; } -- cgit v1.1-32-gdbae