Linus et al,

Here is a patch which allows HFS to be used on ARM, which packs the
structure members.  It has been tested a good few months ago, and
I've not had any complaints from it being in there from the ARM
community (someone actually uses HFS on ARM!)

Anyway, I'd like to get this in before 2.4 comes out, so I'm
copying this to Linux, fs-devel, as well as Adrian who I understand
was the original author of this code.

diff -urN linux-orig/fs/hfs/catalog.c linux/fs/hfs/catalog.c
--- linux-orig/fs/hfs/catalog.c Fri Jun  4 21:30:25 1999
+++ linux/fs/hfs/catalog.c      Thu Dec 30 23:53:30 1999
@@ -60,7 +60,7 @@
        hfs_byte_t      RExtRec[12];    /* first extent record
                                           for the resource fork */
        hfs_lword_t     Resrv;          /* reserved by Apple */
-} FIL_REC;
+} __attribute__((packed)) FIL_REC;
 
 /* the catalog record for a directory */
 typedef struct {
@@ -74,14 +74,14 @@
        hfs_dinfo_t     UsrInfo;        /* data used by the Finder */
        hfs_dxinfo_t    FndrInfo;       /* more data used by Finder */
        hfs_byte_t      Resrv[16];      /* reserved by Apple */
-} DIR_REC;
+} __attribute__((packed)) DIR_REC;
 
 /* the catalog record for a thread */
 typedef struct {
        hfs_byte_t              Reserv[8];      /* reserved by Apple */
        hfs_lword_t             ParID;          /* CNID of parent directory */
        struct hfs_name         CName;          /* The name of this entry */
-} THD_REC;
+}  __attribute__((packed)) THD_REC;
 
 /* A catalog tree record */
 struct hfs_cat_rec {
@@ -92,7 +92,7 @@
                DIR_REC dir;
                THD_REC thd;
        } u;
-};
+} __attribute__((packed));
 
 /*================ File-local variables ================*/
  
diff -urN linux-orig/fs/hfs/file_hdr.c linux/fs/hfs/file_hdr.c
--- linux-orig/fs/hfs/file_hdr.c        Sun Feb 27 09:45:04 2000
+++ linux/fs/hfs/file_hdr.c     Sun Feb 27 10:16:36 2000
@@ -158,7 +158,7 @@
         hfs_byte_t     filler[16];
         hfs_word_t     entries;
         hfs_byte_t     descrs[12*HFS_HDR_MAX];
-};
+}  __attribute__((packed));
 
 /*================ File-local functions ================*/
 
diff -urN linux-orig/fs/hfs/hfs.h linux/fs/hfs/hfs.h
--- linux-orig/fs/hfs/hfs.h     Fri Feb 11 20:25:43 2000
+++ linux/fs/hfs/hfs.h  Fri Feb 11 21:31:08 2000
@@ -130,7 +130,7 @@
 struct hfs_name {
        hfs_byte_t      Len;
        hfs_byte_t      Name[31];
-};
+} __attribute__((packed));
 
 typedef struct {
        hfs_word_t      v;
@@ -150,21 +150,21 @@
        hfs_word_t       fdFlags;
        hfs_point_t      fdLocation;
        hfs_word_t       fdFldr;
-} hfs_finfo_t;
+} __attribute__((packed)) hfs_finfo_t;
 
 typedef struct {
        hfs_word_t      fdIconID;
        hfs_byte_t      fdUnused[8];
        hfs_word_t      fdComment;
        hfs_lword_t     fdPutAway;
-} hfs_fxinfo_t;
+} __attribute__((packed)) hfs_fxinfo_t;
 
 typedef struct {
        hfs_rect_t      frRect;
        hfs_word_t      frFlags;
        hfs_point_t     frLocation;
        hfs_word_t      frView;
-} hfs_dinfo_t;
+} __attribute__((packed)) hfs_dinfo_t;
 
 typedef struct {
        hfs_point_t     frScroll;
@@ -172,7 +172,7 @@
        hfs_word_t      frUnused;
        hfs_word_t      frComment;
        hfs_lword_t     frPutAway;
-} hfs_dxinfo_t;
+} __attribute__((packed)) hfs_dxinfo_t;
 
 union hfs_finder_info {
        struct {
@@ -189,7 +189,7 @@
 struct hfs_bkey {
        hfs_byte_t      KeyLen;         /* number of bytes in the key */
        hfs_byte_t      value[1];       /* (KeyLen) bytes of key */
-};
+} __attribute__((packed));
 
 /* Cast to a pointer to a generic bkey */
 #define        HFS_BKEY(X)     (((void)((X)->KeyLen)), ((struct hfs_bkey *)(X)))
@@ -200,7 +200,7 @@
        hfs_byte_t      Resrv1; /* padding */
        hfs_lword_t     ParID;  /* CNID of the parent dir */
        struct hfs_name CName;  /* The filename of the entry */
-};
+} __attribute__((packed));
 
 /* The key used in the extents b-tree: */
 struct hfs_ext_key {
@@ -208,7 +208,7 @@
        hfs_byte_t      FkType; /* HFS_FK_{DATA,RSRC} */
        hfs_lword_t     FNum;   /* The File ID of the file */
        hfs_word_t      FABN;   /* allocation blocks number*/
-};
+} __attribute__((packed));
 
 /*======== Data structures kept in memory ========*/
 
diff -urN linux-orig/fs/hfs/hfs_btree.h linux/fs/hfs/hfs_btree.h
--- linux-orig/fs/hfs/hfs_btree.h       Sat Jan 22 19:46:33 2000
+++ linux/fs/hfs/hfs_btree.h    Fri Jan 21 20:50:17 2000
@@ -90,7 +90,7 @@
         hfs_byte_t  bthResv2;   /* reserved */
         hfs_lword_t bthAtrb;    /* (F) attributes */
         hfs_lword_t bthResv3[16]; /* Reserved */
-};
+} __attribute__((packed));
 
 /*
  * struct NodeDescriptor
@@ -112,7 +112,7 @@
        hfs_byte_t  ndNHeight;  /* (F) The level of this node (leaves=1) */
        hfs_word_t  ndNRecs;    /* (V) The number of records in this node */
        hfs_word_t  ndResv2;    /* Reserved */
-};
+} __attribute__((packed));
 
 /*
  * typedef hfs_cmpfn
diff -urN linux-orig/fs/hfs/mdb.c linux/fs/hfs/mdb.c
--- linux-orig/fs/hfs/mdb.c     Fri Jun  4 21:30:25 1999
+++ linux/fs/hfs/mdb.c  Thu Dec 30 23:53:30 1999
@@ -71,7 +71,7 @@
        hfs_byte_t      drXTExtRec[12]; /* extents B-tree's first 3 extents */
        hfs_lword_t     drCTFlSize;     /* bytes in the catalog B-tree */
        hfs_byte_t      drCTExtRec[12]; /* catalog B-tree's first 3 extents */
-};
+} __attribute__((packed));
 
 /*================ Global functions ================*/
 
diff -urN linux-orig/fs/hfs/part_tbl.c linux/fs/hfs/part_tbl.c
--- linux-orig/fs/hfs/part_tbl.c        Sun Jan  4 18:40:17 1998
+++ linux/fs/hfs/part_tbl.c     Thu Dec 30 23:53:30 1999
@@ -77,7 +77,7 @@
                hfs_lword_t     pdSize;
                hfs_lword_t     pdFSID;
        }       pdEntry[42];
-};
+} __attribute__((packed));
 
 /*================ File-local functions ================*/
 

   _____
  |_____| ------------------------------------------------- ---+---+-
  |   |         Russell King        [EMAIL PROTECTED]      --- ---
  | | | |   http://www.arm.linux.org.uk/~rmk/aboutme.html    /  /  |
  | +-+-+                                                     --- -+-
  /   |               THE developer of ARM Linux              |+| /|\
 /  | | |                                                     ---  |
    +-+-+ -------------------------------------------------  /\\\  |

Reply via email to