home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 May / W2KPRK.iso / apps / posix / source / INCLUDE / BSD / SYS / MOUNT.H < prev   
Encoding:
C/C++ Source or Header  |  1999-11-17  |  10.1 KB  |  299 lines

  1. /*
  2.  * Copyright (c) 1989 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  *
  33.  *    @(#)mount.h    7.22 (Berkeley) 6/3/91
  34.  */
  35.  
  36. #ifndef _POSIX_SOURCE
  37. typedef quad fsid_t;            /* file system id type */
  38. #endif
  39.  
  40. /*
  41.  * File identifier.
  42.  * These are unique per filesystem on a single machine.
  43.  */
  44. #define    MAXFIDSZ    16
  45.  
  46. struct fid {
  47.     u_short        fid_len;        /* length of data in bytes */
  48.     u_short        fid_reserved;        /* force longword alignment */
  49.     char        fid_data[MAXFIDSZ];    /* data (variable length) */
  50. };
  51.  
  52. /*
  53.  * file system statistics
  54.  */
  55.  
  56. #define MNAMELEN 90    /* length of buffer for returned name */
  57.  
  58. struct statfs {
  59.     short    f_type;            /* type of filesystem (see below) */
  60.     short    f_flags;        /* copy of mount flags */
  61.     long    f_fsize;        /* fundamental file system block size */
  62.     long    f_bsize;        /* optimal transfer block size */
  63.     long    f_blocks;        /* total data blocks in file system */
  64.     long    f_bfree;        /* free blocks in fs */
  65.     long    f_bavail;        /* free blocks avail to non-superuser */
  66.     long    f_files;        /* total file nodes in file system */
  67.     long    f_ffree;        /* free file nodes in fs */
  68. #ifdef _POSIX_SOURCE
  69.     struct _quad f_fsid;
  70. #else
  71.     fsid_t    f_fsid;            /* file system id */
  72. #endif
  73.     long    f_spare[9];        /* spare for later */
  74.     char    f_mntonname[MNAMELEN];    /* directory on which mounted */
  75.     char    f_mntfromname[MNAMELEN];/* mounted filesystem */
  76. };
  77.  
  78. /*
  79.  * File system types.
  80.  */
  81. #define    MOUNT_NONE    0
  82. #define    MOUNT_UFS    1
  83. #define    MOUNT_NFS    2
  84. #define    MOUNT_MFS    3
  85. #define    MOUNT_PC    4
  86. #define    MOUNT_MAXTYPE    4
  87.  
  88. /*
  89.  * Structure per mounted file system.
  90.  * Each mounted file system has an array of
  91.  * operations and an instance record.
  92.  * The file systems are put on a doubly linked list.
  93.  */
  94. struct mount {
  95.     struct mount    *mnt_next;        /* next in mount list */
  96.     struct mount    *mnt_prev;        /* prev in mount list */
  97.     struct vfsops    *mnt_op;        /* operations on fs */
  98.     struct vnode    *mnt_vnodecovered;    /* vnode we mounted on */
  99.     struct vnode    *mnt_mounth;        /* list of vnodes this mount */
  100.     int        mnt_flag;        /* flags */
  101.     uid_t        mnt_exroot;        /* exported mapping for uid 0 */
  102.     struct statfs    mnt_stat;        /* cache of filesystem stats */
  103.     qaddr_t        mnt_data;        /* private data */
  104. };
  105.  
  106. /*
  107.  * Mount flags.
  108.  */
  109. #define    MNT_RDONLY    0x00000001    /* read only filesystem */
  110. #define    MNT_SYNCHRONOUS    0x00000002    /* file system written synchronously */
  111. #define    MNT_NOEXEC    0x00000004    /* can't exec from filesystem */
  112. #define    MNT_NOSUID    0x00000008    /* don't honor setuid bits on fs */
  113. #define    MNT_NODEV    0x00000010    /* don't interpret special files */
  114.  
  115. /*
  116.  * exported mount flags.
  117.  */
  118. #define    MNT_EXPORTED    0x00000100    /* file system is exported */
  119. #define    MNT_EXRDONLY    0x00000200    /* exported read only */
  120.  
  121. /*
  122.  * Flags set by internal operations.
  123.  */
  124. #define    MNT_LOCAL    0x00001000    /* filesystem is stored locally */
  125. #define    MNT_QUOTA    0x00002000    /* quotas are enabled on filesystem */
  126.  
  127. /*
  128.  * Mask of flags that are visible to statfs()
  129.  */
  130. #define    MNT_VISFLAGMASK    0x0000ffff
  131.  
  132. /*
  133.  * filesystem control flags.
  134.  *
  135.  * MNT_MLOCK lock the mount entry so that name lookup cannot proceed
  136.  * past the mount point.  This keeps the subtree stable during mounts
  137.  * and unmounts.
  138.  */
  139. #define    MNT_UPDATE    0x00010000    /* not a real mount, just an update */
  140. #define    MNT_MLOCK    0x00100000    /* lock so that subtree is stable */
  141. #define    MNT_MWAIT    0x00200000    /* someone is waiting for lock */
  142. #define MNT_MPBUSY    0x00400000    /* scan of mount point in progress */
  143. #define MNT_MPWANT    0x00800000    /* waiting for mount point */
  144. #define MNT_UNMOUNT    0x01000000    /* unmount in progress */
  145.  
  146. /*
  147.  * Operations supported on mounted file system.
  148.  */
  149. #ifdef KERNEL
  150. #ifdef __STDC__
  151. struct nameidata;
  152. #endif
  153.  
  154. struct vfsops {
  155.     int    (*vfs_mount)    __P((struct mount *mp, char *path, caddr_t data,
  156.                     struct nameidata *ndp, struct proc *p));
  157.     int    (*vfs_start)    __P((struct mount *mp, int flags,
  158.                     struct proc *p));
  159.     int    (*vfs_unmount)    __P((struct mount *mp, int mntflags,
  160.                     struct proc *p));
  161.     int    (*vfs_root)    __P((struct mount *mp, struct vnode **vpp));
  162.             /* int uid,        should be uid_t */
  163.     int    (*vfs_quotactl)    __P((struct mount *mp, int cmds, int uid,
  164.                     caddr_t arg, struct proc *p));
  165.     int    (*vfs_statfs)    __P((struct mount *mp, struct statfs *sbp,
  166.                     struct proc *p));
  167.     int    (*vfs_sync)    __P((struct mount *mp, int waitfor));
  168.     int    (*vfs_fhtovp)    __P((struct mount *mp, struct fid *fhp,
  169.                     struct vnode **vpp));
  170.     int    (*vfs_vptofh)    __P((struct vnode *vp, struct fid *fhp));
  171.     int    (*vfs_init)    __P(());
  172. };
  173.  
  174. #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
  175.     (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
  176. #define VFS_START(MP, FLAGS, P)      (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
  177. #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
  178. #define VFS_ROOT(MP, VPP)      (*(MP)->mnt_op->vfs_root)(MP, VPP)
  179. #define VFS_QUOTACTL(MP,C,U,A,P)  (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
  180. #define VFS_STATFS(MP, SBP, P)      (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
  181. #define VFS_SYNC(MP, WAITFOR)      (*(MP)->mnt_op->vfs_sync)(MP, WAITFOR)
  182. #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
  183. #define    VFS_VPTOFH(VP, FIDP)      (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
  184. #endif /* KERNEL */
  185.  
  186. /*
  187.  * Flags for various system call interfaces.
  188.  *
  189.  * forcibly flags for vfs_umount().
  190.  * waitfor flags to vfs_sync() and getfsstat()
  191.  */
  192. #define MNT_FORCE    1
  193. #define MNT_NOFORCE    2
  194. #define MNT_WAIT    1
  195. #define MNT_NOWAIT    2
  196.  
  197. /*
  198.  * Generic file handle
  199.  */
  200. struct fhandle {
  201. #ifdef _POSIX_SOURCE
  202.     struct _quad fh_fsid;
  203. #else
  204.     fsid_t    fh_fsid;    /* File system id of mount point */
  205. #endif
  206.     struct    fid fh_fid;    /* Id of file */
  207. };
  208. typedef struct fhandle    fhandle_t;
  209.  
  210. /*
  211.  * Arguments to mount UFS
  212.  */
  213. struct ufs_args {
  214.     char    *fspec;        /* block special device to mount */
  215.     int    exflags;    /* export related flags */
  216.     uid_t    exroot;        /* mapping for root uid */
  217. };
  218.  
  219. #ifdef MFS
  220. /*
  221.  * Arguments to mount MFS
  222.  */
  223. struct mfs_args {
  224.     char    *name;        /* name to export for statfs */
  225.     caddr_t    base;        /* base address of file system in memory */
  226.     u_long size;        /* size of file system */
  227. };
  228. #endif /* MFS */
  229.  
  230. #ifdef NFS
  231. /*
  232.  * File Handle (32 bytes for version 2), variable up to 1024 for version 3
  233.  */
  234. union nfsv2fh {
  235.     fhandle_t    fh_generic;
  236.     u_char        fh_bytes[32];
  237. };
  238. typedef union nfsv2fh nfsv2fh_t;
  239.  
  240. /*
  241.  * Arguments to mount NFS
  242.  */
  243. struct nfs_args {
  244.     struct sockaddr    *addr;        /* file server address */
  245.     int        sotype;        /* Socket type */
  246.     int        proto;        /* and Protocol */
  247.     nfsv2fh_t    *fh;        /* File handle to be mounted */
  248.     int        flags;        /* flags */
  249.     int        wsize;        /* write size in bytes */
  250.     int        rsize;        /* read size in bytes */
  251.     int        timeo;        /* initial timeout in .1 secs */
  252.     int        retrans;    /* times to retry send */
  253.     char        *hostname;    /* server's name */
  254. };
  255. /*
  256.  * NFS mount option flags
  257.  */
  258. #define    NFSMNT_SOFT    0x0001    /* soft mount (hard is default) */
  259. #define    NFSMNT_WSIZE    0x0002    /* set write size */
  260. #define    NFSMNT_RSIZE    0x0004    /* set read size */
  261. #define    NFSMNT_TIMEO    0x0008    /* set initial timeout */
  262. #define    NFSMNT_RETRANS    0x0010    /* set number of request retrys */
  263. #define    NFSMNT_HOSTNAME    0x0020    /* set hostname for error printf */
  264. #define    NFSMNT_INT    0x0040    /* allow interrupts on hard mount */
  265. #define    NFSMNT_NOCONN    0x0080    /* Don't Connect the socket */
  266. #define    NFSMNT_SCKLOCK    0x0100    /* Lock socket against others */
  267. #define    NFSMNT_WANTSCK    0x0200    /* Want a socket lock */
  268. #define    NFSMNT_SPONGY    0x0400    /* spongy mount (soft for stat and lookup) */
  269. #define    NFSMNT_COMPRESS    0x0800    /* Compress nfs rpc xdr */
  270. #define    NFSMNT_LOCKBITS    (NFSMNT_SCKLOCK | NFSMNT_WANTSCK)
  271. #endif /* NFS */
  272.  
  273. #ifdef KERNEL
  274. /*
  275.  * exported vnode operations
  276.  */
  277. void    vfs_remove __P((struct mount *mp)); /* remove a vfs from mount list */
  278. int    vfs_lock __P((struct mount *mp));   /* lock a vfs */
  279. void    vfs_unlock __P((struct mount *mp)); /* unlock a vfs */
  280. struct    mount *getvfs __P((fsid_t *fsid));  /* return vfs given fsid */
  281. struct    mount *rootfs;                /* ptr to root mount structure */
  282. struct    vfsops *vfssw[];            /* mount filesystem type table */
  283.  
  284. #else /* KERNEL */
  285.  
  286. #include <sys/cdefs.h>
  287.  
  288. __BEGIN_DECLS
  289. int    fstatfs __P((int, struct statfs *));
  290. int    getfh __P((const char *, fhandle_t *));
  291. int    getfsstat __P((struct statfs *, long, int));
  292. int    getmntinfo __P((struct statfs **, int));
  293. int    mount __P((int, const char *, int, void *));
  294. int    statfs __P((const char *, struct statfs *));
  295. int    unmount __P((const char *, int));
  296. __END_DECLS
  297.  
  298. #endif /* KERNEL */
  299.