9bootfat: handle extended partitions
This commit is contained in:
parent
5be936a192
commit
76c3214389
|
@ -314,7 +314,7 @@ conffat(Fat *fat, void *buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
findfat(Fat *fat, int drive)
|
findfat(Fat *fat, int drive, ulong xbase, ulong lba)
|
||||||
{
|
{
|
||||||
struct {
|
struct {
|
||||||
uchar status;
|
uchar status;
|
||||||
|
@ -327,21 +327,35 @@ findfat(Fat *fat, int drive)
|
||||||
uchar buf[Sectsz];
|
uchar buf[Sectsz];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if(readsect(drive, 0, buf))
|
if(xbase == 0)
|
||||||
|
xbase = lba;
|
||||||
|
if(readsect(drive, lba, buf))
|
||||||
return -1;
|
return -1;
|
||||||
if(buf[0x1fe] != 0x55 || buf[0x1ff] != 0xAA)
|
if(buf[0x1fe] != 0x55 || buf[0x1ff] != 0xAA)
|
||||||
return -1;
|
return -1;
|
||||||
p = (void*)&buf[0x1be];
|
p = (void*)&buf[0x1be];
|
||||||
for(i=0; i<4; i++){
|
for(i=0; i<4; i++){
|
||||||
if(p[i].status != 0x80)
|
switch(p[i].typ){
|
||||||
|
case 0x05:
|
||||||
|
case 0x0f:
|
||||||
|
case 0x85:
|
||||||
|
/* extended partitions */
|
||||||
|
if(!findfat(fat, drive, xbase, xbase + GETLONG(p[i].lba)))
|
||||||
|
return 0;
|
||||||
|
/* no break */
|
||||||
|
case 0x00:
|
||||||
continue;
|
continue;
|
||||||
fat->drive = drive;
|
default:
|
||||||
fat->partlba = *((ulong*)p[i].lba);
|
if(p[i].status != 0x80)
|
||||||
if(readsect(drive, fat->partlba, buf))
|
continue;
|
||||||
continue;
|
fat->drive = drive;
|
||||||
if(conffat(fat, buf))
|
fat->partlba = lba + GETLONG(p[i].lba);
|
||||||
continue;
|
if(readsect(drive, fat->partlba, buf))
|
||||||
return 0;
|
continue;
|
||||||
|
if(conffat(fat, buf))
|
||||||
|
continue;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -358,7 +372,7 @@ start(void *sp)
|
||||||
/* drive passed in DL */
|
/* drive passed in DL */
|
||||||
drive = ((ushort*)sp)[5] & 0xFF;
|
drive = ((ushort*)sp)[5] & 0xFF;
|
||||||
|
|
||||||
if(findfat(&fat, drive)){
|
if(findfat(&fat, drive, 0, 0)){
|
||||||
print("no fat\r\n");
|
print("no fat\r\n");
|
||||||
halt();
|
halt();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue