move ROOTINO here, so applications don't have to include ufsmount.h
[unix-history] / usr / src / sys / ufs / ffs / dinode.h
index ebd13e3..9dec869 100644 (file)
@@ -1,82 +1,73 @@
-/*     dinode.h        4.9     81/11/14        */
+/*
+ * Copyright (c) 1982, 1989 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ *     @(#)dinode.h    7.12 (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, from mode on, is read in from permanent inode on volume.
+ * The root inode is the root of the file system.  Inode 0 can't be used for
+ * normal purposes and historically bad blocks were linked to inode 1, thus
+ * the root inode is 2.  (Inode 1 is no longer used for this purpose, however
+ * numerous dump tapes make this assumption, so we are stuck with it).
  */
  */
-#define        NADDR   13
+#define        ROOTINO ((ino_t)2)
 
 
-struct inode {
-       char    i_flag;
-       char    i_count;        /* reference count */
-       dev_t   i_dev;          /* device where inode resides */
-       ino_t   i_number;       /* i number, 1-to-1 with device address */
-/* begin read from disk */
-       u_short i_mode;
-       short   i_nlink;        /* directory entries */
-       short   i_uid;          /* owner */
-       short   i_gid;          /* group of owner */
-       off_t   i_size;         /* size of file */
-       union {
-               struct i_f {
-                       daddr_t if_addr[NADDR]; /* if normal file/directory */
-                       daddr_t if_lastr;       /* last read (read-ahead) */
-               } i_f;
-               struct i_d {
-                       daddr_t id_rdev;        /* i_addr[0] */
-               } i_d;
-               struct i_s {
-                       struct  socket *is_socket;
-               } i_s;
-#define        i_addr          i_f.if_addr
-#define        i_lastr         i_f.if_lastr
-#define        i_rdev          i_d.id_rdev
-#define        i_socket        i_s.is_socket
-       } i_un;
-/* end read from disk */
-       short   i_XXXXXX;       /* ### */
-/* SHOULD USE POINTERS, NOT INDICES, FOR HAS CHAIN */
-       short   i_hlink;        /* link in hash chain (iget/iput/ifind) */
-};
+/*
+ * A dinode contains all the meta-data associated with a UFS file.
+ * This structure defines the on-disk format of a dinode.
+ */
 
 
-#ifdef KERNEL
-struct inode *inode, *inodeNINODE;
-int    ninode;
+#define        NDADDR  12              /* direct addresses in inode */
+#define        NIADDR  3               /* indirect addresses in inode */
 
 
-struct inode *rootdir;         /* pointer to inode of root directory */
+struct dinode {
+       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 */
+       u_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 */
+};
 
 
-struct inode *ialloc();
-struct inode *ifind();
-struct inode *iget();
-struct inode *owner();
-struct inode *maknode();
-struct inode *namei();
+#ifdef BYTE_ORDER
+#if BYTE_ORDER == LITTLE_ENDIAN || defined(tahoe) /* ugh! -- must be fixed */
+#define        di_size         di_qsize.val[0]
+#else /* BYTE_ORDER == BIG_ENDIAN */
+#define        di_size         di_qsize.val[1]
 #endif
 #endif
+#else
+#define        di_size         BYTE_ORDER_UNDEFINED
+#endif
+
+#define        di_rdev         di_db[0]
 
 
-/* flags */
-#define        ILOCK   01              /* inode is locked */
-#define        IUPD    02              /* file has been modified */
-#define        IACC    04              /* inode access time to be updated */
-#define        IMOUNT  010             /* inode is mounted on */
-#define        IWANT   020             /* some process waiting on lock */
-#define        ITEXT   040             /* inode is pure text prototype */
-#define        ICHG    0100            /* inode has been changed */
+/* file modes */
+#define        IFMT            0170000         /* mask of file type */
+#define        IFIFO           0010000         /* named pipe (fifo) */
+#define        IFCHR           0020000         /* character special device */
+#define        IFDIR           0040000         /* directory */
+#define        IFBLK           0060000         /* block special device */
+#define        IFREG           0100000         /* regular file */
+#define        IFLNK           0120000         /* symbolic link */
+#define        IFSOCK          0140000         /* UNIX domain socket */
 
 
-/* modes */
-#define        IFMT    0170000         /* type of file */
-#define                IFCHR           0020000         /* character special */
-#define                IFDIR           0040000         /* directory */
-#define                IFBLK           0060000         /* block special */
-#define                IFREG           0100000         /* regular */
-#define                IFSYMREG        0110000         /* regular symbolic link */
-#define                IFSYMDIR        0130000         /* directory symbolic link */
-#define                IFPORTAL        0140000         /* portal */
-#define        ISUID   04000           /* set user id on execution */
-#define        ISGID   02000           /* set group id on execution */
-#define        ISVTX   01000           /* save swapped text even after use */
-#define        IREAD   0400            /* read, write, execute permissions */
-#define        IWRITE  0200
-#define        IEXEC   0100
+#define        ISUID           04000           /* set user identifier when exec'ing */
+#define        ISGID           02000           /* set group identifier when exec'ing */
+#define        ISVTX           01000           /* save execution information on exit */
+#define        IREAD           0400            /* read permission */
+#define        IWRITE          0200            /* write permission */
+#define        IEXEC           0100            /* execute permission */