diff -uprN util-linux-ng-2.16.1/shlibs/blkid/src/probers/vfat.c util-linux-ng-2.16.1-new/shlibs/blkid/src/probers/vfat.c --- util-linux-ng-2.16.1/shlibs/blkid/src/probers/vfat.c 2009-08-21 15:59:30.000000000 +0200 +++ util-linux-ng-2.16.1-new/shlibs/blkid/src/probers/vfat.c 2009-10-01 21:05:26.000000000 +0200 @@ -18,6 +18,13 @@ #include "blkidP.h" +#undef STATIC_ASSERT +#ifdef __GNUC__ +# define STATIC_ASSERT(e) extern char _dummy[(e) ? 1 : -1] __attribute__((unused)) +#else +# define STATIC_ASSERT(e) extern char _dummy[(e) ? 1 : -1] +#endif + /* Yucky misaligned values */ struct vfat_super_block { /* 00*/ unsigned char vs_ignored[3]; @@ -45,7 +52,7 @@ struct vfat_super_block { /* 43*/ unsigned char vs_serno[4]; /* 47*/ unsigned char vs_label[11]; /* 52*/ unsigned char vs_magic[8]; -/* 5a*/ unsigned char vs_dummy2[164]; +/* 5a*/ unsigned char vs_dummy2[0x1fe - 0x5a]; /*1fe*/ unsigned char vs_pmagic[2]; }; @@ -58,20 +65,23 @@ struct msdos_super_block { /* 0e*/ uint16_t ms_reserved; /* 10*/ uint8_t ms_fats; /* 11*/ unsigned char ms_dir_entries[2]; -/* 13*/ unsigned char ms_sectors[2]; +/* 13*/ unsigned char ms_sectors[2]; /* =0 iff V3 or later */ /* 15*/ unsigned char ms_media; -/* 16*/ uint16_t ms_fat_length; +/* 16*/ uint16_t ms_fat_length; /* Sectors per FAT */ /* 18*/ uint16_t ms_secs_track; /* 1a*/ uint16_t ms_heads; /* 1c*/ uint32_t ms_hidden; -/* 20*/ uint32_t ms_total_sect; -/* 24*/ unsigned char ms_unknown[3]; +/* V3 BPB */ +/* 20*/ uint32_t ms_total_sect; /* iff ms_sectors == 0 */ +/* V4 BPB */ +/* 24*/ unsigned char ms_unknown[3]; /* Phys drive no., resvd, V4 sig (0x29) */ /* 27*/ unsigned char ms_serno[4]; /* 2b*/ unsigned char ms_label[11]; /* 36*/ unsigned char ms_magic[8]; -/* 3d*/ unsigned char ms_dummy2[192]; +/* 3e*/ unsigned char ms_dummy2[0x1fe - 0x3e]; /*1fe*/ unsigned char ms_pmagic[2]; }; +STATIC_ASSERT( sizeof( struct msdos_super_block) == 512); struct vfat_dir_entry { uint8_t name[11]; @@ -143,6 +153,10 @@ static int probe_fat_nomagic(blkid_probe if (!ms) return -1; + /* Old floppies have a valid MBR signature */ + if (ms->ms_pmagic[0] != 0x55 || ms->ms_pmagic[1] != 0xAA) + return 1; + /* heads check */ if (ms->ms_heads == 0) return 1;