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