mirror of
https://github.com/wiiu-env/libfat.git
synced 2024-11-22 18:09:17 +01:00
Reload partition boot sector when sector 0 is an MBR
This commit is contained in:
parent
94c4eac0cb
commit
198df1272d
@ -103,7 +103,7 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
|
||||
uint8_t sectorBuffer[BYTES_PER_READ] = {0};
|
||||
|
||||
// Read first sector of disc
|
||||
if ( !_FAT_disc_readSectors (disc, 0, 1, sectorBuffer)) {
|
||||
if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -130,12 +130,20 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
|
||||
for (i=0x1BE; (i < 0x1FE) && (sectorBuffer[i+0x04] == 0x00); i+= 0x10);
|
||||
}
|
||||
|
||||
// Go to first valid partition
|
||||
if ( i != 0x1FE) {
|
||||
// Make sure it found a partition
|
||||
// Go to first valid partition
|
||||
startSector = u8array_to_u32(sectorBuffer, 0x8 + i);
|
||||
// Load the BPB
|
||||
if (!_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
|
||||
return NULL;
|
||||
}
|
||||
// Make sure it is a valid BPB
|
||||
if ( (sectorBuffer[BPB_bootSig_55] != 0x55) || (sectorBuffer[BPB_bootSig_AA] != 0xAA)) {
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
startSector = 0; // No partition found, assume this is a MBR free disk
|
||||
// No partition found, assume this is a MBR free disk
|
||||
startSector = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,11 +154,6 @@ PARTITION* _FAT_partition_constructor (const DISC_INTERFACE* disc, uint32_t cach
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Read in boot sector
|
||||
if ( !_FAT_disc_readSectors (disc, startSector, 1, sectorBuffer)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
partition = (PARTITION*) _FAT_mem_allocate (sizeof(PARTITION));
|
||||
if (partition == NULL) {
|
||||
return NULL;
|
||||
@ -253,8 +256,10 @@ PARTITION* _FAT_partition_getPartitionFromPath (const char* path) {
|
||||
devops = GetDeviceOpTab (path);
|
||||
|
||||
if (!devops) {
|
||||
iprintf ("\n%s %d\n", __FILE__, __LINE__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
iprintf ("\n%s %d\n", __FILE__, __LINE__);
|
||||
return (PARTITION*)devops->deviceData;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user