root/sys/mount.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


    1 /*      $OpenBSD: mount.h,v 1.81 2007/06/01 05:37:14 deraadt Exp $      */
    2 /*      $NetBSD: mount.h,v 1.48 1996/02/18 11:55:47 fvdl Exp $  */
    3 
    4 /*
    5  * Copyright (c) 1989, 1991, 1993
    6  *      The Regents of the University of California.  All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  * 3. Neither the name of the University nor the names of its contributors
   17  *    may be used to endorse or promote products derived from this software
   18  *    without specific prior written permission.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   30  * SUCH DAMAGE.
   31  *
   32  *      @(#)mount.h     8.15 (Berkeley) 7/14/94
   33  */
   34 
   35 #ifndef _SYS_MOUNT_H_
   36 #define _SYS_MOUNT_H_
   37 
   38 #include <sys/cdefs.h>
   39 #ifndef _KERNEL
   40 #include <sys/ucred.h>
   41 #endif
   42 #include <sys/queue.h>
   43 #include <sys/rwlock.h>
   44 
   45 typedef struct { int32_t val[2]; } fsid_t;      /* file system id type */
   46 
   47 /*
   48  * File identifier.
   49  * These are unique per filesystem on a single machine.
   50  */
   51 #define MAXFIDSZ        16
   52 
   53 struct fid {
   54         u_short         fid_len;                /* length of data in bytes */
   55         u_short         fid_reserved;           /* force longword alignment */
   56         char            fid_data[MAXFIDSZ];     /* data (variable length) */
   57 };
   58 
   59 /*
   60  * Export arguments for local filesystem mount calls.
   61  */
   62 struct export_args {
   63         int     ex_flags;               /* export related flags */
   64         uid_t   ex_root;                /* mapping for root uid */
   65         struct  ucred ex_anon;          /* mapping for anonymous user */
   66         struct  sockaddr *ex_addr;      /* net address to which exported */
   67         int     ex_addrlen;             /* and the net address length */
   68         struct  sockaddr *ex_mask;      /* mask of valid bits in saddr */
   69         int     ex_masklen;             /* and the smask length */
   70 };
   71 
   72 /*
   73  * Arguments to mount UFS-based filesystems
   74  */
   75 struct ufs_args {
   76         char    *fspec;                 /* block special device to mount */
   77         struct  export_args export_info;/* network export information */
   78 };
   79 
   80 /*
   81  * Arguments to mount MFS
   82  */
   83 struct mfs_args {
   84         char    *fspec;                 /* name to export for statfs */
   85         struct  export_args export_info;/* if exported MFSes are supported */
   86         caddr_t base;                   /* base of file system in memory */
   87         u_long  size;                   /* size of file system */
   88 };
   89 
   90 /*
   91  * Arguments to mount ISO 9660 filesystems.
   92  */
   93 struct iso_args {
   94         char    *fspec;                 /* block special device to mount */
   95         struct  export_args export_info;/* network export info */
   96         int     flags;                  /* mounting flags, see below */
   97         int     sess;                   /* start sector of session */
   98 };
   99 
  100 #define ISOFSMNT_NORRIP         0x00000001      /* disable Rock Ridge Ext.*/
  101 #define ISOFSMNT_GENS           0x00000002      /* enable generation numbers */
  102 #define ISOFSMNT_EXTATT         0x00000004      /* enable extended attr. */
  103 #define ISOFSMNT_NOJOLIET       0x00000008      /* disable Joliet Ext.*/
  104 #define ISOFSMNT_SESS           0x00000010      /* use iso_args.sess */
  105 
  106 /*
  107  * Arguments to mount NFS
  108  */
  109 #define NFS_ARGSVERSION 4               /* change when nfs_args changes */
  110 struct nfs_args {
  111         int             version;        /* args structure version number */
  112         struct sockaddr *addr;          /* file server address */
  113         int             addrlen;        /* length of address */
  114         int             sotype;         /* Socket type */
  115         int             proto;          /* and Protocol */
  116         u_char          *fh;            /* File handle to be mounted */
  117         int             fhsize;         /* Size, in bytes, of fh */
  118         int             flags;          /* flags */
  119         int             wsize;          /* write size in bytes */
  120         int             rsize;          /* read size in bytes */
  121         int             readdirsize;    /* readdir size in bytes */
  122         int             timeo;          /* initial timeout in .1 secs */
  123         int             retrans;        /* times to retry send */
  124         int             maxgrouplist;   /* Max. size of group list */
  125         int             readahead;      /* # of blocks to readahead */
  126         int             leaseterm;      /* Term (sec) of lease */
  127         int             deadthresh;     /* Retrans threshold */
  128         char            *hostname;      /* server's name */
  129         int             acregmin;       /* Attr cache file recently modified */
  130         int             acregmax;       /* ac file not recently modified */
  131         int             acdirmin;       /* ac for dir recently modified */
  132         int             acdirmax;       /* ac for dir not recently modified */
  133 };
  134 /* NFS args version 3 (for backwards compatibility) */
  135 struct nfs_args3 {
  136         int             version;        /* args structure version number */
  137         struct sockaddr *addr;          /* file server address */
  138         int             addrlen;        /* length of address */
  139         int             sotype;         /* Socket type */
  140         int             proto;          /* and Protocol */
  141         u_char          *fh;            /* File handle to be mounted */
  142         int             fhsize;         /* Size, in bytes, of fh */
  143         int             flags;          /* flags */
  144         int             wsize;          /* write size in bytes */
  145         int             rsize;          /* read size in bytes */
  146         int             readdirsize;    /* readdir size in bytes */
  147         int             timeo;          /* initial timeout in .1 secs */
  148         int             retrans;        /* times to retry send */
  149         int             maxgrouplist;   /* Max. size of group list */
  150         int             readahead;      /* # of blocks to readahead */
  151         int             leaseterm;      /* Term (sec) of lease */
  152         int             deadthresh;     /* Retrans threshold */
  153         char            *hostname;      /* server's name */
  154 };
  155 
  156 /*
  157  * NFS mount option flags
  158  */
  159 #ifndef _KERNEL
  160 #define NFSMNT_RESVPORT         0x00000000  /* always use reserved ports */
  161 #endif /* ! _KERNEL */
  162 #define NFSMNT_SOFT             0x00000001  /* soft mount (hard is default) */
  163 #define NFSMNT_WSIZE            0x00000002  /* set write size */
  164 #define NFSMNT_RSIZE            0x00000004  /* set read size */
  165 #define NFSMNT_TIMEO            0x00000008  /* set initial timeout */
  166 #define NFSMNT_RETRANS          0x00000010  /* set number of request retries */
  167 #define NFSMNT_MAXGRPS          0x00000020  /* set maximum grouplist size */
  168 #define NFSMNT_INT              0x00000040  /* allow interrupts on hard mount */
  169 #define NFSMNT_NOCONN           0x00000080  /* Don't Connect the socket */
  170 #define NFSMNT_NQNFS            0x00000100  /* Use Nqnfs protocol */
  171 #define NFSMNT_NFSV3            0x00000200  /* Use NFS Version 3 protocol */
  172 #define NFSMNT_KERB             0x00000400  /* Use Kerberos authentication */
  173 #define NFSMNT_DUMBTIMR         0x00000800  /* Don't estimate rtt dynamically */
  174 #define NFSMNT_LEASETERM        0x00001000  /* set lease term (nqnfs) */
  175 #define NFSMNT_READAHEAD        0x00002000  /* set read ahead */
  176 #define NFSMNT_DEADTHRESH       0x00004000  /* set dead server retry thresh */
  177 #ifdef _KERNEL /* Coming soon to a system call near you! */
  178 #define NFSMNT_NOAC             0x00008000  /* disable attribute cache */
  179 #endif /* _KERNEL */
  180 #define NFSMNT_RDIRPLUS         0x00010000  /* Use Readdirplus for V3 */
  181 #define NFSMNT_READDIRSIZE      0x00020000  /* Set readdir size */
  182 
  183 /* Flags valid only in mount syscall arguments */
  184 #define NFSMNT_ACREGMIN         0x00040000  /* acregmin field valid */
  185 #define NFSMNT_ACREGMAX         0x00080000  /* acregmax field valid */
  186 #define NFSMNT_ACDIRMIN         0x00100000  /* acdirmin field valid */
  187 #define NFSMNT_ACDIRMAX         0x00200000  /* acdirmax field valid */
  188 
  189 /* Flags valid only in kernel */
  190 #define NFSMNT_INTERNAL         0xfffc0000  /* Bits set internally */
  191 #define NFSMNT_HASWRITEVERF     0x00040000  /* Has write verifier for V3 */
  192 #define NFSMNT_GOTPATHCONF      0x00080000  /* Got the V3 pathconf info */
  193 #define NFSMNT_GOTFSINFO        0x00100000  /* Got the V3 fsinfo */
  194 #define NFSMNT_MNTD             0x00200000  /* Mnt server for mnt point */
  195 #define NFSMNT_DISMINPROG       0x00400000  /* Dismount in progress */
  196 #define NFSMNT_DISMNT           0x00800000  /* Dismounted */
  197 #define NFSMNT_SNDLOCK          0x01000000  /* Send socket lock */
  198 #define NFSMNT_WANTSND          0x02000000  /* Want above */
  199 #define NFSMNT_RCVLOCK          0x04000000  /* Rcv socket lock */
  200 #define NFSMNT_WANTRCV          0x08000000  /* Want above */
  201 #define NFSMNT_WAITAUTH         0x10000000  /* Wait for authentication */
  202 #define NFSMNT_HASAUTH          0x20000000  /* Has authenticator */
  203 #define NFSMNT_WANTAUTH         0x40000000  /* Wants an authenticator */
  204 #define NFSMNT_AUTHERR          0x80000000  /* Authentication error */
  205 
  206 /*
  207  *  Arguments to mount MSDOS filesystems.
  208  */
  209 struct msdosfs_args {
  210         char    *fspec;         /* blocks special holding the fs to mount */
  211         struct  export_args export_info;
  212                                 /* network export information */
  213         uid_t   uid;            /* uid that owns msdosfs files */
  214         gid_t   gid;            /* gid that owns msdosfs files */
  215         mode_t  mask;           /* mask to be applied for msdosfs perms */
  216         int     flags;          /* see below */
  217 };
  218 
  219 /*
  220  * Msdosfs mount options:
  221  */
  222 #define MSDOSFSMNT_SHORTNAME    0x01    /* Force old DOS short names only */
  223 #define MSDOSFSMNT_LONGNAME     0x02    /* Force Win'95 long names */
  224 #define MSDOSFSMNT_NOWIN95      0x04    /* Completely ignore Win95 entries */
  225 #define MSDOSFSMNT_ALLOWDIRX    0x10    /* dir is mode +x if r */
  226 
  227 /*
  228  * Arguments to mount ntfs filesystems
  229  */
  230 struct ntfs_args {
  231         char    *fspec;                 /* block special device to mount */
  232         struct  export_args export_info;/* network export information */
  233         uid_t   uid;                    /* uid that owns ntfs files */
  234         gid_t   gid;                    /* gid that owns ntfs files */
  235         mode_t  mode;                   /* mask to be applied for ntfs perms */
  236         u_long  flag;                   /* additional flags */
  237 };
  238 
  239 /*
  240  * ntfs mount options:
  241  */
  242 #define NTFS_MFLAG_CASEINS      0x00000001
  243 #define NTFS_MFLAG_ALLNAMES     0x00000002
  244 
  245 /* Arguments to mount UDF file systems */
  246 struct udf_args {
  247         char *fspec; /* Block special device to mount */
  248         u_int32_t lastblock; /* Special device last block */
  249 };
  250 
  251 /*
  252  * Arguments to mount procfs filesystems
  253  */
  254 struct procfs_args {
  255         int version;
  256         int flags;
  257 };
  258 
  259 /*
  260  * procfs mount options:
  261  */
  262 #define PROCFS_ARGSVERSION      1
  263 #define PROCFSMNT_LINUXCOMPAT   0x01
  264 
  265 
  266 /*
  267  * file system statistics
  268  */
  269 
  270 #define MFSNAMELEN      16      /* length of fs type name, including nul */
  271 #define MNAMELEN        90      /* length of buffer for returned name */
  272 
  273 /* per-filesystem mount options */
  274 union mount_info {
  275         struct ufs_args ufs_args;
  276         struct mfs_args mfs_args;
  277         struct nfs_args nfs_args;
  278         struct iso_args iso_args;
  279         struct procfs_args procfs_args;
  280         struct msdosfs_args msdosfs_args;
  281         struct ntfs_args ntfs_args;
  282         char __align[160];      /* 64-bit alignment and room to grow */
  283 };
  284 
  285 /* new statfs structure with mount options */
  286 struct statfs {
  287         u_int32_t  f_flags;             /* copy of mount flags */
  288         int32_t    f_bsize;             /* fundamental file system block size */
  289         u_int32_t  f_iosize;            /* optimal transfer block size */
  290         u_int32_t  f_blocks;            /* total data blocks in file system */
  291         u_int32_t  f_bfree;             /* free blocks in fs */
  292         int32_t    f_bavail;            /* free blocks avail to non-superuser */
  293         u_int32_t  f_files;             /* total file nodes in file system */
  294         u_int32_t  f_ffree;             /* free file nodes in fs */
  295         fsid_t     f_fsid;              /* file system id */
  296         uid_t      f_owner;             /* user that mounted the file system */
  297         u_int32_t  f_syncwrites;        /* count of sync writes since mount */
  298         u_int32_t  f_asyncwrites;       /* count of async writes since mount */
  299         u_int32_t  f_ctime;             /* last mount [-u] time */
  300         u_int32_t  f_spare[3];          /* spare for later */
  301         char       f_fstypename[MFSNAMELEN]; /* fs type name */
  302         char       f_mntonname[MNAMELEN];    /* directory on which mounted */
  303         char       f_mntfromname[MNAMELEN];  /* mounted file system */
  304         union mount_info mount_info;        /* per-filesystem mount options */
  305 };
  306 
  307 /* old (pre-2.6) statfs structure */
  308 struct ostatfs {
  309         short   f_type;                 /* type of file system (unused; zero) */
  310         short   f_flags;                /* copy of mount flags */
  311         long    f_bsize;                /* fundamental file system block size */
  312         long    f_iosize;               /* optimal transfer block size */
  313         long    f_blocks;               /* total data blocks in file system */
  314         long    f_bfree;                /* free blocks in fs */
  315         long    f_bavail;               /* free blocks avail to non-superuser */
  316         long    f_files;                /* total file nodes in file system */
  317         long    f_ffree;                /* free file nodes in fs */
  318         fsid_t  f_fsid;                 /* file system id */
  319         uid_t   f_owner;                /* user that mounted the file system */
  320         long    f_syncwrites;           /* count of sync writes since mount */
  321         long    f_asyncwrites;          /* count of async writes since mount */
  322         long    f_spare[2];             /* spare for later */
  323         char    f_fstypename[MFSNAMELEN]; /* fs type name */
  324         char    f_mntonname[MNAMELEN];    /* directory on which mounted */
  325         char    f_mntfromname[MNAMELEN];  /* mounted file system */
  326 };
  327 
  328 /*
  329  * File system types.
  330  */
  331 #define MOUNT_FFS       "ffs"           /* UNIX "Fast" Filesystem */
  332 #define MOUNT_UFS       MOUNT_FFS       /* for compatibility */
  333 #define MOUNT_NFS       "nfs"           /* Network Filesystem */
  334 #define MOUNT_MFS       "mfs"           /* Memory Filesystem */
  335 #define MOUNT_MSDOS     "msdos"         /* MSDOS Filesystem */
  336 #define MOUNT_PORTAL    "portal"        /* Portal Filesystem */
  337 #define MOUNT_PROCFS    "procfs"        /* /proc Filesystem */
  338 #define MOUNT_AFS       "afs"           /* Andrew Filesystem */
  339 #define MOUNT_CD9660    "cd9660"        /* ISO9660 (aka CDROM) Filesystem */
  340 #define MOUNT_EXT2FS    "ext2fs"        /* Second Extended Filesystem */
  341 #define MOUNT_NCPFS     "ncpfs"         /* NetWare Network File System */
  342 #define MOUNT_XFS       "xfs"           /* xfs */
  343 #define MOUNT_NTFS      "ntfs"          /* NTFS */
  344 #define MOUNT_UDF       "udf"           /* UDF */
  345 
  346 /*
  347  * Structure per mounted file system.  Each mounted file system has an
  348  * array of operations and an instance record.  The file systems are
  349  * put on a doubly linked list.
  350  */
  351 LIST_HEAD(vnodelst, vnode);
  352 
  353 struct mount {
  354         CIRCLEQ_ENTRY(mount) mnt_list;          /* mount list */
  355         const struct vfsops *mnt_op;            /* operations on fs */
  356         struct vfsconf  *mnt_vfc;               /* configuration info */
  357         struct vnode    *mnt_vnodecovered;      /* vnode we mounted on */
  358         struct vnode    *mnt_syncer;            /* syncer vnode */
  359         struct vnodelst mnt_vnodelist;          /* list of vnodes this mount */
  360         struct rwlock   mnt_lock;               /* mount structure lock */
  361         int             mnt_flag;               /* flags */
  362         int             mnt_maxsymlinklen;      /* max size of short symlink */
  363         struct statfs   mnt_stat;               /* cache of filesystem stats */
  364         void            *mnt_data;              /* private data */
  365 };
  366 
  367 /*
  368  * Mount flags.
  369  *
  370  * Unmount uses MNT_FORCE flag.
  371  */
  372 #define MNT_RDONLY      0x00000001      /* read only filesystem */
  373 #define MNT_SYNCHRONOUS 0x00000002      /* file system written synchronously */
  374 #define MNT_NOEXEC      0x00000004      /* can't exec from filesystem */
  375 #define MNT_NOSUID      0x00000008      /* don't honor setuid bits on fs */
  376 #define MNT_NODEV       0x00000010      /* don't interpret special files */
  377 #define MNT_ASYNC       0x00000040      /* file system written asynchronously */
  378 
  379 /*
  380  * exported mount flags.
  381  */
  382 #define MNT_EXRDONLY    0x00000080      /* exported read only */
  383 #define MNT_EXPORTED    0x00000100      /* file system is exported */
  384 #define MNT_DEFEXPORTED 0x00000200      /* exported to the world */
  385 #define MNT_EXPORTANON  0x00000400      /* use anon uid mapping for everyone */
  386 #define MNT_EXKERB      0x00000800      /* exported with Kerberos uid mapping */
  387 
  388 /*
  389  * Flags set by internal operations.
  390  */
  391 #define MNT_LOCAL       0x00001000      /* filesystem is stored locally */
  392 #define MNT_QUOTA       0x00002000      /* quotas are enabled on filesystem */
  393 #define MNT_ROOTFS      0x00004000      /* identifies the root filesystem */
  394 
  395 /*
  396  * Extra post 4.4BSD-lite2 mount flags.
  397  */
  398 #define MNT_NOATIME     0x00008000      /* don't update access times on fs */
  399 
  400 /*
  401  * Mask of flags that are visible to statfs()
  402  */
  403 #define MNT_VISFLAGMASK 0x0400ffff
  404 
  405 #define MNT_BITS \
  406     "\010\001RDONLY\002SYNCHRONOUS\003NOEXEC\004NOSUID\005NODEV" \
  407     "\007ASYNC\010EXRDONLY\011EXPORTED\012DEFEXPORTED\013EXPORTANON" \
  408     "\014EXKERB\015LOCAL\016QUOTA\017ROOTFS"
  409 
  410 /*
  411  * filesystem control flags.
  412  */
  413 #define MNT_UPDATE      0x00010000      /* not a real mount, just an update */
  414 #define MNT_DELEXPORT   0x00020000      /* delete export host lists */
  415 #define MNT_RELOAD      0x00040000      /* reload filesystem data */
  416 #define MNT_FORCE       0x00080000      /* force unmount or readonly change */
  417 #define MNT_WANTRDWR    0x02000000      /* want upgrade to read/write */
  418 #define MNT_SOFTDEP     0x04000000      /* soft dependencies being done */
  419 #define MNT_DOOMED      0x08000000      /* device behind filesystem is gone */
  420 
  421 /*
  422  * Sysctl CTL_VFS definitions.
  423  *
  424  * Second level identifier specifies which filesystem. Second level
  425  * identifier VFS_GENERIC returns information about all filesystems.
  426  */
  427 #define VFS_GENERIC     0       /* generic filesystem information */
  428 /*
  429  * Third level identifiers for VFS_GENERIC are given below; third
  430  * level identifiers for specific filesystems are given in their
  431  * mount specific header files.
  432  */
  433 #define VFS_MAXTYPENUM  1       /* int: highest defined filesystem type */
  434 #define VFS_CONF        2       /* struct: vfsconf for filesystem given
  435                                    as next argument */
  436 #define CTL_VFSGENCTL_NAMES { \
  437         { 0, 0 }, \
  438         { "maxtypenum", CTLTYPE_INT }, \
  439         { "conf", CTLTYPE_NODE } \
  440 }
  441 
  442 /*
  443  * Filesystem configuration information. One of these exists for each
  444  * type of filesystem supported by the kernel. These are searched at
  445  * mount time to identify the requested filesystem.
  446  */
  447 struct vfsconf {
  448         const struct vfsops *vfc_vfsops; /* filesystem operations vector */
  449         char    vfc_name[MFSNAMELEN];   /* filesystem type name */
  450         int     vfc_typenum;            /* historic filesystem type number */
  451         int     vfc_refcount;           /* number mounted of this type */
  452         int     vfc_flags;              /* permanent flags */
  453         int     (*vfc_mountroot)(void); /* if != NULL, routine to mount root */
  454         struct  vfsconf *vfc_next;      /* next in list */
  455 };
  456 
  457 /*
  458  * Operations supported on mounted file system.
  459  */
  460 #ifdef _KERNEL
  461 #ifdef __STDC__
  462 struct nameidata;
  463 struct mbuf;
  464 #endif
  465 
  466 extern int maxvfsconf;          /* highest defined filesystem type */
  467 extern struct vfsconf *vfsconf; /* head of list of filesystem types */
  468 
  469 struct vfsops {
  470         int     (*vfs_mount)(struct mount *mp, const char *path,
  471                                     void *data,
  472                                     struct nameidata *ndp, struct proc *p);
  473         int     (*vfs_start)(struct mount *mp, int flags,
  474                                     struct proc *p);
  475         int     (*vfs_unmount)(struct mount *mp, int mntflags,
  476                                     struct proc *p);
  477         int     (*vfs_root)(struct mount *mp, struct vnode **vpp);
  478         int     (*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid,
  479                                     caddr_t arg, struct proc *p);
  480         int     (*vfs_statfs)(struct mount *mp, struct statfs *sbp,
  481                                     struct proc *p);
  482         int     (*vfs_sync)(struct mount *mp, int waitfor,
  483                                     struct ucred *cred, struct proc *p);
  484         int     (*vfs_vget)(struct mount *mp, ino_t ino,
  485                                     struct vnode **vpp);
  486         int     (*vfs_fhtovp)(struct mount *mp, struct fid *fhp,
  487                                      struct vnode **vpp);
  488         int     (*vfs_vptofh)(struct vnode *vp, struct fid *fhp);
  489         int     (*vfs_init)(struct vfsconf *);
  490         int     (*vfs_sysctl)(int *, u_int, void *, size_t *, void *,
  491                                      size_t, struct proc *);
  492         int     (*vfs_checkexp)(struct mount *mp, struct mbuf *nam,
  493                                     int *extflagsp, struct ucred **credanonp);
  494 };
  495 
  496 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
  497         (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
  498 #define VFS_START(MP, FLAGS, P)   (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
  499 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
  500 #define VFS_ROOT(MP, VPP)         (*(MP)->mnt_op->vfs_root)(MP, VPP)
  501 #define VFS_QUOTACTL(MP,C,U,A,P)  (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
  502 #define VFS_STATFS(MP, SBP, P)    (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
  503 #define VFS_SYNC(MP, WAIT, C, P)  (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
  504 #define VFS_VGET(MP, INO, VPP)    (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
  505 #define VFS_FHTOVP(MP, FIDP, VPP) \
  506         (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
  507 #define VFS_VPTOFH(VP, FIDP)      (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
  508 #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \
  509         (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED)
  510 #endif /* _KERNEL */
  511 
  512 /*
  513  * Flags for various system call interfaces.
  514  *
  515  * waitfor flags to vfs_sync() and getfsstat()
  516  */
  517 #define MNT_WAIT        1       /* synchronously wait for I/O to complete */
  518 #define MNT_NOWAIT      2       /* start all I/O, but do not wait for it */
  519 #define MNT_LAZY        3       /* push data not written by filesystem syncer */
  520 
  521 /*
  522  * Generic file handle
  523  */
  524 struct fhandle {
  525         fsid_t  fh_fsid;        /* File system id of mount point */
  526         struct  fid fh_fid;     /* File sys specific id */
  527 };
  528 typedef struct fhandle  fhandle_t;
  529 
  530 #ifdef _KERNEL
  531 #include <net/radix.h>
  532 #include <sys/socket.h>         /* XXX for AF_MAX */
  533 
  534 /*
  535  * Network address lookup element
  536  */
  537 struct netcred {
  538         struct  radix_node netc_rnodes[2];
  539         int     netc_exflags;
  540         struct  ucred netc_anon;
  541 };
  542 
  543 /*
  544  * Network export information
  545  */
  546 struct netexport {
  547         struct  netcred ne_defexported;               /* Default export */
  548         struct  radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
  549 };
  550 #endif /* _KERNEL */
  551 
  552 #ifdef _KERNEL
  553 /*
  554  * exported vnode operations
  555  */
  556 int     vfs_busy(struct mount *, int);
  557 #define VB_READ         0x01
  558 #define VB_WRITE        0x02
  559 #define VB_NOWAIT       0x04    /* immediately fail on busy lock */
  560 #define VB_WAIT         0x08    /* sleep fail on busy lock */
  561 
  562 int     vfs_isbusy(struct mount *);
  563 int     vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
  564                                     void *), void *);
  565 void    vfs_getnewfsid(struct mount *);
  566 struct  mount *vfs_getvfs(fsid_t *);
  567 int     vfs_mountedon(struct vnode *);
  568 int     vfs_mountroot(void);
  569 int     vfs_rootmountalloc(char *, char *, struct mount **);
  570 void    vfs_unbusy(struct mount *);
  571 void    vfs_unmountall(void);
  572 extern  CIRCLEQ_HEAD(mntlist, mount) mountlist;
  573 
  574 struct  mount *getvfs(fsid_t *);            /* return vfs given fsid */
  575                                             /* process mount export info */
  576 int     vfs_export(struct mount *, struct netexport *, struct export_args *);
  577                                             /* lookup host in fs export list */
  578 struct  netcred *vfs_export_lookup(struct mount *, struct netexport *,
  579             struct mbuf *);
  580 int     vfs_allocate_syncvnode(struct mount *);
  581 int     speedup_syncer(void);
  582 
  583 int     vfs_syncwait(int);      /* sync and wait for complete */
  584 void    vfs_shutdown(void);     /* unmount and sync file systems */
  585 long    makefstype(char *);
  586 int     dounmount(struct mount *, int, struct proc *, struct vnode *);
  587 void    vfsinit(void);
  588 void    vfs_bufstats(void);
  589 int     vfs_register(struct vfsconf *);
  590 int     vfs_unregister(struct vfsconf *);
  591 #else /* _KERNEL */
  592 
  593 #ifndef _SYS_STAT_H_
  594 struct stat;
  595 #endif
  596 
  597 __BEGIN_DECLS
  598 int     fstatfs(int, struct statfs *);
  599 int     getfh(const char *, fhandle_t *);
  600 int     getfsstat(struct statfs *, size_t, int);
  601 int     getmntinfo(struct statfs **, int);
  602 int     mount(const char *, const char *, int, void *);
  603 int     statfs(const char *, struct statfs *);
  604 int     unmount(const char *, int);
  605 #if __BSD_VISIBLE
  606 int     fhopen(const fhandle_t *, int);
  607 int     fhstat(const fhandle_t *, struct stat *);
  608 int     fhstatfs(const fhandle_t *, struct statfs *);
  609 #endif /* __BSD_VISIBLE */
  610 
  611 __END_DECLS
  612 
  613 #endif /* _KERNEL */
  614 #endif /* !_SYS_MOUNT_H_ */

/* [<][>][^][v][top][bottom][index][help] */