diff options
Diffstat (limited to 'rbutil/ipodpatcher/main.c')
-rw-r--r-- | rbutil/ipodpatcher/main.c | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/rbutil/ipodpatcher/main.c b/rbutil/ipodpatcher/main.c index a4508abf57..24938931d6 100644 --- a/rbutil/ipodpatcher/main.c +++ b/rbutil/ipodpatcher/main.c | |||
@@ -47,7 +47,8 @@ enum { | |||
47 | WRITE_FIRMWARE, | 47 | WRITE_FIRMWARE, |
48 | READ_PARTITION, | 48 | READ_PARTITION, |
49 | WRITE_PARTITION, | 49 | WRITE_PARTITION, |
50 | FORMAT_PARTITION | 50 | FORMAT_PARTITION, |
51 | CONVERT_TO_FAT32 | ||
51 | }; | 52 | }; |
52 | 53 | ||
53 | void print_macpod_warning(void) | 54 | void print_macpod_warning(void) |
@@ -87,6 +88,7 @@ void print_usage(void) | |||
87 | fprintf(stderr," -ab, --add-bootloader-bin filename.bin\n"); | 88 | fprintf(stderr," -ab, --add-bootloader-bin filename.bin\n"); |
88 | fprintf(stderr," -d, --delete-bootloader\n"); | 89 | fprintf(stderr," -d, --delete-bootloader\n"); |
89 | fprintf(stderr," -f, --format\n"); | 90 | fprintf(stderr," -f, --format\n"); |
91 | fprintf(stderr," -c, --convert\n"); | ||
90 | fprintf(stderr,"\n"); | 92 | fprintf(stderr,"\n"); |
91 | 93 | ||
92 | #ifdef __WIN32__ | 94 | #ifdef __WIN32__ |
@@ -118,11 +120,11 @@ void display_partinfo(struct ipod_t* ipod) | |||
118 | if (ipod->pinfo[i].start != 0) { | 120 | if (ipod->pinfo[i].start != 0) { |
119 | printf("[INFO] %d %10ld %10ld %10.1f %s (0x%02x)\n", | 121 | printf("[INFO] %d %10ld %10ld %10.1f %s (0x%02x)\n", |
120 | i, | 122 | i, |
121 | ipod->pinfo[i].start, | 123 | (long int)ipod->pinfo[i].start, |
122 | ipod->pinfo[i].start+ipod->pinfo[i].size-1, | 124 | (long int)ipod->pinfo[i].start+ipod->pinfo[i].size-1, |
123 | ipod->pinfo[i].size/sectors_per_MB, | 125 | ipod->pinfo[i].size/sectors_per_MB, |
124 | get_parttype(ipod->pinfo[i].type), | 126 | get_parttype(ipod->pinfo[i].type), |
125 | ipod->pinfo[i].type); | 127 | (int)ipod->pinfo[i].type); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | } | 130 | } |
@@ -297,6 +299,10 @@ int main(int argc, char* argv[]) | |||
297 | (strcmp(argv[i],"--format")==0)) { | 299 | (strcmp(argv[i],"--format")==0)) { |
298 | action = FORMAT_PARTITION; | 300 | action = FORMAT_PARTITION; |
299 | i++; | 301 | i++; |
302 | } else if ((strcmp(argv[i],"-c")==0) || | ||
303 | (strcmp(argv[i],"--convert")==0)) { | ||
304 | action = CONVERT_TO_FAT32; | ||
305 | i++; | ||
300 | } else { | 306 | } else { |
301 | print_usage(); return 1; | 307 | print_usage(); return 1; |
302 | } | 308 | } |
@@ -470,8 +476,9 @@ int main(int argc, char* argv[]) | |||
470 | 476 | ||
471 | close(infile); | 477 | close(infile); |
472 | } else if (action==FORMAT_PARTITION) { | 478 | } else if (action==FORMAT_PARTITION) { |
473 | printf("WARNING!!! YOU ARE ABOUT TO USE AN EXPERIMENTAL FORMATTING FEATURE.\n"); | 479 | printf("WARNING!!! YOU ARE ABOUT TO USE AN EXPERIMENTAL FEATURE.\n"); |
474 | printf("Are you sure you want to continue? (y/n):"); | 480 | printf("ALL DATA ON YOUR IPOD WILL BE ERASED.\n"); |
481 | printf("Are you sure you want to format your ipod? (y/n):"); | ||
475 | 482 | ||
476 | if (fgets(yesno,4,stdin)) { | 483 | if (fgets(yesno,4,stdin)) { |
477 | if (yesno[0]=='y') { | 484 | if (yesno[0]=='y') { |
@@ -486,6 +493,32 @@ int main(int argc, char* argv[]) | |||
486 | fprintf(stderr,"[INFO] Format cancelled.\n"); | 493 | fprintf(stderr,"[INFO] Format cancelled.\n"); |
487 | } | 494 | } |
488 | } | 495 | } |
496 | } else if (action==CONVERT_TO_FAT32) { | ||
497 | if (!ipod.macpod) { | ||
498 | printf("[ERR] Ipod is already FAT32, aborting\n"); | ||
499 | } else { | ||
500 | printf("WARNING!!! YOU ARE ABOUT TO USE AN EXPERIMENTAL FEATURE.\n"); | ||
501 | printf("ALL DATA ON YOUR IPOD WILL BE ERASED.\n"); | ||
502 | printf("Are you sure you want to convert your ipod to FAT32? (y/n):"); | ||
503 | |||
504 | if (fgets(yesno,4,stdin)) { | ||
505 | if (yesno[0]=='y') { | ||
506 | if (ipod_reopen_rw(&ipod) < 0) { | ||
507 | return 5; | ||
508 | } | ||
509 | |||
510 | if (write_dos_partition_table(&ipod) < 0) { | ||
511 | fprintf(stderr,"[ERR] Partition conversion failed.\n"); | ||
512 | } | ||
513 | |||
514 | if (format_partition(&ipod,1) < 0) { | ||
515 | fprintf(stderr,"[ERR] Format failed.\n"); | ||
516 | } | ||
517 | } else { | ||
518 | fprintf(stderr,"[INFO] Format cancelled.\n"); | ||
519 | } | ||
520 | } | ||
521 | } | ||
489 | } | 522 | } |
490 | 523 | ||
491 | ipod_close(&ipod); | 524 | ipod_close(&ipod); |