home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 8.ddi / usr / include / sys / fs / bfs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.3 KB  |  183 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_BFS_H
  11. #define _FS_BFS_H
  12.  
  13. #ident    "@(#)/usr/include/sys/fs/bfs.h.sl 1.1 4.0 12/08/90 48238 AT&T-USL"
  14.  
  15. #include <sys/resource.h>
  16.  
  17. #define BFS_MAXFNLEN 14            /* Maximum file length */
  18. #define BFS_MAXFNLENN (BFS_MAXFNLEN+1)  /* Used for NULL terminated copies */
  19.  
  20. struct bfsvattr {
  21.     vtype_t        va_type;    /* vnode type (for create) */
  22.     mode_t        va_mode;    /* file access mode */
  23.     uid_t        va_uid;        /* owner user id */
  24.     uid_t        va_gid;        /* owner group id */
  25.     nlink_t        va_nlink;    /* number of references to file */
  26.     time_t        va_atime;    /* time of last access */
  27.     time_t        va_mtime;    /* time of last modification */
  28.     time_t        va_ctime;    /* time file ``created'' */
  29.     long        va_filler[4];    /* padding */
  30. };
  31.  
  32. /*
  33.  * The bfs_dirent is the "inode" of BFS.  Always on disk, it is pointed
  34.  * to (by disk offset) by the vnode and is referenced every time an
  35.  * operation is done on the vnode.  It must be referenced every time,
  36.  * as things can move around very quickly
  37.  */
  38. struct bfs_dirent
  39. {
  40.     ushort  d_ino;                /* inode */
  41.     daddr_t d_sblock;            /* Start block */
  42.     daddr_t d_eblock;            /* End block */
  43.     daddr_t d_eoffset;            /* EOF disk offset (absolute) */
  44.     struct  bfsvattr d_fattr;        /* File attributes */
  45. };
  46.  
  47.  
  48. struct bfs_ldirs {
  49.     ushort l_ino;
  50.     char   l_name[BFS_MAXFNLEN];
  51. };
  52.  
  53. /*
  54.  * We keep a linked list of all referenced BFS vnodes.  bfs_inactive will remove
  55.  * them from the list, and bfs_fillvnode will add to and search through the list
  56.  */
  57. struct bfs_core_vnode
  58. {
  59.     struct vnode *core_vnode;
  60.     struct bfs_core_vnode *core_next;
  61. };
  62.  
  63. /*
  64.  * The BFS superbuf contains all private data about a given BFS filesystem.
  65.  * It is pointed to by the data field of the vfs structure and is thus passed
  66.  * to every vfsop and vnodeops even if indirectly
  67.  */
  68. struct bsuper
  69. {
  70.     off_t bsup_start;        /* The filesystem data start offset */
  71.     off_t bsup_end;            /* The filesystem data end offset */
  72.     long bsup_freeblocks;        /* # of freeblocks (for statfs) */
  73.     long bsup_freedrents;        /* # of free dir entries (for statfs) */
  74.     struct vnode *bsup_devnode;    /* The device special vnode */
  75.     struct vnode *bsup_root;    /* Root vnode */
  76.     off_t bsup_lastfile;        /* Last file directory offset */
  77.  
  78.     long  bsup_inomapsz;
  79.     char *bsup_inomap;
  80.  
  81.     /* Linked vnode list */
  82.  
  83.     struct bfs_core_vnode *bsup_incore_vlist;    
  84.  
  85.     /*
  86.      * bsup_ioinprog is the count of the number of io operations is 
  87.      * in progress.  Compaction routines sleep on this being zero
  88.      */
  89.     ushort bsup_ioinprog;
  90.     struct vnode *bsup_writelock;    /* The file which is open for write */
  91.  
  92.     /* Booleans */
  93.  
  94.     unsigned char bsup_fslocked;    /* Fs is locked when compacting */
  95.     unsigned char bsup_compacted;    /* Fs compacted, no removes done */
  96. };
  97.  
  98. /* The disk superbuff */
  99. struct bdsuper
  100. {
  101.     long  bdsup_bfsmagic;        /* Magic number */
  102.     off_t bdsup_start;        /* Filesystem data start offset */
  103.     off_t bdsup_end;        /* Filesystem data end offset */
  104.  
  105.     /*
  106.      * The next four words are used to promote sanity in compaction.  Used
  107.      * correctly, a crash at any point during compaction is recoverable
  108.      */
  109.     daddr_t bdcp_fromblock;        /* "From" block of current transfer */
  110.     daddr_t bdcp_toblock;        /* "To" block of current transfer */
  111.     daddr_t bdcpb_fromblock;    /* Backup of "from" block */
  112.     daddr_t bdcpb_toblock;        /* Backup of "to" block */
  113.     long    bdsup_filler[121];    /* Padding */
  114. };
  115.  
  116. /* Used to overlay the kernel struct fid */
  117. struct bfs_fid_overlay
  118. {
  119.     ushort o_len;
  120.     long o_offset;
  121. };
  122.  
  123.  
  124. #define BFS_MAGIC    0x1BADFACE
  125. #define BFS_SUPEROFF    0
  126. #define BFS_DIRSTART    (BFS_SUPEROFF + sizeof(struct bdsuper))
  127. #define BFS_DEVNODE(vfsp) ((struct bsuper *)vfsp->vfs_data)->bsup_devnode
  128. #define BFS_BSIZE    512
  129. #define BFS_ULT        RLIM_INFINITY    /* file size limit not enforced */
  130. #define BFS_YES        (char)1
  131. #define BFS_NO        (char)0
  132. #define CHUNKSIZE    4096
  133. #define BIGFILE        500
  134. #define SMALLFILE    10
  135. #define BFSROOTINO    2
  136. #define DIRBUFSIZE    1024
  137.  
  138. #define BFS_INOLOCK(bs, inode) { \
  139.     while (bs->bsup_inomap[inode]) \
  140.         sleep(&(bs->bsup_inomap[inode]), PINOD); \
  141.     bs->bsup_inomap[inode] = 1; \
  142. }
  143.  
  144. #define BFS_INOUNLOCK(bs, inode) { \
  145.     ASSERT (bs->bsup_inomap[inode]); \
  146.     bs->bsup_inomap[inode] = 0; \
  147.     wakeprocs(&(bs->bsup_inomap[inode]), PRMPT); \
  148. }
  149.  
  150.  
  151. #define BFS_OFF2INO(offset) \
  152.     ((offset - BFS_DIRSTART) / sizeof(struct bfs_dirent)) + BFSROOTINO
  153.  
  154. #define BFS_INO2OFF(inode) \
  155.     ((inode - BFSROOTINO) * sizeof(struct bfs_dirent)) + BFS_DIRSTART
  156.  
  157. #define BFS_GETINODE(bvp, offset, buf, cr) \
  158.     vn_rdwr(UIO_READ, bvp, (caddr_t)buf, sizeof(struct bfs_dirent), \
  159.                 offset, UIO_SYSSPACE, 0, 0, cr, 0)
  160.  
  161. #define BFS_PUTINODE(bvp, offset, buf, cr) \
  162.     vn_rdwr(UIO_WRITE, bvp, (caddr_t)buf, sizeof(struct bfs_dirent), \
  163.             offset, UIO_SYSSPACE, IO_SYNC, BFS_ULT, cr, (int *)0)
  164.  
  165. #define BFS_GETDIRLIST(bvp, offset, buf, len, cr) \
  166.     vn_rdwr(UIO_READ, bvp, buf, len, offset, UIO_SYSSPACE, 0, 0, cr, 0)
  167.  
  168. #define CHECK_LOCK(bs) \
  169.     if (bs->bsup_fslocked) \
  170.         while (bs->bsup_fslocked) \
  171.             sleep((caddr_t)&bs->bsup_fslocked, PINOD)
  172.  
  173.  
  174. #define BFS_LOCK(bs) bs->bsup_fslocked = BFS_YES
  175.  
  176.  
  177. #define BFS_IOBEGIN(bs) bs->bsup_ioinprog++
  178.  
  179. #define BFS_IOEND(bs) if (!(--bs->bsup_ioinprog)) \
  180.             wakeprocs((caddr_t)&bs->bsup_ioinprog, PRMPT)
  181.  
  182. #endif    /* _FS_BFS_H */
  183.