home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / fs / snode.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  4.6 KB  |  147 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_SNODE_H
  11. #define _FS_SNODE_H
  12.  
  13. #ident    "@(#)/usr/include/sys/fs/snode.h.sl 1.1 4.0 12/08/90 9132 AT&T-USL"
  14. /*
  15.  * The snode represents a special file in any filesystem.  There is
  16.  * one snode for each active special file.  Filesystems that support
  17.  * special files use specvp(vp, dev, type, cr) to convert a normal
  18.  * vnode to a special vnode in the ops lookup() and create().
  19.  *
  20.  * To handle having multiple snodes that represent the same
  21.  * underlying device vnode without cache aliasing problems,
  22.  * the s_commonvp is used to point to the "common" vnode used for
  23.  * caching data.  If an snode is created internally by the kernel,
  24.  * then the s_realvp field is NULL and s_commonvp points to s_vnode.
  25.  * The other snodes which are created as a result of a lookup of a
  26.  * device in a file system have s_realvp pointing to the vp which
  27.  * represents the device in the file system while the s_commonvp points
  28.  * into the "common" vnode for the device in another snode.
  29.  */
  30.  
  31. struct snode {
  32.     struct    snode *s_next;        /* must be first */
  33.     struct    vnode s_vnode;        /* vnode associated with this snode */
  34.     struct    vnode *s_realvp;    /* vnode for the fs entry (if any) */
  35.     struct    vnode *s_commonvp;    /* common device vnode */
  36.     ushort    s_flag;            /* flags, see below */
  37.     dev_t    s_dev;            /* device the snode represents */
  38.     dev_t    s_fsid;            /* file system identifier */
  39.     daddr_t    s_nextr;        /* next byte read offset (read-ahead) */
  40.     long    s_size;            /* block device size in bytes */
  41.     time_t  s_atime;        /* time of last access */
  42.     time_t  s_mtime;        /* time of last modification */
  43.     time_t  s_ctime;        /* time of last attributes change */
  44.     int    s_count;        /* count of opened references */
  45.         long    s_mapcnt;               /* count of mappings of pages */
  46.     long    s_pad1;            /* reserved for security */
  47.     long    s_pad2;            /* reserved for security */
  48.     long    s_pad3;            /* reserved for security */
  49.     struct proc *s_powns;        /* XXX vm debugging */
  50. };
  51.  
  52. /* flags */
  53. #define SLOCKED        0x01        /* snode is locked */
  54. #define SUPD        0x02        /* update device access time */
  55. #define SACC        0x04        /* update device modification time */
  56. #define SWANT        0x10        /* some process waiting on lock */
  57. #define SCHG        0x40        /* update device change time */
  58.  
  59. /*
  60.  * Convert between vnode and snode
  61.  */
  62. #define    VTOS(vp)    ((struct snode *)((vp)->v_data))
  63. #define    STOV(sp)    (&(sp)->s_vnode)
  64.  
  65. extern struct proc *curproc;        /* XXX vm debugging */
  66. /*
  67.  * Lock and unlock snodes.
  68.  */
  69. #define SNLOCK(sp) { \
  70.     while ((sp)->s_flag & SLOCKED) { \
  71.         (sp)->s_flag |= SWANT; \
  72.         (void) sleep((caddr_t)(sp), PINOD); \
  73.     } \
  74.     (sp)->s_flag |= SLOCKED; \
  75.     if (((sp)->s_vnode.v_flag & VISSWAP) != 0) { \
  76.         curproc->p_swlocks++; \
  77.         curproc->p_flag |= SSWLOCKS; \
  78.     } \
  79.     (sp)->s_powns = curproc; \
  80. }
  81.  
  82. #define SNUNLOCK(sp) { \
  83.     (sp)->s_flag &= ~SLOCKED; \
  84.     if (((sp)->s_vnode.v_flag & VISSWAP) != 0) \
  85.         if (--curproc->p_swlocks == 0) \
  86.             curproc->p_flag &= ~SSWLOCKS; \
  87.     if ((sp)->s_flag & SWANT) { \
  88.         (sp)->s_flag &= ~SWANT; \
  89.         wakeprocs((caddr_t)(sp), PRMPT); \
  90.     } \
  91.     (sp)->s_powns = NULL; \
  92. }
  93.  
  94. /*
  95.  * Construct a spec vnode for a given device that shadows a particular
  96.  * "real" vnode.
  97.  */
  98. extern struct vnode *specvp();
  99.  
  100. /*
  101.  * Construct a spec vnode for a given device that shadows nothing.
  102.  */
  103. extern struct vnode *makespecvp();
  104.  
  105. /*
  106.  * Find any other spec vnode that refers to the same device as another vnode.
  107.  */
  108. extern struct vnode *other_specvp();
  109.  
  110. /*
  111.  * Convert a device vnode pointer into a common device vnode pointer.
  112.  */
  113. extern struct vnode *common_specvp();
  114.  
  115. /*
  116.  * Wait for access to a file, or signal other processes waiting for access.
  117.  */
  118. extern int openwait();
  119. extern int openprivwait();
  120. extern int setprivwait();
  121. extern void privsig();
  122.  
  123. /* XENIX Support */
  124. extern int spec_rdchk();
  125. /* End XENIX Support */
  126.  
  127. /*
  128.  * If driver does not have a size routine (e.g. old drivers), the size of the
  129.  * device is assumed to be infinite.
  130.  */
  131. #define UNKNOWN_SIZE     0x7fffffff
  132.  
  133. /*
  134.  * Snode lookup stuff.
  135.  * These routines maintain a table of snodes hashed by dev so
  136.  * that the snode for an dev can be found if it already exists.
  137.  * NOTE: STABLESIZE must be a power of 2 for STABLEHASH to work!
  138.  */
  139.  
  140. #define    STABLESIZE    16
  141. #define    STABLEHASH(dev)    ((getmajor(dev) + getminor(dev)) & (STABLESIZE - 1))
  142. extern struct snode *stable[];
  143.  
  144. extern struct vnodeops spec_vnodeops;
  145.  
  146. #endif    /* _FS_SNODE_H */
  147.