Hello!

I've had a chance to try the current version of GRUB on FreeBSD 2.2.5
There were minor compilation problems. Some of the types defined in
stage2/defs.h are defined differently in the system headers.

Those definitions where only used in the filesystem code.
In my opinion, it is bad to use types like time_t for describing
filesystems.

The size of time_t may grow, but a disk written in 1999 should remain
readable in 2038 (when sizeof(time_t) will certainly be more than 4)

So I've just prepended `mach_' to the offending types. It is Mach code
that describes filesystems in this broken way.

ChangeLog:
        * stage2/defs.h: rename time_t to mach_daddr_t, daddr_t to
        mach_daddr_t, uid_t to mach_uid_t, gid_t to mach_gid_t
        * stage2/fs.h: Likewise
        * stage2/disk_inode.h: Likewise

There have been no other problems. /sbin/grub, stage1 and stage2 are
functional.

Pavel Roskin
--- stage2/defs.h       Thu Jun 24 04:03:14 1999
+++ stage2/defs.h       Tue Sep 28 00:58:13 1999
@@ -56,13 +56,13 @@
   }
 quad;                          /* an 8-byte item */
 
-typedef unsigned int time_t;   /* an unsigned int */
-typedef unsigned int daddr_t;  /* an unsigned int */
+typedef unsigned int mach_time_t;      /* an unsigned int */
+typedef unsigned int mach_daddr_t;     /* an unsigned int */
 typedef unsigned int mach_off_t;       /* another unsigned int */
 
-typedef unsigned short uid_t;
-typedef unsigned short gid_t;
-typedef unsigned int ino_t;
+typedef unsigned short mach_uid_t;
+typedef unsigned short mach_gid_t;
+typedef unsigned int mach_ino_t;
 
 #define        NBBY    8
 
--- stage2/disk_inode.h Thu Jun 24 04:03:15 1999
+++ stage2/disk_inode.h Tue Sep 28 01:01:19 1999
@@ -56,27 +56,27 @@
 #define        FFS_NDADDR      12      /* direct addresses in inode */
 #define        FFS_NIADDR      3       /* indirect addresses in inode */
 
-#define        FFS_MAX_FASTLINK_SIZE   ((FFS_NDADDR + FFS_NIADDR) * sizeof(daddr_t))
+#define        FFS_MAX_FASTLINK_SIZE   ((FFS_NDADDR + FFS_NIADDR) * 
+sizeof(mach_daddr_t))
 
 struct icommon
   {
     u_short ic_mode;           /*  0: mode and type of file */
     short ic_nlink;            /*  2: number of links to file */
-    uid_t ic_uid;              /*  4: owner's user id */
-    gid_t ic_gid;              /*  6: owner's group id */
+    mach_uid_t ic_uid;         /*  4: owner's user id */
+    mach_gid_t ic_gid;         /*  6: owner's group id */
     quad ic_size;              /*  8: number of bytes in file */
-    time_t ic_atime;           /* 16: time last accessed */
+    mach_time_t ic_atime;              /* 16: time last accessed */
     int ic_atspare;
-    time_t ic_mtime;           /* 24: time last modified */
+    mach_time_t ic_mtime;              /* 24: time last modified */
     int ic_mtspare;
-    time_t ic_ctime;           /* 32: last time inode changed */
+    mach_time_t ic_ctime;              /* 32: last time inode changed */
     int ic_ctspare;
     union
       {
        struct
          {
-           daddr_t Mb_db[FFS_NDADDR];  /* 40: disk block addresses */
-           daddr_t Mb_ib[FFS_NIADDR];  /* 88: indirect blocks */
+           mach_daddr_t Mb_db[FFS_NDADDR];     /* 40: disk block addresses */
+           mach_daddr_t Mb_ib[FFS_NIADDR];     /* 88: indirect blocks */
          }
        ic_Mb;
        char ic_Msymlink[FFS_MAX_FASTLINK_SIZE];
--- stage2/fs.h Thu Jun 24 04:03:19 1999
+++ stage2/fs.h Tue Sep 28 01:02:01 1999
@@ -70,8 +70,8 @@
 #define SBSIZE         8192
 #define        BBOFF           ((mach_off_t)(0))
 #define        SBOFF           ((mach_off_t)(BBOFF + BBSIZE))
-#define        BBLOCK          ((daddr_t)(0))
-#define        SBLOCK          ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
+#define        BBLOCK          ((mach_daddr_t)(0))
+#define        SBLOCK          ((mach_daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
 
 /*
  * Addresses stored in inodes are capable of addressing fragments
@@ -98,7 +98,7 @@
  * this purpose, however numerous dump tapes make this
  * assumption, so we are stuck with it)
  */
-#define        ROOTINO         ((ino_t)2)      /* i number of all roots */
+#define        ROOTINO         ((mach_ino_t)2) /* i number of all roots */
 
 /*
  * MINBSIZE is the smallest allowable block size.
@@ -147,13 +147,13 @@
   {
     int xxx1;                  /* struct       fs *fs_link; */
     int xxx2;                  /* struct       fs *fs_rlink; */
-    daddr_t fs_sblkno;         /* addr of super-block in filesys */
-    daddr_t fs_cblkno;         /* offset of cyl-block in filesys */
-    daddr_t fs_iblkno;         /* offset of inode-blocks in filesys */
-    daddr_t fs_dblkno;         /* offset of first data after cg */
+    mach_daddr_t fs_sblkno;            /* addr of super-block in filesys */
+    mach_daddr_t fs_cblkno;            /* offset of cyl-block in filesys */
+    mach_daddr_t fs_iblkno;            /* offset of inode-blocks in filesys */
+    mach_daddr_t fs_dblkno;            /* offset of first data after cg */
     int fs_cgoffset;           /* cylinder group offset in cylinder */
     int fs_cgmask;             /* used to calc mod fs_ntrak */
-    time_t fs_time;            /* last time written */
+    mach_time_t fs_time;               /* last time written */
     int fs_size;               /* number of blocks in fs */
     int fs_dsize;              /* number of data blocks in fs */
     int fs_ncg;                        /* number of cylinder groups */
@@ -190,7 +190,7 @@
     int fs_headswitch;         /* head switch time, usec */
     int fs_trkseek;            /* track-to-track seek, usec */
 /* sizes determined by number of cylinder groups and their sizes */
-    daddr_t fs_csaddr;         /* blk addr of cyl grp summary area */
+    mach_daddr_t fs_csaddr;            /* blk addr of cyl grp summary area */
     int fs_cssize;             /* size of cyl grp summary area */
     int fs_cgsize;             /* cylinder group size */
 /* these fields are derived from the hardware */
@@ -275,7 +275,7 @@
   {
     int xxx1;                  /* struct       cg *cg_link; */
     int cg_magic;              /* magic number */
-    time_t cg_time;            /* time last written */
+    mach_time_t cg_time;               /* time last written */
     int cg_cgx;                        /* we are the cgx'th cylinder group */
     short cg_ncyl;             /* number of cyl's this cg */
     short cg_niblk;            /* number of inode blocks this cg */
@@ -324,7 +324,7 @@
   {
     int xxx1;                  /* struct       ocg *cg_link; */
     int xxx2;                  /* struct       ocg *cg_rlink; */
-    time_t cg_time;            /* time last written */
+    mach_time_t cg_time;               /* time last written */
     int cg_cgx;                        /* we are the cgx'th cylinder group */
     short cg_ncyl;             /* number of cyl's this cg */
     short cg_niblk;            /* number of inode blocks this cg */
@@ -353,7 +353,7 @@
  * Cylinder group macros to locate things in cylinder groups.
  * They calc file system addresses of cylinder group data structures.
  */
-#define        cgbase(fs, c)   ((daddr_t)((fs)->fs_fpg * (c)))
+#define        cgbase(fs, c)   ((mach_daddr_t)((fs)->fs_fpg * (c)))
 #define cgstart(fs, c) \
        (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask)))
 #define        cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno)      /* super blk 
*/
@@ -370,7 +370,7 @@
 #define        itoo(fs, x)     ((x) % INOPB(fs))
 #define        itog(fs, x)     ((x) / (fs)->fs_ipg)
 #define        itod(fs, x) \
-       ((daddr_t)(cgimin(fs, itog(fs, x)) + \
+       ((mach_daddr_t)(cgimin(fs, itog(fs, x)) + \
        (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
 
 /*

Reply via email to