Fix SIGBUS through unaligned access to FAT superblocks.

SPARCs do not like unaligned halfword access and throw SIGBUS.
Read data "manually" instead.

Tested on Solaris 8/SPARC with gcc 2.95.3.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
bitmap-optimize
Matthias Andree 2006-05-30 15:47:12 +02:00
parent 0ac93a00c9
commit 94fa1108ee
1 changed files with 7 additions and 4 deletions

View File

@ -253,7 +253,7 @@ static int probe_fat(struct blkid_probe *probe,
struct msdos_super_block *ms = (struct msdos_super_block *) buf;
struct vfat_dir_entry *dir;
char serno[10];
const unsigned char *label = 0, *vol_label = 0;
const unsigned char *label = 0, *vol_label = 0, *tmp;
unsigned char *vol_serno;
int label_len = 0, maxloop = 100;
__u16 sector_size, dir_entries, reserved;
@ -261,14 +261,17 @@ static int probe_fat(struct blkid_probe *probe,
__u32 buf_size, start_data_sect, next, root_start, root_dir_entries;
/* sector size check */
sector_size = blkid_le16(*((__u16 *) &ms->ms_sector_size));
tmp = &ms->ms_sector_size;
sector_size = tmp[0] + tmp[1] << 8;
if (sector_size != 0x200 && sector_size != 0x400 &&
sector_size != 0x800 && sector_size != 0x1000)
return 1;
dir_entries = blkid_le16(*((__u16 *) &ms->ms_dir_entries));
tmp = &ms->ms_dir_entries;
dir_entries = tmp[0] + tmp[1] << 8;
reserved = blkid_le16(ms->ms_reserved);
sect_count = blkid_le16(*((__u16 *) &ms->ms_sectors));
tmp = &ms->ms_sectors;
sect_count = tmp[0] + tmp[1] << 8;
if (sect_count == 0)
sect_count = blkid_le32(ms->ms_total_sect);