ipodpatcher: Fix build warning and 'make clean'

Change-Id: I9e546b0e4e0bcc30efccfca334281398e358ae8d
This commit is contained in:
Solomon Peachy 2026-06-17 10:05:42 -04:00
parent d737cbb931
commit db0d7649e0
3 changed files with 64 additions and 65 deletions

View file

@ -31,7 +31,7 @@ LDOPTS_OSX = -framework CoreFoundation -framework IOKit
LIBSOURCES = ipodpatcher.c fat32format.c arc4.c \
ipodio-posix.c ipodio-win32-scsi.c ipodio-win32.c \
ipodpatcher-aupd.c
ipodpatcher_aupd.c
SOURCES = main.c $(BOOTSRC)
ipodpatcher: SOURCES+= ipodio-posix.c

View file

@ -65,9 +65,9 @@ static const char apple_stop_sign[] = "{{~~ /-----\\ "\
"----------------"\
"---------------";
/* Windows requires the buffer for disk I/O to be aligned in memory on a
/* Windows requires the buffer for disk I/O to be aligned in memory on a
multiple of the disk volume size - so we use a single global variable
and initialise it with ipod_alloc_buf()
and initialise it with ipod_alloc_buf()
*/
char* get_parttype(unsigned int pt)
@ -231,7 +231,7 @@ int read_partinfo(struct ipod_t* ipod, int silent)
/* see if it's a partition entry */
if ((ipod->sectorbuf[0] != 'P') || (ipod->sectorbuf[1] != 'M')) {
/* end of partition table -> leave the loop */
break;
break;
}
/* Extract the interesting entries */
@ -267,8 +267,8 @@ int read_partinfo(struct ipod_t* ipod, int silent)
1) Partition 1 is of type 0 (Empty) but isn't empty.
2) Partition 2 is of type 0xb or 0xc (winpod) or -1 (macpod)
*/
if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) ||
((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) &&
if ((ipod->pinfo[0].type != 0) || (ipod->pinfo[0].size == 0) ||
((ipod->pinfo[1].type != 0xb) && (ipod->pinfo[1].type != 0xc) &&
(ipod->pinfo[1].type != PARTTYPE_HFS))) {
if (!silent) fprintf(stderr,"[ERR] Partition layout is not an ipod\n");
return -1;
@ -370,7 +370,7 @@ int write_partition(struct ipod_t* ipod, int infile)
/* We need to pad the last write to a multiple of SECTOR_SIZE */
if ((n % ipod->sector_size) != 0) {
padding = (ipod->sector_size-(n % ipod->sector_size));
n += padding;
n += padding;
}
}
@ -380,7 +380,7 @@ int write_partition(struct ipod_t* ipod, int infile)
if (res < 0) {
ipod_print_error(" Error writing to disk: ");
fprintf(stderr,"Bytes written: %d\n",byteswritten);
fprintf(stderr,"Bytes read/written: %d/%d\n", bytesread, byteswritten);
return -1;
}
@ -408,8 +408,8 @@ int diskmove(struct ipod_t* ipod, int delta)
int n;
src_start = ipod->ipod_directory[1].devOffset;
src_end = (ipod->ipod_directory[ipod->nimages-1].devOffset + ipod->sector_size +
ipod->ipod_directory[ipod->nimages-1].len +
src_end = (ipod->ipod_directory[ipod->nimages-1].devOffset + ipod->sector_size +
ipod->ipod_directory[ipod->nimages-1].len +
(ipod->sector_size-1)) & ~(ipod->sector_size-1);
bytesleft = src_end - src_start;
@ -494,13 +494,13 @@ static int rename_image(struct ipod_t* ipod, char* from, char* to)
return -1;
}
/* Read directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to diroffset (%08x) failed.\n",(unsigned)ipod->diroffset);
return -1;
}
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -514,7 +514,7 @@ static int rename_image(struct ipod_t* ipod, char* from, char* to)
ipod->diroffset += ipod->sector_size - x;
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -537,13 +537,13 @@ static int rename_image(struct ipod_t* ipod, char* from, char* to)
}
/* Write directory back to disk */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to diroffset (%08x) failed.\n",(unsigned)ipod->diroffset);
return -1;
}
n=ipod_write(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Write of directory failed in rename_image.\n");
return -1;
}
@ -563,13 +563,13 @@ static int delete_image(struct ipod_t* ipod, char* name)
x = ipod->diroffset % ipod->sector_size;
/* Read directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to diroffset (%08x) failed.\n",(unsigned)ipod->diroffset);
return -1;
}
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -583,7 +583,7 @@ static int delete_image(struct ipod_t* ipod, char* name)
ipod->diroffset += ipod->sector_size - x;
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -605,13 +605,13 @@ static int delete_image(struct ipod_t* ipod, char* name)
}
/* Write directory back to disk */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to diroffset (%08x) failed.\n",(unsigned)ipod->diroffset);
return -1;
}
n=ipod_write(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Write of directory failed in delete_image.\n");
return -1;
}
@ -643,8 +643,8 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
fprintf(stderr,"[INFO] Using internal bootloader - %d bytes\n",ipod->bootloader_len);
length = ipod->bootloader_len;
infile = -1;
}
else
}
else
#endif
{
/* First check that the input file is the correct type for this ipod. */
@ -653,7 +653,7 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
fprintf(stderr,"[ERR] Couldn't open input file %s\n",filename);
return -1;
}
if (type==FILETYPE_DOT_IPOD) {
n = read(infile,header,8);
if (n < 8) {
@ -661,16 +661,16 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
close(infile);
return -1;
}
if (memcmp(header+4, ipod->modelname,4)!=0) {
fprintf(stderr,"[ERR] Model name in input file (%c%c%c%c) doesn't match ipod model (%s)\n",
header[4],header[5],header[6],header[7], ipod->modelname);
close(infile);
return -1;
}
filechksum = be2int(header);
length = filesize(infile)-8;
} else {
length = filesize(infile);
@ -693,7 +693,7 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
#ifdef WITH_BOOTOBJS
if (type == FILETYPE_INTERNAL) {
memcpy(ipod->sectorbuf,ipod->bootloader,ipod->bootloader_len);
}
}
else
#endif
{
@ -733,7 +733,7 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
/* 2nd Gen Nano has encrypted firmware, and the sector
preceeding the firmware contains hashes that need to be
preserved. Nano 2G images include these extra 2048 (0x800)
bytes
bytes
*/
if (ipod_seek(ipod, offset - (ipod->modelnum == 62 ? 0x800 : 0)) < 0) {
fprintf(stderr,"[ERR] Seek failed\n");
@ -752,7 +752,7 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
}
fprintf(stderr,"[INFO] Wrote %d bytes to firmware partition\n",n);
/* Now we need to create a new directory entry
/* Now we need to create a new directory entry
NOTE: On the Nano 2G, the checksum is the checksum of the
unencrypted firmware. But this isn't checked by the NOR
@ -802,7 +802,7 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
int2le(length - (ipod->modelnum==62 ? 0x800: 0), p + 16); /* len */
int2le(chksum, p + 28); /* checksum */
/* Write directory */
/* Write directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) { return -1; }
n=ipod_write(ipod, ipod->sector_size);
if (n < 0) { return -1; }
@ -929,8 +929,8 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
memcpy(ipod->sectorbuf+entryOffset,ipod->bootloader,ipod->bootloader_len);
length = ipod->bootloader_len;
paddedlength=(ipod->bootloader_len+ipod->sector_size-1)&~(ipod->sector_size-1);
}
else
}
else
#endif
{
infile=open(filename,O_RDONLY);
@ -947,16 +947,16 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
close(infile);
return -1;
}
if (memcmp(header+4, ipod->modelname,4)!=0) {
fprintf(stderr,"[ERR] Model name in input file (%c%c%c%c) doesn't match ipod model (%s)\n",
header[4],header[5],header[6],header[7], ipod->modelname);
close(infile);
return -1;
}
filechksum = be2int(header);
length=filesize(infile)-8;
} else {
length=filesize(infile);
@ -976,7 +976,7 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
fprintf(stderr,"[ERR] Couldn't read input file\n");
return -1;
}
if (type==FILETYPE_DOT_IPOD) {
/* Calculate and confirm bootloader checksum */
chksum = ipod->modelnum;
@ -984,7 +984,7 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
/* add 8 unsigned bits but keep a 32 bit sum */
chksum += bootloader_buf[i];
}
if (chksum == filechksum) {
fprintf(stderr,"[INFO] Checksum OK in %s\n",filename);
} else {
@ -1057,7 +1057,7 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
chksum = 0;
for (i=0;i<entryOffset + length; i++) {
chksum += ipod->sectorbuf[i];
}
}
/* Now write the combined firmware image to the disk */
@ -1082,7 +1082,7 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
x = ipod->diroffset % ipod->sector_size;
/* Read directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek failed\n");
return -1;
}
@ -1106,13 +1106,13 @@ int add_bootloader(struct ipod_t* ipod, char* filename, int type)
}
}
/* Write directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
/* Write directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to %d failed\n", (int)(ipod->start+ipod->diroffset-x));
return -1;
}
n=ipod_write(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Directory write failed\n");
return -1;
}
@ -1194,7 +1194,7 @@ int delete_bootloader(struct ipod_t* ipod)
int2le(0,ipod->sectorbuf+x+24);
int2le(chksum,ipod->sectorbuf+x+28);
/* Write directory */
/* Write directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) { return -1; }
n=ipod_write(ipod, ipod->sector_size);
if (n < 0) { return -1; }
@ -1226,8 +1226,8 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type)
fprintf(stderr,"[INFO] Using internal bootloader - %d bytes\n",ipod->bootloader_len);
length = ipod->bootloader_len;
infile = -1;
}
else
}
else
#endif
{
/* First check that the input file is the correct type for this ipod. */
@ -1236,7 +1236,7 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type)
fprintf(stderr,"[ERR] Couldn't open input file %s\n",filename);
return -1;
}
if (type==FILETYPE_DOT_IPOD) {
n = read(infile,header,8);
if (n < 8) {
@ -1244,16 +1244,16 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type)
close(infile);
return -1;
}
if (memcmp(header+4, ipod->modelname,4)!=0) {
fprintf(stderr,"[ERR] Model name in input file (%c%c%c%c) doesn't match ipod model (%s)\n",
header[4],header[5],header[6],header[7], ipod->modelname);
close(infile);
return -1;
}
filechksum = be2int(header);
length = filesize(infile)-8;
} else {
length = filesize(infile);
@ -1288,7 +1288,7 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type)
#ifdef WITH_BOOTOBJS
if (type == FILETYPE_INTERNAL) {
memcpy(ipod->sectorbuf,ipod->bootloader,ipod->bootloader_len);
}
}
else
#endif
{
@ -1329,7 +1329,7 @@ int write_firmware(struct ipod_t* ipod, char* filename, int type)
/* 2nd Gen Nano has encrypted firmware, and the sector
preceeding the firmware contains hashes that need to be
preserved. Nano 2G images include these extra 2048 (0x800)
bytes
bytes
*/
offset -= 0x800;
@ -1480,17 +1480,17 @@ int read_directory(struct ipod_t* ipod)
ipod->nimages=0;
/* Read firmware partition header (first 512 bytes of disk - but
/* Read firmware partition header (first 512 bytes of disk - but
let's read a whole sector) */
if (ipod_seek(ipod, ipod->start) < 0) {
if (ipod_seek(ipod, ipod->start) < 0) {
fprintf(stderr,"[ERR] Seek to 0x%08x in read_directory() failed.\n",
(unsigned int)(ipod->start));
return -1;
}
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] ipod_read(ipod,0x%08x) failed in read_directory()\n", ipod->sector_size);
return -1;
}
@ -1516,13 +1516,13 @@ int read_directory(struct ipod_t* ipod)
x = ipod->diroffset % ipod->sector_size;
/* Read directory */
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
if (ipod_seek(ipod, ipod->start + ipod->diroffset - x) < 0) {
fprintf(stderr,"[ERR] Seek to diroffset (%08x) failed.\n",(unsigned)ipod->diroffset);
return -1;
}
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -1536,7 +1536,7 @@ int read_directory(struct ipod_t* ipod)
ipod->diroffset += ipod->sector_size - x;
n=ipod_read(ipod, ipod->sector_size);
if (n < 0) {
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
@ -1544,7 +1544,7 @@ int read_directory(struct ipod_t* ipod)
}
ipod->ososimage = -1;
while ((ipod->nimages < MAX_IMAGES) && (p < (ipod->sectorbuf + x + 400)) &&
while ((ipod->nimages < MAX_IMAGES) && (p < (ipod->sectorbuf + x + 400)) &&
((memcmp(p,"!ATA",4)==0) || (memcmp(p,"DNAN",4)==0))) {
p+=4;
if (memcmp(p,"soso",4)==0) {
@ -1823,7 +1823,7 @@ int ipod_scan(struct ipod_t* ipod)
}
#ifdef __WIN32__
printf("[INFO] Ipod found - %s (\"%s\") - disk device %d\n",
printf("[INFO] Ipod found - %s (\"%s\") - disk device %d\n",
ipod->modelstr,ipod->macpod ? "macpod" : "winpod",i);
#else
printf("[INFO] Ipod found - %s (\"%s\") - %s\n",
@ -1880,7 +1880,7 @@ int write_dos_partition_table(struct ipod_t* ipod)
memset(ipod->sectorbuf, 0, ipod->sector_size);
/* Now add the partition info */
for (i=0; i < 4 ; i++)
for (i=0; i < 4 ; i++)
{
p = ipod->sectorbuf + 0x1be + i*16;
@ -1932,7 +1932,7 @@ int ipod_get_xmlinfo(struct ipod_t* ipod)
return -1;
}
/* Reading directly into hdr[] causes problems (for an unknown reason) on
/* Reading directly into hdr[] causes problems (for an unknown reason) on
win32 */
memcpy(hdr, buf, sizeof(hdr));
@ -1940,7 +1940,7 @@ int ipod_get_xmlinfo(struct ipod_t* ipod)
psize = npages * 0xf8; /* Hopefully this is enough. */
ipod->xmlinfo = malloc(psize);
ipod->xmlinfo = malloc(psize);
ipod->xmlinfo_len = 0;
if (ipod->xmlinfo == NULL) {
@ -1949,7 +1949,7 @@ int ipod_get_xmlinfo(struct ipod_t* ipod)
}
p = ipod->xmlinfo;
for (i=0; i < npages; i++) {
if (ipod_scsi_inquiry(ipod, hdr[i+4], buf, sizeof(buf)) < 0) {
fprintf(stderr,"[ERR] Sending SCSI Command failed.\n");
@ -1966,7 +1966,7 @@ int ipod_get_xmlinfo(struct ipod_t* ipod)
memcpy(p, buf + 4, buf[3]);
p += buf[3];
ipod->xmlinfo_len += buf[3];
ipod->xmlinfo_len += buf[3];
}
/* NULL-terminate the XML info */
@ -1991,4 +1991,3 @@ void ipod_get_ramsize(struct ipod_t* ipod)
ipod->ramsize = atoi(p + sizeof(needle) - 1);
}
}