Detect and reject 2nd Gen Nanos when scanning for ipods, instead of failing quietly.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14152 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2007-08-03 02:12:32 +00:00
parent e4d0f0e638
commit 564d249e66
2 changed files with 31 additions and 2 deletions

View file

@ -1038,9 +1038,20 @@ int read_directory(struct ipod_t* ipod)
}
p = sectorbuf + x;
/* A hack to detect 2nd gen Nanos - maybe there is a better way? */
if (p[0] == 0)
{
n=ipod_read(ipod, sectorbuf, ipod->sector_size);
if (n < 0) {
fprintf(stderr,"[ERR] Read of directory failed.\n");
return -1;
}
p = sectorbuf;
}
while ((ipod->nimages < MAX_IMAGES) && (p < (sectorbuf + x + 400)) &&
(memcmp(p,"!ATA",4)==0)) {
((memcmp(p,"!ATA",4)==0) || (memcmp(p,"DNAN",4)==0))) {
p+=4;
if (memcmp(p,"soso",4)==0) {
ipod->ipod_directory[ipod->nimages].ftype=FTYPE_OSOS;
@ -1220,6 +1231,15 @@ int getmodel(struct ipod_t* ipod, int ipod_version)
#ifdef WITH_BOOTOBJS
ipod->bootloader = ipodvideo;
ipod->bootloader_len = LEN_ipodvideo;
#endif
break;
case 0x100:
ipod->modelstr="2nd Generation Nano";
ipod->modelnum = 0;
ipod->targetname = NULL;
#ifdef WITH_BOOTOBJS
ipod->bootloader = NULL;
ipod->bootloader_len = 0;
#endif
break;
default:

View file

@ -348,6 +348,15 @@ int main(int argc, char* argv[])
printf("[INFO] Ipod model: %s (\"%s\")\n",ipod.modelstr,
ipod.macpod ? "macpod" : "winpod");
if (ipod.ipod_directory[0].vers == 0x10000) {
fprintf(stderr,"[ERR] *** ipodpatcher does not support the 2nd Generation Nano! ***\n");
#ifdef WITH_BOOTOBJS
printf("Press ENTER to exit ipodpatcher :");
fgets(yesno,4,stdin);
#endif
return 0;
}
if (ipod.macpod) {
print_macpod_warning();
}