home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 9.ddi / usr / include / sys / vfs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-12-08  |  5.2 KB  |  167 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 _SYS_VFS_H
  11. #define _SYS_VFS_H
  12.  
  13. #ident    "@(#)/usr/include/sys/vfs.h.sl 1.1 4.0 12/08/90 39473 AT&T-USL"
  14.  
  15. /*
  16.  * Data associated with mounted file systems.
  17.  */
  18.  
  19. /*
  20.  * File system identifier. Should be unique (at least per machine).
  21.  */
  22. typedef struct {
  23.     long val[2];            /* file system id type */
  24. } fsid_t;
  25.  
  26. /*
  27.  * File identifier.  Should be unique per filesystem on a single
  28.  * machine.  This is typically called by a stateless file server
  29.  * in order to generate "file handles".
  30.  */
  31. #define    MAXFIDSZ    16
  32. #define    freefid(fidp) \
  33.   kmem_free((caddr_t)(fidp), sizeof (struct fid) - MAXFIDSZ + (fidp)->fid_len)
  34.  
  35. typedef struct fid {
  36.     u_short        fid_len;        /* length of data in bytes */
  37.     char        fid_data[MAXFIDSZ];    /* data (variable length) */
  38. } fid_t;
  39.  
  40. /*
  41.  * Structure per mounted file system.  Each mounted file system has
  42.  * an array of operations and an instance record.  The file systems
  43.  * are kept on a singly linked list headed by "rootvfs" and terminated
  44.  * by NULL.
  45.  */
  46. typedef struct vfs {
  47.     struct vfs    *vfs_next;        /* next VFS in VFS list */
  48.     struct vfsops    *vfs_op;        /* operations on VFS */
  49.     struct vnode    *vfs_vnodecovered;    /* vnode mounted on */
  50.     u_long        vfs_flag;        /* flags */
  51.     u_long        vfs_bsize;        /* native block size */
  52.     int        vfs_fstype;        /* file system type index */
  53.     fsid_t        vfs_fsid;        /* file system id */
  54.     caddr_t        vfs_data;        /* private data */
  55.     dev_t        vfs_dev;        /* device of mounted VFS */
  56.     u_long        vfs_bcount;        /* I/O count (accounting) */
  57.     u_short        vfs_nsubmounts;        /* immediate sub-mount count */
  58. } vfs_t;
  59.  
  60. /*
  61.  * VFS flags.
  62.  */
  63. #define VFS_RDONLY    0x01        /* read-only vfs */
  64. #define VFS_MLOCK    0x02        /* lock vfs so that subtree is stable */
  65. #define VFS_MWAIT    0x04        /* someone is waiting for lock */
  66. #define VFS_NOSUID    0x08        /* setuid disallowed */
  67. #define VFS_REMOUNT    0x10        /* modify mount options only */
  68. #define VFS_NOTRUNC    0x20        /* does not truncate long file names */
  69. #define VFS_UNLINKABLE    0x40        /* unlink(2) can be applied to root */
  70. #define VFS_BADBLOCK    0x80        /* disk based fs has bad block */
  71.  
  72. /*
  73.  * Argument structure for mount(2).
  74.  */
  75. struct mounta {
  76.     char    *spec;
  77.     char    *dir;
  78.     int    flags;
  79.     char    *fstype;
  80.     char    *dataptr;
  81.     int    datalen;
  82. };
  83.  
  84. /*
  85.  * Operations supported on virtual file system.
  86.  */
  87. typedef struct vfsops {
  88.     int    (*vfs_mount)();        /* mount file system */
  89.     int    (*vfs_unmount)();    /* unmount file system */
  90.     int    (*vfs_root)();        /* get root vnode */
  91.     int    (*vfs_statvfs)();    /* get file system statistics */
  92.     int    (*vfs_sync)();        /* flush fs buffers */
  93.     int    (*vfs_vget)();        /* get vnode from fid */
  94.     int    (*vfs_mountroot)();    /* mount the root filesystem */
  95.     int    (*vfs_swapvp)();    /* return vnode for swap */
  96.     int    (*vfs_filler[8])();    /* for future expansion */
  97. } vfsops_t;
  98.  
  99. #define VFS_MOUNT(vfsp, mvp, uap, cr) \
  100.     (*(vfsp)->vfs_op->vfs_mount)(vfsp, mvp, uap, cr)
  101. #define VFS_UNMOUNT(vfsp, cr)    (*(vfsp)->vfs_op->vfs_unmount)(vfsp, cr)
  102. #define VFS_ROOT(vfsp, vpp)    (*(vfsp)->vfs_op->vfs_root)(vfsp, vpp)
  103. #define    VFS_STATVFS(vfsp, sp)    (*(vfsp)->vfs_op->vfs_statvfs)(vfsp, sp)
  104. #define VFS_SYNC(vfsp, flag, cr) \
  105.         (*(vfsp)->vfs_op->vfs_sync)(vfsp, flag, cr)
  106. #define VFS_VGET(vfsp, vpp, fidp) \
  107.         (*(vfsp)->vfs_op->vfs_vget)(vfsp, vpp, fidp)
  108. #define VFS_MOUNTROOT(vfsp, init) \
  109.          (*(vfsp)->vfs_op->vfs_mountroot)(vfsp, init)
  110. #define VFS_SWAPVP(vfsp, vpp, nm) \
  111.         (*(vfsp)->vfs_op->vfs_swapvp)(vfsp, vpp, nm)
  112.  
  113. /*
  114.  * Filesystem type switch table.
  115.  */
  116. typedef struct vfssw {
  117.     char        *vsw_name;    /* type name string */
  118.     int        (*vsw_init)();    /* init routine */
  119.     struct vfsops    *vsw_vfsops;    /* filesystem operations vector */
  120.     long        vsw_flag;    /* flags */
  121. } vfssw_t;
  122.  
  123. /*
  124.  * Public operations.
  125.  */
  126. extern void    vfs_mountroot();    /* mount the root */
  127. extern void    vfs_add();        /* add a new vfs to mounted vfs list */
  128. extern void    vfs_remove();        /* remove a vfs from mounted vfs list */
  129. extern int    vfs_lock();        /* lock a vfs */
  130. extern void    vfs_unlock();        /* unlock a vfs */
  131. extern vfs_t     *getvfs();        /* return vfs given fsid */
  132. extern vfs_t     *vfs_devsearch();    /* find vfs given device */
  133. extern vfssw_t     *vfs_getvfssw();    /* find vfssw ptr given fstype name */
  134. extern u_long    vf_to_stf();        /* map VFS flags to statfs flags */
  135. extern int    dounmount();        /* unmount a vfs */
  136.  
  137. #define VFS_INIT(vfsp, op, data)    { \
  138.     (vfsp)->vfs_next = (struct vfs *)0; \
  139.     (vfsp)->vfs_op = (op); \
  140.     (vfsp)->vfs_flag = 0; \
  141.     (vfsp)->vfs_data = (data); \
  142.     (vfsp)->vfs_nsubmounts = 0; \
  143. }
  144.  
  145. /*
  146.  * Globals.
  147.  */
  148. extern struct vfs *rootvfs;        /* ptr to root vfs structure */
  149. extern struct vfssw vfssw[];        /* table of filesystem types */
  150. extern char rootfstype[];        /* name of root fstype */
  151. extern int nfstype;            /* # of elements in vfssw array */
  152.  
  153. /*
  154.  * Reasons for calling the vfs_mountroot() operation.
  155.  */
  156.  
  157. enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT };
  158. typedef enum whymountroot whymountroot_t;
  159.  
  160. /*
  161.  * VFS_SYNC flags.
  162.  */
  163. #define SYNC_ATTR    0x01        /* sync attributes only */
  164. #define SYNC_CLOSE    0x02        /* close open file */
  165.  
  166. #endif    /* _SYS_VFS_H */
  167.