home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / fs / s5inode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  6.8 KB  |  246 lines

  1. /*    Copyright (c) 1990 UNIX System Laboratories, Inc.    */
  2. /*    Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T    */
  3. /*      All Rights Reserved      */
  4.  
  5. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF         */
  6. /*    UNIX System Laboratories, Inc.                         */
  7. /*    The copyright notice above does not evidence any       */
  8. /*    actual or intended publication of such source code.    */
  9.  
  10. #ifndef _FS_S5INODE_H
  11. #define _FS_S5INODE_H
  12.  
  13. #ident    "@(#)/usr/include/sys/fs/s5inode.h.sl 1.1 4.0 12/08/90 3323 AT&T-USL"
  14.  
  15. #include <sys/proc.h>    /* XXX -- needed for user-context kludge in ILOCK */
  16. #include <sys/disp.h>    /* XXX */
  17.  
  18. #define    NADDR    13
  19. #define    NSADDR    (NADDR*sizeof(daddr_t)/sizeof(short))
  20.  
  21. struct inode {
  22.     struct    inode *i_forw;    /* inode hash chain */
  23.     struct    inode *i_back;    /* " */
  24.     struct    inode *av_forw;    /* freelist chain */
  25.     struct    inode *av_back;    /* " */
  26.     u_short    i_flag;        /* flags */
  27.     o_ino_t    i_number;    /* inode number */
  28.     dev_t    i_dev;        /* device where inode resides */
  29.     o_mode_t i_mode;    /* file mode and type */
  30.     o_uid_t    i_uid;        /* owner */
  31.     o_gid_t    i_gid;        /* group */
  32.     o_nlink_t i_nlink;    /* number of links */
  33.     off_t    i_size;        /* size in bytes */
  34.     time_t    i_atime;    /* last access time */
  35.     time_t    i_mtime;    /* last modification time */
  36.     time_t    i_ctime;    /* last "inode change" time */
  37.     daddr_t    i_addr[NADDR];    /* block address list */
  38.     short    i_nilocks;    /* XXX -- count of recursive ilocks */
  39.     short    i_owner;    /* XXX -- proc slot of ilock owner */
  40.     daddr_t    i_nextr;    /* next byte read offset (read-ahead) */
  41.     u_char     i_gen;        /* generation number */
  42.     long    i_mapcnt;       /* number of mappings of pages */
  43.     u_long    i_vcode;    /* version code attribute */
  44.     struct vnode i_vnode;    /* Contains an instance of a vnode */
  45.     int    *i_map;        /* block list for the corresponding file */
  46.     dev_t    i_rdev;        /* rdev field for block/char specials */
  47.  
  48.     int    i_mapsz;    /* kmem_alloc'ed size */
  49.     int    i_oldsz;    /* i_size when you did the allocation */
  50. };
  51.  
  52. #define    i_oldrdev    i_addr[0]
  53. #define i_bcflag    i_addr[1]    /* block/char special flag occupies
  54.                     ** bytes 3-5 in di_addr
  55.                     */
  56. #define NDEVFORMAT    0x1    /* device number stored in new area */
  57. #define i_major        i_addr[2] /* major component occupies bytes 6-8 in di_addr */
  58. #define i_minor        i_addr[3] /* minor component occupies bytes 9-11 in di_addr */
  59.  
  60. typedef struct inode inode_t;
  61.  
  62. extern struct inode *inode;
  63. extern long int ninode;
  64.  
  65. struct    ifreelist {    /* must match struct inode */
  66.     struct inode    *pad[2];
  67.     struct inode    *av_forw;
  68.     struct inode    *av_back;
  69. };
  70.  
  71. extern struct ifreelist ifreelist;
  72.  
  73. /* Flags */
  74.  
  75. #define    ILOCKED    0x0001        /* inode is locked */
  76. #define    IUPD    0x0002        /* file has been modified */
  77. #define    IACC    0x0004        /* inode access time to be updated */
  78. #define    IWANT    0x0010        /* some process waiting on lock */
  79. #define    ICHG    0x0040        /* inode has been changed */
  80. #define    ISYN    0x0080        /* do synchronous write for iupdat */
  81. #define    IMOD    0x0100        /* inode times have been modified */
  82. #define    INOACC    0x0200        /* no access time update in getpage */
  83. #define    ISYNC    0x0400        /* do all block allocation synchronously */
  84. #define    IMODTIME 0x0800        /* mod time already set */
  85. #define    IRWLOCKED    0x1000        /* inode is rwlocked */
  86. #define    IINACTIVE    0x2000        /* iinactive in progress */
  87.  
  88. /*
  89.  * File types.
  90.  */
  91.  
  92. #define    IFMT    0xF000        /* type of file */
  93. #define        IFIFO    0x1000    /* fifo special */
  94. #define        IFCHR    0x2000    /* character special */
  95. #define        IFDIR    0x4000    /* directory */
  96. #define        IFNAM    0x5000    /* XENIX special named file */
  97. #define        IFBLK    0x6000    /* block special */
  98. #define        IFREG    0x8000    /* regular */
  99. #define        IFLNK    0xA000    /* symbolic link */
  100.  
  101. /*
  102.  * File modes.
  103.  */
  104. #define    ISUID    VSUID        /* set user id on execution */
  105. #define    ISGID    VSGID        /* set group id on execution */
  106. #define ISVTX    VSVTX        /* save swapped text even after use */
  107.  
  108. /*
  109.  * Permissions.
  110.  */
  111. #define    IREAD        VREAD    /* read permission */
  112. #define    IWRITE        VWRITE    /* write permission */
  113. #define    IEXEC        VEXEC    /* execute permission */
  114.  
  115. #ifdef _KERNEL
  116.  
  117. extern int iget(), ialloc();
  118. extern void iinactive();
  119.  
  120. extern int bmap(), bmapalloc();
  121.  
  122. /*
  123.  * inode-to-vnode conversion.
  124.  */
  125. #define    ITOV(ip)    ((struct vnode *)&(ip)->i_vnode)
  126. #define VTOI(vp)    ((struct inode *)(vp)->v_data)
  127.  
  128. #define ESAME    (-1)        /* Special KLUDGE error for rename */
  129.  
  130. #define    S5_HOLE    (-1)        /* Value used when no block allocated */
  131.  
  132. enum de_op    { DE_CREATE, DE_MKDIR, DE_LINK, DE_RENAME }; /* direnter ops */
  133. enum dr_op    { DR_REMOVE, DR_RMDIR, DR_RENAME }; /* dirremove ops */
  134.  
  135. /*
  136.  * This overlays the fid structure (see vfs.h).
  137.  */
  138. struct ufid {
  139.     u_short    ufid_len;
  140.     o_ino_t    ufid_ino;
  141.     long    ufid_gen;
  142. };
  143.  
  144. /*
  145.  * S5 VFS private data.
  146.  */
  147. struct s5vfs {
  148.     struct vnode    *vfs_root;    /* root vnode */
  149.     struct buf    *vfs_bufp;    /* buffer containing superblock */
  150.     struct vnode    *vfs_devvp;    /* block device vnode */
  151.     long        vfs_nindir;    /* bsize/sizeof(daddr_t) */
  152.     long        vfs_inopb;    /* bsize/sizeof(dinode) */
  153.     long        vfs_bmask;    /* bsize-1 */
  154.     long        vfs_nmask;    /* nindir-1 */
  155.     long        vfs_ltop;    /* ltop or ptol shift constant */
  156.     long        vfs_bshift;    /* log2(bsize) */
  157.     long        vfs_nshift;    /* log2(nindir) */
  158.     long        vfs_inoshift;    /* log2(inopb) */
  159. };
  160.  
  161. #define S5VFS(vfsp) ((struct s5vfs *)((vfsp)->vfs_data))
  162.  
  163. /*
  164.  * Lock and unlock inodes.
  165.  *
  166.  * XXX -- Uses process context.  Rewrite to remove this.
  167.  */
  168. #define    IRWLOCK(ip) { \
  169.     while ((ip)->i_flag & IRWLOCKED) { \
  170.         (ip)->i_flag |= IWANT; \
  171.         (void) sleep((caddr_t)(ip), PINOD); \
  172.     } \
  173.     (ip)->i_flag |= IRWLOCKED; \
  174.     if ((ip)->i_vnode.v_flag & VISSWAP) { \
  175.         curproc->p_swlocks++; \
  176.         curproc->p_flag |= SSWLOCKS; \
  177.     } \
  178. }
  179.  
  180. #define    IRWUNLOCK(ip) { \
  181.     ASSERT((ip)->i_flag & IRWLOCKED); \
  182.     if ((ip)->i_vnode.v_flag & VISSWAP) { \
  183.         if (--curproc->p_swlocks == 0) \
  184.             curproc->p_flag &= ~SSWLOCKS; \
  185.     } \
  186.     (ip)->i_flag &= ~IRWLOCKED; \
  187.     if ((ip)->i_flag & IWANT) { \
  188.         (ip)->i_flag &= ~IWANT; \
  189.         wakeprocs((caddr_t)(ip), PRMPT); \
  190.     } \
  191. }
  192.  
  193. #define    ILOCK(ip) { \
  194.     while (((ip)->i_flag & ILOCKED) && (ip)->i_owner != curproc->p_slot) { \
  195.         (ip)->i_flag |= IWANT; \
  196.         (void) sleep((caddr_t)(ip), PINOD); \
  197.     } \
  198.     (ip)->i_owner = curproc->p_slot; \
  199.     (ip)->i_nilocks++; \
  200.     (ip)->i_flag |= ILOCKED; \
  201.     if ((ip)->i_vnode.v_flag & VISSWAP) { \
  202.         curproc->p_swlocks++; \
  203.         curproc->p_flag |= SSWLOCKS; \
  204.     } \
  205. }
  206.  
  207. #define    IUNLOCK(ip) { \
  208.     ASSERT((ip)->i_flag & ILOCKED); \
  209.     --(ip)->i_nilocks; \
  210.     ASSERT((ip)->i_nilocks >= 0); \
  211.     if ((ip)->i_vnode.v_flag & VISSWAP) { \
  212.         if (--curproc->p_swlocks == 0) \
  213.             curproc->p_flag &= ~SSWLOCKS; \
  214.     } \
  215.     if ((ip)->i_nilocks == 0) { \
  216.         (ip)->i_flag &= ~ILOCKED; \
  217.         if ((ip)->i_flag & IWANT) { \
  218.             (ip)->i_flag &= ~IWANT; \
  219.             wakeprocs((caddr_t)(ip), PRMPT); \
  220.         } \
  221.     } \
  222. }
  223.  
  224. #define ITIMES(ip) { \
  225.     if ((ip)->i_flag & (IUPD|IACC|ICHG)) { \
  226.         (ip)->i_flag |= IMOD; \
  227.         if ((ip)->i_flag & IACC) \
  228.             (ip)->i_atime = hrestime.tv_sec; \
  229.         if ((ip)->i_flag & IUPD) {\
  230.             (ip)->i_mtime = hrestime.tv_sec; \
  231.             (ip)->i_flag |= IMODTIME; \
  232.         } \
  233.         if ((ip)->i_flag & ICHG) \
  234.             (ip)->i_ctime = hrestime.tv_sec; \
  235.         (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
  236.     } \
  237. }
  238.  
  239. #endif
  240.  
  241. #ifndef NADDR
  242. #define NADDR 13
  243. #endif
  244.  
  245. #endif    /* _FS_S5INODE_H */
  246.