Re: VFAT Madness

Gabriel Paubert (paubert@iram.es)
Tue, 1 Jul 1997 10:41:58 +0200 (METDST)


On Wed, 2 Jul 1997, Joe Pranevich wrote:

> Okay, we'll let's compare your origional (bad) one with the "real"
> struct for the block and see if we see asnything blatant. (I could
> easily make an error here, I'm doing this by hand as I don't have a
> compiler handy.)
>
> __s8 ignored[3];
> __s8 system_id[8]; -- This is the MSWIN4.1 signature that it leaves.
> OSR 2. Feh.
> __u8 sector_size[2]; -- 0x0 and 0x2 (2 -> a bit low? Or am I reading
> this wrong?)

It's little endian (:-(), so it means 2*256+0=512, which is right ! This
16 bit quantity is declared this way to avoid automatic structure
alignment by the compiler which would skip one byte. There are other ways
to force the compiler to pack structures, however accessing it as
sector_size[0]+(sector_size[1]<<8) is guaranteed to be portable, endian
independant, and to avoid alignment traps on RISC machines.

> __u8 cluster_size; -- 0x10 (16)
> __u16 reserved; -- 0x100 (256)
> __u8 fats; -- 0x2
> __u8 dir_entries[2]; -- 0x0 and 0x2

Same !

Gabriel.