linux-mips-fnet
[Top] [All Lists]

FAT alignment problem

To: linux-mips@fnet.fr
Subject: FAT alignment problem
From: Systemkennung Linux <linux@mailhost.uni-koblenz.de>
Date: Fri, 3 May 1996 22:25:58 +0200 (MET DST)
-----BEGIN PGP SIGNED MESSAGE-----

Hi,

the following patch fixes an alignment problem in the FAT filesystem
that makes the kernel panic with an ADEL exception otherwise.

  Ralf


- --- linux-1.3.96.orig/fs/fat/inode.c  Sun Apr 21 10:11:13 1996
+++ linux-1.3.96/fs/fat/inode.c Fri May  3 21:44:05 1996
@@ -3,6 +3,8 @@
  *
  *  Written 1992,1993 by Werner Almesberger
  *  VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
+ *
+ * 3 May 1996  Fixed alignment problems for RISC architectures.
  */
 
 #define __NO_VERSION__
@@ -242,7 +244,13 @@
 #define ROUND_TO_MULTIPLE(n,m) ((n) && (m) ? (n)+(m)-1-((n)-1)%(m) : 0)
     /* don't divide by zero */
 
- -     logical_sector_size = CF_LE_W(*(unsigned short *) &b->sector_size);
+       /*
+        * There are some misaligned 16 bit members in the msdos bootblock
+        * that we decode manualy without the CF_LE_W() macro.  This avoids
+        * problems on architecture with restrictive alignment rules like
+        * MIPS or Alpha -- Ralf
+        */
+       logical_sector_size = b->sector_size[0] | (b->sector_size[1] << 8);
        sector_mult = logical_sector_size >> SECTOR_BITS;
        MSDOS_SB(sb)->cluster_size = b->cluster_size*sector_mult;
        MSDOS_SB(sb)->fats = b->fats;
@@ -250,13 +258,13 @@
        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;
- -     MSDOS_SB(sb)->dir_entries = CF_LE_W(*((unsigned short *) &b->dir_entries
- -         ));
+       MSDOS_SB(sb)->dir_entries = (b->dir_entries[0] |
+                                   (b->dir_entries[1] << 8));
        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);
- -     data_sectors = (CF_LE_W(*((unsigned short *) &b->sectors)) ?
- -         CF_LE_W(*((unsigned short *) &b->sectors)) :
+       data_sectors = ((b->sectors[0] | (b->sectors[1] << 8)) ?
+           (b->sectors[0] | (b->sectors[1] << 8)) :
            CF_LE_L(b->total_sect))*sector_mult-MSDOS_SB(sb)->data_start;
        error = !b->cluster_size || !sector_mult;
        if (!error) {
@@ -293,7 +301,7 @@
                       
MSDOS_SB(sb)->fats,MSDOS_SB(sb)->fat_start,MSDOS_SB(sb)->fat_length,
                       MSDOS_SB(sb)->dir_start,MSDOS_SB(sb)->dir_entries,
                       MSDOS_SB(sb)->data_start,
- -                    CF_LE_W(*(unsigned short *) &b->sectors),
+                      (b->sectors[0] | (b->sectors[1] << 8)),
                       (unsigned long)b->total_sect,logical_sector_size);
                printk ("Transaction block size = %d\n",blksize);
        }

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAgUBMYpr1Eckbl6vezDBAQEqbAP/WIscK4B0pcogF91AxHJ9l9KWtW0LOczO
+C4jcT3EevabEhtqK/USRLaxuNIrf1iT69LWU3V9iPLjpkLvXOY4P9khdlzKFF4y
LiLmdflBINMJIpQDK81L4xAUwA5wZRaF6oMNIXPvqkQ+eNJW9TvWlYHgjjkZ2l+Q
HWHJzH7r3w4=
=Ztzr
-----END PGP SIGNATURE-----

<Prev in Thread] Current Thread [Next in Thread>
  • FAT alignment problem, Systemkennung Linux <=