split out that part of inode.h that is relevant to the disk node
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 25 Oct 1989 11:35:29 +0000 (03:35 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 25 Oct 1989 11:35:29 +0000 (03:35 -0800)
SCCS-vsn: sys/ufs/ffs/dinode.h 7.6
SCCS-vsn: sys/ufs/ufs/dinode.h 7.6

usr/src/sys/ufs/ffs/dinode.h
usr/src/sys/ufs/ufs/dinode.h

index 3a23d29..dd34866 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)dinode.h    7.5 (Berkeley) %G%
+ *     @(#)dinode.h    7.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
- * The I node is the focus of all file activity in UNIX.
- * There is a unique inode allocated for each active file,
- * each current directory, each mounted-on file, text file, and the root.
- * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
- * Data in icommon is read in from permanent inode on volume.
+ * This structure defines the on-disk format of an inode.
  */
 
 #define        NDADDR  12              /* direct addresses in inode */
 #define        NIADDR  3               /* indirect addresses in inode */
 
  */
 
 #define        NDADDR  12              /* direct addresses in inode */
 #define        NIADDR  3               /* indirect addresses in inode */
 
-struct inode {
-       struct  inode *i_chain[2];      /* must be first */
-       struct  vnode i_vnode;  /* vnode associated with this inode */
-       struct  vnode *i_devvp; /* vnode for block I/O */
-       u_short i_flag;
-       dev_t   i_dev;          /* device where inode resides */
-       ino_t   i_number;       /* i number, 1-to-1 with device address */
-       long    i_id;           /* unique identifier */
-       long    i_diroff;       /* offset in dir, where we found last entry */
-       struct  fs *i_fs;       /* file sys associated with this inode */
-       struct  dquot *i_dquot; /* quota structure controlling this file */
-       struct  text *i_text;   /* text entry, if any (should be region) */
-       struct  inode *i_devlst;/* list of block device inodes */
-       off_t   i_endoff;       /* end of useful stuff in directory */
-       long    i_spare[4];
-       union {
-               daddr_t if_lastr;       /* last read (read-ahead) */
-               struct  socket *is_socket;
-               struct  {
-                       struct inode  *if_freef;        /* free list forward */
-                       struct inode **if_freeb;        /* free list back */
-               } i_fr;
-       } i_un;
-       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 */
-               quad    ic_size;        /*  8: number of bytes in file */
-               time_t  ic_atime;       /* 16: time last accessed */
-               long    ic_atspare;
-               time_t  ic_mtime;       /* 24: time last modified */
-               long    ic_mtspare;
-               time_t  ic_ctime;       /* 32: last time inode changed */
-               long    ic_ctspare;
-               daddr_t ic_db[NDADDR];  /* 40: disk block addresses */
-               daddr_t ic_ib[NIADDR];  /* 88: indirect blocks */
-               long    ic_flags;       /* 100: status, currently unused */
-               long    ic_blocks;      /* 104: blocks actually held */
-               long    ic_gen;         /* 108: generation number */
-               long    ic_spare[4];    /* 112: reserved, currently unused */
-       } i_ic;
-};
-
 struct dinode {
 struct dinode {
-       union {
-               struct  icommon di_icom;
-               char    di_size[128];
-       } di_un;
+       u_short di_mode;        /*  0: mode and type of file */
+       short   di_nlink;       /*  2: number of links to file */
+       uid_t   di_uid;         /*  4: owner's user id */
+       gid_t   di_gid;         /*  6: owner's group id */
+       quad    di_qsize;       /*  8: number of bytes in file */
+       time_t  di_atime;       /* 16: time last accessed */
+       long    di_atspare;
+       time_t  di_mtime;       /* 24: time last modified */
+       long    di_mtspare;
+       time_t  di_ctime;       /* 32: last time inode changed */
+       long    di_ctspare;
+       daddr_t di_db[NDADDR];  /* 40: disk block addresses */
+       daddr_t di_ib[NIADDR];  /* 88: indirect blocks */
+       long    di_flags;       /* 100: status, currently unused */
+       long    di_blocks;      /* 104: blocks actually held */
+       long    di_gen;         /* 108: generation number */
+       long    di_spare[4];    /* 112: reserved, currently unused */
 };
 
 };
 
-#define        i_mode          i_ic.ic_mode
-#define        i_nlink         i_ic.ic_nlink
-#define        i_uid           i_ic.ic_uid
-#define        i_gid           i_ic.ic_gid
 /* ugh! -- must be fixed */
 #if defined(vax) || defined(tahoe)
 /* ugh! -- must be fixed */
 #if defined(vax) || defined(tahoe)
-#define        i_size          i_ic.ic_size.val[0]
-#endif
-#define        i_db            i_ic.ic_db
-#define        i_ib            i_ic.ic_ib
-#define        i_atime         i_ic.ic_atime
-#define        i_mtime         i_ic.ic_mtime
-#define        i_ctime         i_ic.ic_ctime
-#define i_blocks       i_ic.ic_blocks
-#define        i_rdev          i_ic.ic_db[0]
-#define i_flags                i_ic.ic_flags
-#define i_gen          i_ic.ic_gen
-#define        i_lastr         i_un.if_lastr
-#define        i_socket        i_un.is_socket
-#define        i_forw          i_chain[0]
-#define        i_back          i_chain[1]
-#define        i_freef         i_un.i_fr.if_freef
-#define        i_freeb         i_un.i_fr.if_freeb
-
-#define di_ic          di_un.di_icom
-#define        di_mode         di_ic.ic_mode
-#define        di_nlink        di_ic.ic_nlink
-#define        di_uid          di_ic.ic_uid
-#define        di_gid          di_ic.ic_gid
-#if defined(vax) || defined(tahoe)
-#define        di_size         di_ic.ic_size.val[0]
+#define        di_size         di_qsize.val[0]
+#else
+#define        di_size         di_qsize.val[1]
 #endif
 #endif
-#define        di_db           di_ic.ic_db
-#define        di_ib           di_ic.ic_ib
-#define        di_atime        di_ic.ic_atime
-#define        di_mtime        di_ic.ic_mtime
-#define        di_ctime        di_ic.ic_ctime
-#define        di_rdev         di_ic.ic_db[0]
-#define        di_blocks       di_ic.ic_blocks
-#define        di_flags        di_ic.ic_flags
-#define        di_gen          di_ic.ic_gen
-
-#ifdef KERNEL
-struct inode *inode;           /* the inode table itself */
-struct inode *inodeNINODE;     /* the end of the inode table */
-int    ninode;                 /* number of slots in the table */
-
-u_long nextgennumber;          /* next generation number to assign */
-
-extern struct vnodeops ufs_vnodeops;   /* vnode operations for ufs */
-extern struct vnodeops blk_vnodeops;   /* vnode operations for blk devices */
+#define        di_rdev         di_db[0]
 
 
-extern ino_t   dirpref();
-#endif
-
-/* flags */
-#define        ILOCKED         0x1             /* inode is locked */
-#define        IUPD            0x2             /* file has been modified */
-#define        IACC            0x4             /* inode access time to be updated */
-#define        IWANT           0x8             /* some process waiting on lock */
-#define        ICHG            0x10            /* inode has been changed */
-#define        ISHLOCK         0x20            /* file has shared lock */
-#define        IEXLOCK         0x40            /* file has exclusive lock */
-#define        ILWAIT          0x80            /* someone waiting on file lock */
-#define        IMOD            0x100           /* inode has been modified */
-#define        IRENAME         0x200           /* inode is being renamed */
-
-/* modes */
+/* file modes */
 #define        IFMT            0170000         /* type of file */
 #define        IFCHR           0020000         /* character special */
 #define        IFDIR           0040000         /* directory */
 #define        IFMT            0170000         /* type of file */
 #define        IFCHR           0020000         /* character special */
 #define        IFDIR           0040000         /* directory */
@@ -162,67 +67,3 @@ extern ino_t        dirpref();
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
-
-#ifdef KERNEL
-/*
- * Convert between inode pointers and vnode pointers
- */
-#define VTOI(vp)       ((struct inode *)(vp)->v_data)
-#define ITOV(ip)       (&(ip)->i_vnode)
-
-/*
- * Convert between vnode types and inode formats
- */
-extern enum vtype      iftovt_tab[];
-extern int             vttoif_tab[];
-#define IFTOVT(mode)   (iftovt_tab[((mode) & IFMT) >> 13])
-#define VTTOIF(indx)   (vttoif_tab[(int)(indx)])
-
-#define MAKEIMODE(indx, mode)  (int)(VTTOIF(indx) | (mode))
-
-/*
- * Lock and unlock inodes.
- */
-#define        ILOCK(ip) { \
-       while ((ip)->i_flag & ILOCKED) { \
-               (ip)->i_flag |= IWANT; \
-               (void) sleep((caddr_t)(ip), PINOD); \
-       } \
-       (ip)->i_flag |= ILOCKED; \
-}
-
-#define        IUNLOCK(ip) { \
-       (ip)->i_flag &= ~ILOCKED; \
-       if ((ip)->i_flag&IWANT) { \
-               (ip)->i_flag &= ~IWANT; \
-               wakeup((caddr_t)(ip)); \
-       } \
-}
-
-#define        IUPDAT(ip, t1, t2, waitfor) { \
-       if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
-               (void) iupdat(ip, t1, t2, waitfor); \
-}
-
-#define        ITIMES(ip, t1, t2) { \
-       if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
-               (ip)->i_flag |= IMOD; \
-               if ((ip)->i_flag&IACC) \
-                       (ip)->i_atime = (t1)->tv_sec; \
-               if ((ip)->i_flag&IUPD) \
-                       (ip)->i_mtime = (t2)->tv_sec; \
-               if ((ip)->i_flag&ICHG) \
-                       (ip)->i_ctime = time.tv_sec; \
-               (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
-       } \
-}
-
-/*
- * This overlays the fid sturcture (see mount.h)
- */
-struct ufid {
-       u_short ufid_len;
-       ino_t   ufid_ino;
-       long    ufid_gen;
-};
-#endif
index 3a23d29..dd34866 100644 (file)
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  *
- *     @(#)dinode.h    7.5 (Berkeley) %G%
+ *     @(#)dinode.h    7.6 (Berkeley) %G%
  */
 
 /*
  */
 
 /*
- * The I node is the focus of all file activity in UNIX.
- * There is a unique inode allocated for each active file,
- * each current directory, each mounted-on file, text file, and the root.
- * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
- * Data in icommon is read in from permanent inode on volume.
+ * This structure defines the on-disk format of an inode.
  */
 
 #define        NDADDR  12              /* direct addresses in inode */
 #define        NIADDR  3               /* indirect addresses in inode */
 
  */
 
 #define        NDADDR  12              /* direct addresses in inode */
 #define        NIADDR  3               /* indirect addresses in inode */
 
-struct inode {
-       struct  inode *i_chain[2];      /* must be first */
-       struct  vnode i_vnode;  /* vnode associated with this inode */
-       struct  vnode *i_devvp; /* vnode for block I/O */
-       u_short i_flag;
-       dev_t   i_dev;          /* device where inode resides */
-       ino_t   i_number;       /* i number, 1-to-1 with device address */
-       long    i_id;           /* unique identifier */
-       long    i_diroff;       /* offset in dir, where we found last entry */
-       struct  fs *i_fs;       /* file sys associated with this inode */
-       struct  dquot *i_dquot; /* quota structure controlling this file */
-       struct  text *i_text;   /* text entry, if any (should be region) */
-       struct  inode *i_devlst;/* list of block device inodes */
-       off_t   i_endoff;       /* end of useful stuff in directory */
-       long    i_spare[4];
-       union {
-               daddr_t if_lastr;       /* last read (read-ahead) */
-               struct  socket *is_socket;
-               struct  {
-                       struct inode  *if_freef;        /* free list forward */
-                       struct inode **if_freeb;        /* free list back */
-               } i_fr;
-       } i_un;
-       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 */
-               quad    ic_size;        /*  8: number of bytes in file */
-               time_t  ic_atime;       /* 16: time last accessed */
-               long    ic_atspare;
-               time_t  ic_mtime;       /* 24: time last modified */
-               long    ic_mtspare;
-               time_t  ic_ctime;       /* 32: last time inode changed */
-               long    ic_ctspare;
-               daddr_t ic_db[NDADDR];  /* 40: disk block addresses */
-               daddr_t ic_ib[NIADDR];  /* 88: indirect blocks */
-               long    ic_flags;       /* 100: status, currently unused */
-               long    ic_blocks;      /* 104: blocks actually held */
-               long    ic_gen;         /* 108: generation number */
-               long    ic_spare[4];    /* 112: reserved, currently unused */
-       } i_ic;
-};
-
 struct dinode {
 struct dinode {
-       union {
-               struct  icommon di_icom;
-               char    di_size[128];
-       } di_un;
+       u_short di_mode;        /*  0: mode and type of file */
+       short   di_nlink;       /*  2: number of links to file */
+       uid_t   di_uid;         /*  4: owner's user id */
+       gid_t   di_gid;         /*  6: owner's group id */
+       quad    di_qsize;       /*  8: number of bytes in file */
+       time_t  di_atime;       /* 16: time last accessed */
+       long    di_atspare;
+       time_t  di_mtime;       /* 24: time last modified */
+       long    di_mtspare;
+       time_t  di_ctime;       /* 32: last time inode changed */
+       long    di_ctspare;
+       daddr_t di_db[NDADDR];  /* 40: disk block addresses */
+       daddr_t di_ib[NIADDR];  /* 88: indirect blocks */
+       long    di_flags;       /* 100: status, currently unused */
+       long    di_blocks;      /* 104: blocks actually held */
+       long    di_gen;         /* 108: generation number */
+       long    di_spare[4];    /* 112: reserved, currently unused */
 };
 
 };
 
-#define        i_mode          i_ic.ic_mode
-#define        i_nlink         i_ic.ic_nlink
-#define        i_uid           i_ic.ic_uid
-#define        i_gid           i_ic.ic_gid
 /* ugh! -- must be fixed */
 #if defined(vax) || defined(tahoe)
 /* ugh! -- must be fixed */
 #if defined(vax) || defined(tahoe)
-#define        i_size          i_ic.ic_size.val[0]
-#endif
-#define        i_db            i_ic.ic_db
-#define        i_ib            i_ic.ic_ib
-#define        i_atime         i_ic.ic_atime
-#define        i_mtime         i_ic.ic_mtime
-#define        i_ctime         i_ic.ic_ctime
-#define i_blocks       i_ic.ic_blocks
-#define        i_rdev          i_ic.ic_db[0]
-#define i_flags                i_ic.ic_flags
-#define i_gen          i_ic.ic_gen
-#define        i_lastr         i_un.if_lastr
-#define        i_socket        i_un.is_socket
-#define        i_forw          i_chain[0]
-#define        i_back          i_chain[1]
-#define        i_freef         i_un.i_fr.if_freef
-#define        i_freeb         i_un.i_fr.if_freeb
-
-#define di_ic          di_un.di_icom
-#define        di_mode         di_ic.ic_mode
-#define        di_nlink        di_ic.ic_nlink
-#define        di_uid          di_ic.ic_uid
-#define        di_gid          di_ic.ic_gid
-#if defined(vax) || defined(tahoe)
-#define        di_size         di_ic.ic_size.val[0]
+#define        di_size         di_qsize.val[0]
+#else
+#define        di_size         di_qsize.val[1]
 #endif
 #endif
-#define        di_db           di_ic.ic_db
-#define        di_ib           di_ic.ic_ib
-#define        di_atime        di_ic.ic_atime
-#define        di_mtime        di_ic.ic_mtime
-#define        di_ctime        di_ic.ic_ctime
-#define        di_rdev         di_ic.ic_db[0]
-#define        di_blocks       di_ic.ic_blocks
-#define        di_flags        di_ic.ic_flags
-#define        di_gen          di_ic.ic_gen
-
-#ifdef KERNEL
-struct inode *inode;           /* the inode table itself */
-struct inode *inodeNINODE;     /* the end of the inode table */
-int    ninode;                 /* number of slots in the table */
-
-u_long nextgennumber;          /* next generation number to assign */
-
-extern struct vnodeops ufs_vnodeops;   /* vnode operations for ufs */
-extern struct vnodeops blk_vnodeops;   /* vnode operations for blk devices */
+#define        di_rdev         di_db[0]
 
 
-extern ino_t   dirpref();
-#endif
-
-/* flags */
-#define        ILOCKED         0x1             /* inode is locked */
-#define        IUPD            0x2             /* file has been modified */
-#define        IACC            0x4             /* inode access time to be updated */
-#define        IWANT           0x8             /* some process waiting on lock */
-#define        ICHG            0x10            /* inode has been changed */
-#define        ISHLOCK         0x20            /* file has shared lock */
-#define        IEXLOCK         0x40            /* file has exclusive lock */
-#define        ILWAIT          0x80            /* someone waiting on file lock */
-#define        IMOD            0x100           /* inode has been modified */
-#define        IRENAME         0x200           /* inode is being renamed */
-
-/* modes */
+/* file modes */
 #define        IFMT            0170000         /* type of file */
 #define        IFCHR           0020000         /* character special */
 #define        IFDIR           0040000         /* directory */
 #define        IFMT            0170000         /* type of file */
 #define        IFCHR           0020000         /* character special */
 #define        IFDIR           0040000         /* directory */
@@ -162,67 +67,3 @@ extern ino_t        dirpref();
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
 #define        IREAD           0400            /* read, write, execute permissions */
 #define        IWRITE          0200
 #define        IEXEC           0100
-
-#ifdef KERNEL
-/*
- * Convert between inode pointers and vnode pointers
- */
-#define VTOI(vp)       ((struct inode *)(vp)->v_data)
-#define ITOV(ip)       (&(ip)->i_vnode)
-
-/*
- * Convert between vnode types and inode formats
- */
-extern enum vtype      iftovt_tab[];
-extern int             vttoif_tab[];
-#define IFTOVT(mode)   (iftovt_tab[((mode) & IFMT) >> 13])
-#define VTTOIF(indx)   (vttoif_tab[(int)(indx)])
-
-#define MAKEIMODE(indx, mode)  (int)(VTTOIF(indx) | (mode))
-
-/*
- * Lock and unlock inodes.
- */
-#define        ILOCK(ip) { \
-       while ((ip)->i_flag & ILOCKED) { \
-               (ip)->i_flag |= IWANT; \
-               (void) sleep((caddr_t)(ip), PINOD); \
-       } \
-       (ip)->i_flag |= ILOCKED; \
-}
-
-#define        IUNLOCK(ip) { \
-       (ip)->i_flag &= ~ILOCKED; \
-       if ((ip)->i_flag&IWANT) { \
-               (ip)->i_flag &= ~IWANT; \
-               wakeup((caddr_t)(ip)); \
-       } \
-}
-
-#define        IUPDAT(ip, t1, t2, waitfor) { \
-       if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
-               (void) iupdat(ip, t1, t2, waitfor); \
-}
-
-#define        ITIMES(ip, t1, t2) { \
-       if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
-               (ip)->i_flag |= IMOD; \
-               if ((ip)->i_flag&IACC) \
-                       (ip)->i_atime = (t1)->tv_sec; \
-               if ((ip)->i_flag&IUPD) \
-                       (ip)->i_mtime = (t2)->tv_sec; \
-               if ((ip)->i_flag&ICHG) \
-                       (ip)->i_ctime = time.tv_sec; \
-               (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
-       } \
-}
-
-/*
- * This overlays the fid sturcture (see mount.h)
- */
-struct ufid {
-       u_short ufid_len;
-       ino_t   ufid_ino;
-       long    ufid_gen;
-};
-#endif