diff options
Diffstat (limited to 'rbutil/ipodpatcher/fat32format.c')
-rw-r--r-- | rbutil/ipodpatcher/fat32format.c | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/rbutil/ipodpatcher/fat32format.c b/rbutil/ipodpatcher/fat32format.c index 9d2c538cd7..f47be60a97 100644 --- a/rbutil/ipodpatcher/fat32format.c +++ b/rbutil/ipodpatcher/fat32format.c | |||
@@ -87,9 +87,6 @@ static uint32_t rb_htole32(uint32_t x) | |||
87 | } | 87 | } |
88 | 88 | ||
89 | 89 | ||
90 | /* A large aligned buffer for disk I/O */ | ||
91 | extern unsigned char* ipod_sectorbuf; | ||
92 | |||
93 | /* TODO: Pass these as parameters to the various create_ functions */ | 90 | /* TODO: Pass these as parameters to the various create_ functions */ |
94 | 91 | ||
95 | /* can be zero for default or 1,2,4,8,16,32 or 64 */ | 92 | /* can be zero for default or 1,2,4,8,16,32 or 64 */ |
@@ -166,7 +163,7 @@ static int zero_sectors(struct ipod_t* ipod, uint64_t sector, int count) | |||
166 | return -1; | 163 | return -1; |
167 | } | 164 | } |
168 | 165 | ||
169 | memset(ipod_sectorbuf, 0, 128 * ipod->sector_size); | 166 | memset(ipod->sectorbuf, 0, 128 * ipod->sector_size); |
170 | 167 | ||
171 | /* Write 128 sectors at a time */ | 168 | /* Write 128 sectors at a time */ |
172 | while (count) { | 169 | while (count) { |
@@ -175,7 +172,7 @@ static int zero_sectors(struct ipod_t* ipod, uint64_t sector, int count) | |||
175 | else | 172 | else |
176 | n = count; | 173 | n = count; |
177 | 174 | ||
178 | if (ipod_write(ipod,ipod_sectorbuf,n * ipod->sector_size) < 0) { | 175 | if (ipod_write(ipod,n * ipod->sector_size) < 0) { |
179 | perror("[ERR] Write failed in zero_sectors\n"); | 176 | perror("[ERR] Write failed in zero_sectors\n"); |
180 | return -1; | 177 | return -1; |
181 | } | 178 | } |
@@ -484,15 +481,15 @@ int format_partition(struct ipod_t* ipod, int partition) | |||
484 | fprintf(stderr,"[INFO] Initialising reserved sectors and FATs...\n" ); | 481 | fprintf(stderr,"[INFO] Initialising reserved sectors and FATs...\n" ); |
485 | 482 | ||
486 | /* Create the boot sector structure */ | 483 | /* Create the boot sector structure */ |
487 | create_boot_sector(ipod_sectorbuf, ipod, partition); | 484 | create_boot_sector(ipod->sectorbuf, ipod, partition); |
488 | create_fsinfo(ipod_sectorbuf + 512); | 485 | create_fsinfo(ipod->sectorbuf + 512); |
489 | 486 | ||
490 | /* Write boot sector and fsinfo at start of partition */ | 487 | /* Write boot sector and fsinfo at start of partition */ |
491 | if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) { | 488 | if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) { |
492 | fprintf(stderr,"[ERR] Seek failed\n"); | 489 | fprintf(stderr,"[ERR] Seek failed\n"); |
493 | return -1; | 490 | return -1; |
494 | } | 491 | } |
495 | if (ipod_write(ipod,ipod_sectorbuf,512 * 2) < 0) { | 492 | if (ipod_write(ipod,512 * 2) < 0) { |
496 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); | 493 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); |
497 | return -1; | 494 | return -1; |
498 | } | 495 | } |
@@ -502,13 +499,13 @@ int format_partition(struct ipod_t* ipod, int partition) | |||
502 | fprintf(stderr,"[ERR] Seek failed\n"); | 499 | fprintf(stderr,"[ERR] Seek failed\n"); |
503 | return -1; | 500 | return -1; |
504 | } | 501 | } |
505 | if (ipod_write(ipod,ipod_sectorbuf,512 * 2) < 0) { | 502 | if (ipod_write(ipod,512 * 2) < 0) { |
506 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); | 503 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); |
507 | return -1; | 504 | return -1; |
508 | } | 505 | } |
509 | 506 | ||
510 | /* Create the first FAT sector */ | 507 | /* Create the first FAT sector */ |
511 | create_firstfatsector(ipod_sectorbuf); | 508 | create_firstfatsector(ipod->sectorbuf); |
512 | 509 | ||
513 | /* Write the first fat sector in the right places */ | 510 | /* Write the first fat sector in the right places */ |
514 | for ( i=0; i<NumFATs; i++ ) { | 511 | for ( i=0; i<NumFATs; i++ ) { |
@@ -519,7 +516,7 @@ int format_partition(struct ipod_t* ipod, int partition) | |||
519 | return -1; | 516 | return -1; |
520 | } | 517 | } |
521 | 518 | ||
522 | if (ipod_write(ipod,ipod_sectorbuf,512) < 0) { | 519 | if (ipod_write(ipod,512) < 0) { |
523 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); | 520 | perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n"); |
524 | return -1; | 521 | return -1; |
525 | } | 522 | } |