forked from len0rd/rockbox
Consider sector size when checking cluster size
On file systems with 2048 bytes per cluster, the bpb_secperclus value gets multiplied by 4 when the meta data is loaded. This patch changes the sanity check to consider (and reverse) that multiplication before checking the cluster size. Signed-off-by: Stefan Ott <stefan@ott.net>
This commit is contained in:
parent
180cef835b
commit
63bf8e4acd
1 changed files with 6 additions and 1 deletions
|
|
@ -391,7 +391,12 @@ static int bpb_is_sane(struct bpb *fat_bpb)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fat_bpb->bpb_secperclus * fat_bpb->bpb_bytspersec > 128*1024ul)
|
/* The fat_bpb struct does not hold the raw value of bpb_bytspersec, the
|
||||||
|
* value is multiplied in cases where bpb_bytspersec != SECTOR_SIZE. We need
|
||||||
|
* to undo that multiplication before we do the sanity check. */
|
||||||
|
unsigned long secmult = fat_bpb->bpb_bytspersec / SECTOR_SIZE;
|
||||||
|
|
||||||
|
if (fat_bpb->bpb_secperclus * fat_bpb->bpb_bytspersec / secmult > 128*1024ul)
|
||||||
{
|
{
|
||||||
DEBUGF("%s() - Error: cluster size is larger than 128K "
|
DEBUGF("%s() - Error: cluster size is larger than 128K "
|
||||||
"(%lu * %lu = %lu)\n", __func__,
|
"(%lu * %lu = %lu)\n", __func__,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue