forked from len0rd/rockbox
Fix bpb_is_sane() cluster size calculation for non-512 byte sectors.
bpb_is_sane() used to effectively multiplying the sector size (relative to 512 bytes) twice, which meant that filesystems with e.g. 2K sectors and 32 sectors per cluster were rejected because while this adds up to 64K clusters (i.e. the upper limit), the calculation wrongly came to 256K. This bug tends to affect 5.5G ipods when formatted using dosfstools. Change-Id: Ia3f1e1303b2af953f497ccdbf23cd49c3d72e46a
This commit is contained in:
parent
da94b6303e
commit
646edc594f
1 changed files with 9 additions and 4 deletions
|
|
@ -624,13 +624,18 @@ static int bpb_is_sane(IF_MV_NONVOID(struct bpb* fat_bpb))
|
|||
fat_bpb->bpb_bytspersec);
|
||||
return -1;
|
||||
}
|
||||
if((long)fat_bpb->bpb_secperclus * (long)fat_bpb->bpb_bytspersec
|
||||
> 128L*1024L)
|
||||
if((long)fat_bpb->bpb_secperclus * SECTOR_SIZE > 128L*1024L)
|
||||
{
|
||||
/* We don't multiply by bpb_bytspersec here, because
|
||||
* back in fat_mount_internal() bpb_secperclus has been
|
||||
* "normalised" to 512 byte clusters, by multiplying with
|
||||
* secmult. */
|
||||
DEBUGF( "bpb_is_sane() - Error: cluster size is larger than 128K "
|
||||
"(%d * %d = %d)\n",
|
||||
fat_bpb->bpb_bytspersec, fat_bpb->bpb_secperclus,
|
||||
fat_bpb->bpb_bytspersec * fat_bpb->bpb_secperclus);
|
||||
fat_bpb->bpb_bytspersec,
|
||||
fat_bpb->bpb_secperclus / (fat_bpb->bpb_bytspersec / SECTOR_SIZE),
|
||||
fat_bpb->bpb_bytspersec * fat_bpb->bpb_secperclus /
|
||||
(fat_bpb->bpb_bytspersec / SECTOR_SIZE));
|
||||
return -2;
|
||||
}
|
||||
if(fat_bpb->bpb_numfats != 2)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue