[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [MiNT] FreeMiNT and cluster size
Hello Vincent,
On 22 Aug 2011 at 15:59, Vincent Rivière wrote:
>
> I have a single FAT16 partition (sizes in bytes):
> - sector size: 512
> - cluster size: 16384 (32 sectors)
>
> It works fine with EmuTOS alone, but I can't use it with FreeMiNT's
> NEWFATFS.
>
> EmuTOS provides an AHDI cookie to a PUN_INFO structure:
> http://toshyp.atari.org/en/00300b.html#PUN_INFO
>
> The field P_max_sector is defined as "the largest occurring block size
> for BIOS sectors".
> On my setup EmuTOS returns 512 in this field, and I believe this is correct.
>
I looked in pun.h in FreeMiNT, and the comment is "Max logical sec size".
> Then in FreeMiNT's sys/block_IO.c, function init_block_IO(), we can see:
> if (pun)
> cache.max_size = pun->max_sect_siz * 2L;
>
> So in my case I will get cache.max_size == 1024.
>
> Just after that, we can see:
> cache.max_size = MAX (cache.max_size, MIN_BLOCK);
> where MIN_BLOCK == 8192
>
> Finally I have cache.max_size == 8192.
>
> But later, in sys/fatfs.c, function val_bpb(), there is:
> // max = cache.max_size (8192)
> // xbpb->clsizb (16384)
> if (xbpb->clsizb > max)
> {
> FAT_ALERT (("FATFS [%c]: unitsize (%li) too small (clsizb =
> %li)!", 'A'+drv, max, xbpb->clsizb));
> FAT_ALERT (("FATFS [%c]: medium access denied", 'A'+drv));
>
> Fatally, this fails for me with "FATFS [C]: unitsize (8192) too small
> (clsizb = 16384)!" and I can't use my partition.
>
> The cache.max_size setting seems good to me, with a sensible minimum value.
> But the fatfs test comparing a cluster size with a maximum sector size
> looks totally bogus. Am I wrong ?
>
With the latter test, it looks like NEWFATFS is saying that a cluster must be
containable in a unit, which I think makes sense.
In init_block_IO(), I think it's trying to convert the logical sector size
returned by get_pun() into a cluster size, by multiplying by two. And then
with max() it's allowing for an 8K cluster size at least.
Since AFAIK, the only valid info provided by EmuTOS in the PUN_INFO structure
is max_sec_size, and that is only there to stop FreeMiNT complaining, perhaps
the easiest fix would be to change the value from EmuTOS to clsizb/2.
But I'm sure someone who actually knows what he's talking about will provide
the correct answer :-).
Roger Burrows