home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / sys / mount.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-09  |  10.9 KB  |  325 lines

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