From 24e37ddf57bac6a1c9786d50abbe3a1982930382 Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sun, 23 Dec 2012 23:30:57 +0100 Subject: 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 --- rbutil/ipodpatcher/fat32format.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'rbutil/ipodpatcher/fat32format.c') 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