From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9605050924.AA29357@nova.tat.physik.uni-tuebingen.de> Date: Sat, 4 May 1996 17:39:20 +0200 (MET DST) From: Harald Koenig Subject: fix for some kernel unaligned accesses Hi, this fix (for 1.3.97) fixes some alignment problems for alpha for fat (msdos) file system. the problem in scsicam.c is triggered when running "cfdisk". Harald ------------------------------------------------------------------------------- --- mnt/soft/linux/fs/fat/inode.c Mon Apr 22 22:42:35 1996 +++ linux/fs/fat/inode.c Fri May 3 20:57:49 1996 @@ -242,7 +242,11 @@ #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0) /* don't divide by zero */ +#ifdef __alpha__ + logical_sector_size = CF_LE_W(b->sector_size[0] | b->sector_size[1]<<8); +#else logical_sector_size = CF_LE_W(*(unsigned short *) &b->sector_size); +#endif sector_mult = logical_sector_size >> SECTOR_BITS; MSDOS_SB(sb)->cluster_size = b->cluster_size*sector_mult; MSDOS_SB(sb)->fats = b->fats; @@ -250,14 +254,24 @@ MSDOS_SB(sb)->fat_length = CF_LE_W(b->fat_length)*sector_mult; MSDOS_SB(sb)->dir_start = (CF_LE_W(b->reserved)+b->fats*CF_LE_W( b->fat_length))*sector_mult; +#ifdef __alpha__ + MSDOS_SB(sb)->dir_entries = CF_LE_W(b->dir_entries[0] | b->dir_entries[1]<<8); +#else MSDOS_SB(sb)->dir_entries = CF_LE_W(*((unsigned short *) &b->dir_entries )); +#endif MSDOS_SB(sb)->data_start = MSDOS_SB(sb)->dir_start+ROUND_TO_MULTIPLE(( MSDOS_SB(sb)->dir_entries << MSDOS_DIR_BITS) >> SECTOR_BITS, sector_mult); +#ifdef __alpha__ + data_sectors = (CF_LE_W(b->sectors[0] | b->sectors[1]<<8) ? + CF_LE_W(b->sectors[0] | b->sectors[1]<<8) : + CF_LE_L(b->total_sect))*sector_mult-MSDOS_SB(sb)->data_start; +#else data_sectors = (CF_LE_W(*((unsigned short *) &b->sectors)) ? CF_LE_W(*((unsigned short *) &b->sectors)) : CF_LE_L(b->total_sect))*sector_mult-MSDOS_SB(sb)->data_start; +#endif error = !b->cluster_size || !sector_mult; if (!error) { MSDOS_SB(sb)->clusters = b->cluster_size ? data_sectors/ --- mnt/soft/linux/drivers/scsi/scsicam.c Thu Dec 14 15:59:41 1995 +++ linux/drivers/scsi/scsicam.c Fri May 3 18:17:59 1996 @@ -87,7 +87,7 @@ struct partition *p, *largest = NULL; int i, largest_cyl; int cyl, ext_cyl, end_head, end_cyl, end_sector; - unsigned int logical_end, physical_end, ext_physical_end; + unsigned int logical_end, physical_end, ext_physical_end, tmp; if (*(unsigned short *) (bh->b_data+510) == 0xAA55) { @@ -121,7 +121,13 @@ end_head * end_sector + end_sector; /* This is the actual _sector_ number at the end */ +#ifdef __alpha__ + memcpy(&logical_end, &largest->start_sect, sizeof(int)); + memcpy(&tmp, &largest->nr_sects, sizeof(int)); + logical_end += tmp; +#else logical_end = largest->start_sect + largest->nr_sects; +#endif /* This is for >1023 cylinders */ ext_cyl= (logical_end-(end_head * end_sector + end_sector)) -- All SCSI disks will from now on ___ _____ be required to send an email notice 0--,| /OOOOOOO\ 24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\ \ \/OOOOOOOOOOOOOOO\ \ OOOOOOOOOOOOOOOOO|// Harald Koenig, \/\/\/\/\/\/\/\/\/ Inst.f.Theoret.Astrophysik // / \\ \ koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^