home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / include / sys / inode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1988-06-21  |  6.8 KB  |  210 lines

  1. /*
  2.  *    @(#) inode.h 2.3 88/06/21 
  3.  *
  4.  *    Copyright (C) The Santa Cruz Operation, 1984, 1985, 1986, 1987, 1988.
  5.  *    Copyright (C) Microsoft Corporation, 1984, 1985, 1986, 1987, 1988.
  6.  *    This Module contains Proprietary Information of
  7.  *    The Santa Cruz Operation, Microsoft Corporation
  8.  *    and AT&T, and should be treated as Confidential.
  9.  */
  10.  
  11. /*
  12.  * THIS FILE CONTAINS CODE WHICH IS DESIGNED TO BE
  13.  * PORTABLE BETWEEN DIFFERENT MACHINE ARCHITECTURES
  14.  * AND CONFIGURATIONS. IT SHOULD NOT REQUIRE ANY
  15.  * MODIFICATIONS WHEN ADAPTING XENIX TO NEW HARDWARE.
  16.  */
  17.  
  18.  
  19. /*
  20.  * The I node is the focus of all
  21.  * file activity in unix. There is a unique
  22.  * inode allocated for each active file,
  23.  * each current directory, each mounted-on
  24.  * file, text file, and the root. An inode is 'named'
  25.  * by its dev/inumber pair. (iget/iget.c)
  26.  * Data, from mode on, is read in
  27.  * from permanent inode on volume.
  28.  */
  29.  
  30. #define    NADDR    13
  31. #define    NSADDR    (NADDR*sizeof(daddr_t)/sizeof(short))
  32.  
  33. /* file dependent part for named files */
  34.  
  35. struct iisem {               /* semaphore */
  36.     int  i_scount;           /* current semaphore count */
  37.     int  i_eflag;            /* err flg */
  38.     filep_t i_headw;         /* first waiter */
  39.     filep_t i_tailw;         /* last waiter */
  40. };
  41.  
  42. struct iisd {                /* shared data */
  43.     mloc_t   i_buf;          /* address of kernel copy */
  44.     long     i_len;          /* limit (size (in bytes) - 1) of segment */
  45.     int      i_vnum;         /* version number */
  46.     int      i_snum;         /* serial # for getv, waitv */
  47.     int      i_flags;        /* LOCKED, etc. */
  48.     short    i_daddr;        /* swap (disk) address of shared segment */
  49.     char     i_ccount;         /* number of loaded references */
  50. #ifdef M_I386
  51.     struct   tabent *i_sdpt; /* pointer to shared data page table */
  52.     ushort   i_sdlocks;         /* # of procs locking this sd seg into core */
  53. #endif /* M_I386 */
  54.     char     i_res;         /* reserved -- used for word alignment */
  55.     ushort   i_cuid;         /* SysV, creator uid */
  56.     ushort   i_cgid;         /* SysV, creator gid */
  57.     ushort   i_cpid;         /* SysV, creator pid */
  58.     ushort   i_lpid;         /* SysV, pid of last operation */
  59.     time_t   i_ctime;        /* SysV, time of last change */
  60.     time_t   i_atime;        /* SysV, time of last attach */
  61.     time_t   i_dtime;        /* SysV, time of last detach */
  62. };
  63.  
  64.  
  65. struct iirem {            /* DSA */
  66.     unsigned     i_vcid;    /* location of remote file */
  67.     unsigned     i_pte_p;    /* ????               */
  68.     int          i_typ;        /* type of the remote file */
  69.     int          i_fid;        /* id of the remote file   */
  70.     int          i_bid;            /* bind id on remote sys   */
  71.     int          i_tid;         /* tree connect id         */
  72.     char         (*i_gchar)();    /* function passed to nfc_nami */
  73.     long     i_path;    /* path name           */
  74.     unsigned     i_remres[10];    /* reserved for future use */
  75. };
  76.  
  77. struct  inode {
  78.     char    i_flag;
  79.     cnt_t    i_count;    /* reference count */
  80.     dev_t    i_dev;        /* device where inode resides */
  81.     ino_t    i_number;    /* i number, 1-to-1 with device address */
  82.     ushort    i_mode;
  83.     short    i_nlink;    /* directory entries */
  84.     ushort    i_uid;        /* owner */
  85.     ushort    i_gid;        /* group of owner */
  86.     off_t    i_size;        /* size of file */
  87.     union {                 /* file type dependent section */
  88.         struct {                /* files which have data blocks */
  89.         union {
  90.             daddr_t i_a[NADDR];     /* if normal file/directory */
  91.             short   i_f[NSADDR];    /* if fifio's */
  92.         } i_p;
  93.         daddr_t i_l;    /* last logical block read (for read-ahead) */
  94.         } i_blks;
  95.         struct {                /* name type files */
  96.         long i_type;
  97.         union {
  98.             struct iisem i_sem;
  99.             struct iisd  i_sd;
  100.             struct iirem i_rem;        /* DSA */
  101.         } i_ndata;
  102.         } i_namef;
  103.         struct {
  104.         dev_t    i_rd;
  105.         struct stdata *i_sp;
  106.         time_t    i_at;
  107.         time_t    i_mt;
  108.         time_t    i_ct;
  109.         } i_iod;
  110.     } i_fdep;
  111.     struct locklist *i_locklist;    /* locked region list */
  112.  
  113.     long      i_id;        /* unique id for name cache verification */
  114.     inodep_t  i_forw;    /* LRU hash chain forward */
  115.     inodep_t  i_back;    /* LRU hash chain back */
  116.     inodep_t  i_freef;    /* free list forward */
  117.     inodepp_t i_freeb;    /* free list back */
  118. };
  119.  
  120. #ifdef M_KERNEL
  121.  
  122. /*
  123.  * Invalidate an inode. Used by the namei cache to detect stale
  124.  * information. At an absurd rate of 100 calls/second, the inode
  125.  * table invalidation should only occur once every 16 months.
  126.  */
  127. long    nextinodeid;        /* unique id generator */
  128.  
  129. #define cacheinval(ip)    \
  130.     (ip)->i_id = ++nextinodeid; \
  131.     if (nextinodeid == 0) \
  132.         cacheinvalall();
  133.  
  134. #if defined(M_I8086) || defined(M_I286)
  135. extern struct inode far inode[];    /* The inode table itself */
  136. #else
  137. extern struct inode inode[];        /* The inode table itself */
  138. #endif
  139.  
  140. #define    LOCKI(ip) { \
  141.     while ((ip)->i_flag & ILOCK) { \
  142.         (ip)->i_flag |= IWANT; \
  143.         sleep((caddr_t)(ip), PINOD); \
  144.     } \
  145.     (ip)->i_flag |= ILOCK; \
  146. }
  147.  
  148. #define    UNLOCKI(ip) { \
  149.     (ip)->i_flag &= ~ILOCK; \
  150.     if ((ip)->i_flag&IWANT) { \
  151.         (ip)->i_flag &= ~IWANT; \
  152.         wakeup((caddr_t)(ip)); \
  153.     } \
  154. }
  155.  
  156. #endif    /* M_KERNEL */
  157.  
  158. /* flags */
  159. #define    ILOCK    01        /* inode is locked */
  160. #define    IUPD    02        /* file has been modified */
  161. #define    IACC    04        /* inode access time to be updated */
  162. #define    IMOUNT    010        /* inode is mounted on */
  163. #define    IWANT    020        /* some process waiting on lock */
  164. #define    ITEXT    040        /* inode is pure text prototype */
  165. #define    ICHG    0100        /* inode has been changed */
  166.  
  167. /* modes */
  168. #define    IFMT    0170000        /* type of file */
  169. #define        IFDIR    0040000    /* directory */
  170. #define        IFCHR    0020000    /* character special */
  171. #define        IFBLK    0060000    /* block special */
  172. #define        IFREG    0100000    /* regular */
  173. #define        IFMPC    0030000    /* multiplexed char special */
  174. #define        IFMPB    0070000    /* multiplexed block special */
  175. #define        IFIFO    0010000    /* fifo special */
  176. #define         IFNAM   0050000 /* name special */
  177. #define    ISUID    04000        /* set user id on execution */
  178. #define    ISGID    02000        /* set group id on execution */
  179. #define ISVTX    01000        /* save swapped text even after use */
  180. #define    IREAD    0400        /* read, write, execute permissions */
  181. #define    IWRITE    0200
  182. #define    IEXEC    0100
  183.  
  184. #define i_addr  i_fdep.i_blks.i_p.i_a
  185. #define i_lastr i_fdep.i_blks.i_l
  186.  
  187. /* fdep fields for device nodes */
  188. #define i_rdev  i_fdep.i_iod.i_rd
  189. #define i_sptr  i_fdep.i_iod.i_sp
  190. /* for in-core only device nodes (clone opens) */
  191. #define i_icatime  i_fdep.i_iod.i_at
  192. #define i_icmtime  i_fdep.i_iod.i_mt
  193. #define i_icctime  i_fdep.i_iod.i_ct
  194.  
  195. #define i_faddr i_fdep.i_blks.i_p.i_a
  196. #define    NFADDR    10
  197. #define    PIPSIZ    NFADDR*BSIZE
  198. #define i_frptr i_fdep.i_blks.i_p.i_f[NSADDR-5]
  199. #define i_fwptr i_fdep.i_blks.i_p.i_f[NSADDR-4]
  200. #define i_frcnt i_fdep.i_blks.i_p.i_f[NSADDR-3]
  201. #define i_fwcnt i_fdep.i_blks.i_p.i_f[NSADDR-2]
  202. #define i_fflag i_fdep.i_blks.i_p.i_f[NSADDR-1]
  203. #define    IFIR    01
  204. #define    IFIW    02
  205.  
  206. /* types for IFNAM type files */
  207. #define IFSEM   1L              /* semaphore type */
  208. #define IFSHD   2L              /* shared data */
  209. #define IFREM    3L        /* Remote inode */
  210.