summaryrefslogtreecommitdiff
path: root/rbutil/ipodpatcher/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/ipodpatcher/main.c')
-rw-r--r--rbutil/ipodpatcher/main.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/rbutil/ipodpatcher/main.c b/rbutil/ipodpatcher/main.c
index c47063cba8..f113c8aff4 100644
--- a/rbutil/ipodpatcher/main.c
+++ b/rbutil/ipodpatcher/main.c
@@ -45,6 +45,8 @@ enum {
45 ADD_BOOTLOADER, 45 ADD_BOOTLOADER,
46 READ_FIRMWARE, 46 READ_FIRMWARE,
47 WRITE_FIRMWARE, 47 WRITE_FIRMWARE,
48 READ_AUPD,
49 WRITE_AUPD,
48 READ_PARTITION, 50 READ_PARTITION,
49 WRITE_PARTITION, 51 WRITE_PARTITION,
50 FORMAT_PARTITION, 52 FORMAT_PARTITION,
@@ -89,6 +91,8 @@ void print_usage(void)
89 fprintf(stderr," -d, --delete-bootloader\n"); 91 fprintf(stderr," -d, --delete-bootloader\n");
90 fprintf(stderr," -f, --format\n"); 92 fprintf(stderr," -f, --format\n");
91 fprintf(stderr," -c, --convert\n"); 93 fprintf(stderr," -c, --convert\n");
94 fprintf(stderr," --read-aupd filename.bin\n");
95 fprintf(stderr," --write-aupd filename.bin\n");
92 fprintf(stderr,"\n"); 96 fprintf(stderr,"\n");
93 97
94#ifdef __WIN32__ 98#ifdef __WIN32__
@@ -299,6 +303,18 @@ int main(int argc, char* argv[])
299 (strcmp(argv[i],"--format")==0)) { 303 (strcmp(argv[i],"--format")==0)) {
300 action = FORMAT_PARTITION; 304 action = FORMAT_PARTITION;
301 i++; 305 i++;
306 } else if (strcmp(argv[i],"--read-aupd")==0) {
307 action = READ_AUPD;
308 i++;
309 if (i == argc) { print_usage(); return 1; }
310 filename=argv[i];
311 i++;
312 } else if (strcmp(argv[i],"--write-aupd")==0) {
313 action = WRITE_AUPD;
314 i++;
315 if (i == argc) { print_usage(); return 1; }
316 filename=argv[i];
317 i++;
302 } else if ((strcmp(argv[i],"-c")==0) || 318 } else if ((strcmp(argv[i],"-c")==0) ||
303 (strcmp(argv[i],"--convert")==0)) { 319 (strcmp(argv[i],"--convert")==0)) {
304 action = CONVERT_TO_FAT32; 320 action = CONVERT_TO_FAT32;
@@ -444,6 +460,22 @@ int main(int argc, char* argv[])
444 } else { 460 } else {
445 fprintf(stderr,"[ERR] --read-firmware failed.\n"); 461 fprintf(stderr,"[ERR] --read-firmware failed.\n");
446 } 462 }
463 } else if (action==READ_AUPD) {
464 if (read_aupd(&ipod, filename)==0) {
465 fprintf(stderr,"[INFO] AUPD image read to file %s.\n",filename);
466 } else {
467 fprintf(stderr,"[ERR] --read-aupd failed.\n");
468 }
469 } else if (action==WRITE_AUPD) {
470 if (ipod_reopen_rw(&ipod) < 0) {
471 return 5;
472 }
473
474 if (write_aupd(&ipod, filename)==0) {
475 fprintf(stderr,"[INFO] AUPD image %s written to device.\n",filename);
476 } else {
477 fprintf(stderr,"[ERR] --write-aupd failed.\n");
478 }
447 } else if (action==READ_PARTITION) { 479 } else if (action==READ_PARTITION) {
448 outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IREAD|S_IWRITE); 480 outfile = open(filename,O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,S_IREAD|S_IWRITE);
449 if (outfile < 0) { 481 if (outfile < 0) {