summaryrefslogtreecommitdiffstats
path: root/rbutil/ipodpatcher/fat32format.c
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2012-12-23 23:30:57 +0100
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2013-01-01 15:05:52 +0100
commit24e37ddf57bac6a1c9786d50abbe3a1982930382 (patch)
treeb34ae751986f185f51556a040f388025cac4c383 /rbutil/ipodpatcher/fat32format.c
parent6803d7b10cd9651ded08674f1597d4511cabb7af (diff)
downloadrockbox-24e37ddf57bac6a1c9786d50abbe3a1982930382.tar.gz
rockbox-24e37ddf57bac6a1c9786d50abbe3a1982930382.tar.bz2
rockbox-24e37ddf57bac6a1c9786d50abbe3a1982930382.zip
ipodpatcher: move sectorbuf pointer into ipod_t structure.
The ipod_t structure holds all relevant information for ipodpatcher. Put the global ipod_sectorbuf pointer into it as well. Allows the Rockbox Utility Ipod class to be instanciated multiple times since each instance can now have its own buffer. Change-Id: Ie319cbadbc20c367ceadba9a46b4dc34b57a79a7
Diffstat (limited to 'rbutil/ipodpatcher/fat32format.c')
-rw-r--r--rbutil/ipodpatcher/fat32format.c19
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)
}
-/* A large aligned buffer for disk I/O */
-extern unsigned char* ipod_sectorbuf;
-
/* TODO: Pass these as parameters to the various create_ functions */
/* 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)
return -1;
}
- memset(ipod_sectorbuf, 0, 128 * ipod->sector_size);
+ memset(ipod->sectorbuf, 0, 128 * ipod->sector_size);
/* Write 128 sectors at a time */
while (count) {
@@ -175,7 +172,7 @@ static int zero_sectors(struct ipod_t* ipod, uint64_t sector, int count)
else
n = count;
- if (ipod_write(ipod,ipod_sectorbuf,n * ipod->sector_size) < 0) {
+ if (ipod_write(ipod,n * ipod->sector_size) < 0) {
perror("[ERR] Write failed in zero_sectors\n");
return -1;
}
@@ -484,15 +481,15 @@ int format_partition(struct ipod_t* ipod, int partition)
fprintf(stderr,"[INFO] Initialising reserved sectors and FATs...\n" );
/* Create the boot sector structure */
- create_boot_sector(ipod_sectorbuf, ipod, partition);
- create_fsinfo(ipod_sectorbuf + 512);
+ create_boot_sector(ipod->sectorbuf, ipod, partition);
+ create_fsinfo(ipod->sectorbuf + 512);
/* Write boot sector and fsinfo at start of partition */
if (ipod_seek(ipod, ipod->pinfo[partition].start * ipod->sector_size) < 0) {
fprintf(stderr,"[ERR] Seek failed\n");
return -1;
}
- if (ipod_write(ipod,ipod_sectorbuf,512 * 2) < 0) {
+ if (ipod_write(ipod,512 * 2) < 0) {
perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
return -1;
}
@@ -502,13 +499,13 @@ int format_partition(struct ipod_t* ipod, int partition)
fprintf(stderr,"[ERR] Seek failed\n");
return -1;
}
- if (ipod_write(ipod,ipod_sectorbuf,512 * 2) < 0) {
+ if (ipod_write(ipod,512 * 2) < 0) {
perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
return -1;
}
/* Create the first FAT sector */
- create_firstfatsector(ipod_sectorbuf);
+ create_firstfatsector(ipod->sectorbuf);
/* Write the first fat sector in the right places */
for ( i=0; i<NumFATs; i++ ) {
@@ -519,7 +516,7 @@ int format_partition(struct ipod_t* ipod, int partition)
return -1;
}
- if (ipod_write(ipod,ipod_sectorbuf,512) < 0) {
+ if (ipod_write(ipod,512) < 0) {
perror("[ERR] Write failed (first copy of bootsect/fsinfo)\n");
return -1;
}