The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/mount.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: mount.h,v 1.127 2005/02/03 19:20:01 perry Exp $        */
    2 
    3 /*
    4  * Copyright (c) 1989, 1991, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  *
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  * 3. Neither the name of the University nor the names of its contributors
   16  *    may be used to endorse or promote products derived from this software
   17  *    without specific prior written permission.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   22  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   23  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   24  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   25  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   26  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   27  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   28  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   29  * SUCH DAMAGE.
   30  *
   31  *      @(#)mount.h     8.21 (Berkeley) 5/20/95
   32  */
   33 
   34 #ifndef _SYS_MOUNT_H_
   35 #define _SYS_MOUNT_H_
   36 
   37 #ifdef _KERNEL_OPT
   38 #include "opt_compat_43.h"
   39 #endif
   40 
   41 #ifndef _KERNEL
   42 #include <sys/featuretest.h>
   43 #include <sys/ucred.h>
   44 #if defined(_NETBSD_SOURCE)
   45 #include <sys/stat.h>
   46 #endif /* _NETBSD_SOURCE */
   47 #endif
   48 #include <sys/fstypes.h>
   49 #include <sys/queue.h>
   50 #include <sys/lock.h>
   51 #include <sys/statvfs.h>
   52 
   53 /*
   54  * file system statistics
   55  */
   56 
   57 #define MFSNAMELEN      16      /* length of fs type name, including nul */
   58 #define MNAMELEN        90      /* length of buffer for returned name */
   59 
   60 #if defined(__LIBC12_SOURCE__) || defined(_KERNEL)
   61 struct statfs12 {
   62         short   f_type;                 /* type of file system */
   63         u_short f_oflags;               /* deprecated copy of mount flags */
   64         long    f_bsize;                /* fundamental file system block size */
   65         long    f_iosize;               /* optimal transfer block size */
   66         long    f_blocks;               /* total data blocks in file system */
   67         long    f_bfree;                /* free blocks in fs */
   68         long    f_bavail;               /* free blocks avail to non-superuser */
   69         long    f_files;                /* total file nodes in file system */
   70         long    f_ffree;                /* free file nodes in fs */
   71         fsid_t  f_fsid;                 /* file system id */
   72         uid_t   f_owner;                /* user that mounted the file system */
   73         long    f_flags;                /* copy of mount flags */
   74         long    f_syncwrites;           /* count of sync writes since mount */
   75         long    f_asyncwrites;          /* count of async writes since mount */
   76         long    f_spare[1];             /* spare for later */
   77         char    f_fstypename[MFSNAMELEN]; /* fs type name */
   78         char    f_mntonname[MNAMELEN];    /* directory on which mounted */
   79         char    f_mntfromname[MNAMELEN];  /* mounted file system */
   80 };
   81 #endif
   82 
   83 /*
   84  * File system types.
   85  */
   86 #define MOUNT_FFS       "ffs"           /* UNIX "Fast" Filesystem */
   87 #define MOUNT_UFS       MOUNT_FFS       /* for compatibility */
   88 #define MOUNT_NFS       "nfs"           /* Network Filesystem */
   89 #define MOUNT_MFS       "mfs"           /* Memory Filesystem */
   90 #define MOUNT_MSDOS     "msdos"         /* MSDOS Filesystem */
   91 #define MOUNT_LFS       "lfs"           /* Log-based Filesystem */
   92 #define MOUNT_FDESC     "fdesc"         /* File Descriptor Filesystem */
   93 #define MOUNT_PORTAL    "portal"        /* Portal Filesystem */
   94 #define MOUNT_NULL      "null"          /* Minimal Filesystem Layer */
   95 #define MOUNT_OVERLAY   "overlay"       /* Minimal Overlay Filesystem Layer */
   96 #define MOUNT_UMAP      "umap"  /* User/Group Identifier Remapping Filesystem */
   97 #define MOUNT_KERNFS    "kernfs"        /* Kernel Information Filesystem */
   98 #define MOUNT_PROCFS    "procfs"        /* /proc Filesystem */
   99 #define MOUNT_AFS       "afs"           /* Andrew Filesystem */
  100 #define MOUNT_CD9660    "cd9660"        /* ISO9660 (aka CDROM) Filesystem */
  101 #define MOUNT_UNION     "union"         /* Union (translucent) Filesystem */
  102 #define MOUNT_ADOSFS    "adosfs"        /* AmigaDOS Filesystem */
  103 #define MOUNT_EXT2FS    "ext2fs"        /* Second Extended Filesystem */
  104 #define MOUNT_CFS       "coda"          /* Coda Filesystem */
  105 #define MOUNT_CODA      MOUNT_CFS       /* Coda Filesystem */
  106 #define MOUNT_FILECORE  "filecore"      /* Acorn Filecore Filesystem */
  107 #define MOUNT_NTFS      "ntfs"          /* Windows/NT Filesystem */
  108 #define MOUNT_SMBFS     "smbfs"         /* CIFS (SMB) */
  109 #define MOUNT_PTYFS     "ptyfs"         /* Pseudo tty filesystem */
  110 
  111 /*
  112  * Structure per mounted file system.  Each mounted file system has an
  113  * array of operations and an instance record.  The file systems are
  114  * put on a doubly linked list.
  115  */
  116 LIST_HEAD(vnodelst, vnode);
  117 
  118 struct mount {
  119         CIRCLEQ_ENTRY(mount) mnt_list;          /* mount list */
  120         struct vfsops   *mnt_op;                /* operations on fs */
  121         struct vnode    *mnt_vnodecovered;      /* vnode we mounted on */
  122         struct vnode    *mnt_syncer;            /* syncer vnode */
  123         struct vnodelst mnt_vnodelist;          /* list of vnodes this mount */
  124         struct lock     mnt_lock;               /* mount structure lock */
  125         int             mnt_flag;               /* flags */
  126         int             mnt_iflag;              /* internal flags */
  127         int             mnt_fs_bshift;          /* offset shift for lblkno */
  128         int             mnt_dev_bshift;         /* shift for device sectors */
  129         struct statvfs  mnt_stat;               /* cache of filesystem stats */
  130         void            *mnt_data;              /* private data */
  131         int             mnt_wcnt;               /* count of vfs_busy waiters */
  132         struct proc     *mnt_unmounter;         /* who is unmounting */
  133         int             mnt_writeopcountupper;  /* upper writeops in progress */
  134         int             mnt_writeopcountlower;  /* lower writeops in progress */
  135         struct simplelock mnt_slock;            /* mutex for wcnt and
  136                                                    writeops counters */
  137         struct mount    *mnt_leaf;              /* leaf fs we mounted on */
  138 };
  139 
  140 /*
  141  * Sysctl CTL_VFS definitions.
  142  *
  143  * Second level identifier specifies which filesystem. Second level
  144  * identifier VFS_GENERIC returns information about all filesystems.
  145  *
  146  * Note the slightly non-flat nature of these sysctl numbers.  Oh for
  147  * a better sysctl interface.
  148  */
  149 #define VFS_GENERIC     0               /* generic filesystem information */
  150 #define VFS_MAXTYPENUM  1               /* int: highest defined fs type */
  151 #define VFS_CONF        2               /* struct: vfsconf for filesystem given
  152                                            as next argument */
  153 #define VFS_USERMOUNT   3               /* enable/disable fs mnt by non-root */
  154 #define VFSGEN_MAXID    4               /* number of valid vfs.generic ids */
  155 
  156 /*
  157  * USE THE SAME NAMES AS MOUNT_*!
  158  *
  159  * Only need to add new entry here if the filesystem actually supports
  160  * sysctl(2).
  161  */
  162 #define CTL_VFS_NAMES { \
  163         { "generic", CTLTYPE_NODE }, \
  164         { MOUNT_FFS, CTLTYPE_NODE }, \
  165         { MOUNT_NFS, CTLTYPE_NODE }, \
  166         { MOUNT_MFS, CTLTYPE_NODE }, \
  167         { MOUNT_MSDOS, CTLTYPE_NODE }, \
  168         { MOUNT_LFS, CTLTYPE_NODE }, \
  169         { 0, 0 },                       /* MOUNT_LOFS */ \
  170         { MOUNT_FDESC, CTLTYPE_NODE }, \
  171         { MOUNT_PORTAL, CTLTYPE_NODE }, \
  172         { MOUNT_NULL, CTLTYPE_NODE }, \
  173         { MOUNT_UMAP, CTLTYPE_NODE }, \
  174         { MOUNT_KERNFS, CTLTYPE_NODE }, \
  175         { MOUNT_PROCFS, CTLTYPE_NODE }, \
  176         { MOUNT_AFS, CTLTYPE_NODE }, \
  177         { MOUNT_CD9660, CTLTYPE_NODE }, \
  178         { MOUNT_UNION, CTLTYPE_NODE }, \
  179         { MOUNT_ADOSFS, CTLTYPE_NODE }, \
  180         { MOUNT_EXT2FS, CTLTYPE_NODE }, \
  181         { MOUNT_CODA, CTLTYPE_NODE }, \
  182         { MOUNT_FILECORE, CTLTYPE_NODE }, \
  183         { MOUNT_NTFS, CTLTYPE_NODE }, \
  184 }
  185 
  186 #define VFS_MAXID       20              /* number of valid vfs ids */
  187 
  188 #define CTL_VFSGENCTL_NAMES { \
  189         { 0, 0 }, \
  190         { "maxtypenum", CTLTYPE_INT }, \
  191         { "conf", CTLTYPE_NODE },       /* Special */ \
  192         { "usermount", CTLTYPE_INT }, \
  193 }
  194 
  195 /*
  196  * Operations supported on mounted file system.
  197  */
  198 #ifdef _KERNEL
  199 
  200 #if defined(COMPAT_09) || defined(COMPAT_43) || defined(COMPAT_44)
  201 
  202 /*
  203  * Filesystem configuration information. Not used by NetBSD, but
  204  * defined here to provide a compatible sysctl interface to Lite2.
  205  */
  206 struct vfsconf {
  207         struct  vfsops *vfc_vfsops;     /* filesystem operations vector */
  208         char    vfc_name[MFSNAMELEN];   /* filesystem type name */
  209         int     vfc_typenum;            /* historic filesystem type number */
  210         int     vfc_refcount;           /* number mounted of this type */
  211         int     vfc_flags;              /* permanent flags */
  212         int     (*vfc_mountroot)(void); /* if != NULL, routine to mount root */
  213         struct  vfsconf *vfc_next;      /* next in list */
  214 };
  215 
  216 #endif
  217 
  218 #if __STDC__
  219 struct nameidata;
  220 struct mbuf;
  221 struct vnodeopv_desc;
  222 #endif
  223 
  224 struct vfsops {
  225         const char *vfs_name;
  226         int     (*vfs_mount)    (struct mount *, const char *, void *,
  227                                     struct nameidata *, struct proc *);
  228         int     (*vfs_start)    (struct mount *, int, struct proc *);
  229         int     (*vfs_unmount)  (struct mount *, int, struct proc *);
  230         int     (*vfs_root)     (struct mount *, struct vnode **);
  231         int     (*vfs_quotactl) (struct mount *, int, uid_t, void *,
  232                                     struct proc *);
  233         int     (*vfs_statvfs)  (struct mount *, struct statvfs *,
  234                                     struct proc *);
  235         int     (*vfs_sync)     (struct mount *, int, struct ucred *,
  236                                     struct proc *);
  237         int     (*vfs_vget)     (struct mount *, ino_t, struct vnode **);
  238         int     (*vfs_fhtovp)   (struct mount *, struct fid *,
  239                                     struct vnode **);
  240         int     (*vfs_vptofh)   (struct vnode *, struct fid *);
  241         void    (*vfs_init)     (void);
  242         void    (*vfs_reinit)   (void);
  243         void    (*vfs_done)     (void);
  244         int     *vfs_wassysctl;                 /* @@@ no longer useful */
  245         int     (*vfs_mountroot)(void);
  246         int     (*vfs_checkexp) (struct mount *, struct mbuf *, int *,
  247                                     struct ucred **);
  248         int     (*vfs_snapshot) (struct mount *, struct vnode *,
  249                                     struct timespec *);
  250         int     (*vfs_extattrctl) (struct mount *, int,
  251                                     struct vnode *, int, const char *,
  252                                     struct proc *);
  253         const struct vnodeopv_desc * const *vfs_opv_descs;
  254         int     vfs_refcount;
  255         LIST_ENTRY(vfsops) vfs_list;
  256 };
  257 
  258 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
  259         (*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
  260 #define VFS_START(MP, FLAGS, P)   (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
  261 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
  262 #define VFS_ROOT(MP, VPP)         (*(MP)->mnt_op->vfs_root)(MP, VPP)
  263 #define VFS_QUOTACTL(MP,C,U,A,P)  (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
  264 #define VFS_STATVFS(MP, SBP, P)   (*(MP)->mnt_op->vfs_statvfs)(MP, SBP, P)
  265 #define VFS_SYNC(MP, WAIT, C, P)  (*(MP)->mnt_op->vfs_sync)(MP, WAIT, C, P)
  266 #define VFS_VGET(MP, INO, VPP)    (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
  267 #define VFS_FHTOVP(MP, FIDP, VPP) (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
  268 #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \
  269         (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED)
  270 #define VFS_VPTOFH(VP, FIDP)      (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
  271 #define VFS_SNAPSHOT(MP, VP, TS)  (*(MP)->mnt_op->vfs_snapshot)(MP, VP, TS)
  272 #define VFS_EXTATTRCTL(MP, C, VP, AS, AN, P) \
  273         (*(MP)->mnt_op->vfs_extattrctl)(MP, C, VP, AS, AN, P)
  274 #endif /* _KERNEL */
  275 
  276 #ifdef _KERNEL
  277 #include <net/radix.h>
  278 #include <sys/socket.h>         /* XXX for AF_MAX */
  279 
  280 /*
  281  * Network address lookup element
  282  */
  283 struct netcred {
  284         struct  radix_node netc_rnodes[2];
  285         int     netc_refcnt;
  286         int     netc_exflags;
  287         struct  ucred netc_anon;
  288 };
  289 
  290 /*
  291  * Network export information
  292  */
  293 struct netexport {
  294         struct  netcred ne_defexported;               /* Default export */
  295         struct  radix_node_head *ne_rtable[AF_MAX+1]; /* Individual exports */
  296 };
  297 #endif /* _KERNEL */
  298 
  299 /*
  300  * Export arguments for local filesystem mount calls.
  301  */
  302 struct export_args {
  303         int     ex_flags;               /* export related flags */
  304         uid_t   ex_root;                /* mapping for root uid */
  305         struct  uucred ex_anon;         /* mapping for anonymous user */
  306         struct  sockaddr *ex_addr;      /* net address to which exported */
  307         int     ex_addrlen;             /* and the net address length */
  308         struct  sockaddr *ex_mask;      /* mask of valid bits in saddr */
  309         int     ex_masklen;             /* and the smask length */
  310         char    *ex_indexfile;          /* index file for WebNFS URLs */
  311 };
  312 
  313 /*
  314  * Structure holding information for a publicly exported filesystem
  315  * (WebNFS). Currently the specs allow just for one such filesystem.
  316  */
  317 struct nfs_public {
  318         int             np_valid;       /* Do we hold valid information */
  319         fhandle_t       np_handle;      /* Filehandle for pub fs (internal) */
  320         struct mount    *np_mount;      /* Mountpoint of exported fs */
  321         char            *np_index;      /* Index file */
  322 };
  323 
  324 #ifdef _KERNEL
  325 #include <sys/mallocvar.h>
  326 MALLOC_DECLARE(M_MOUNT);
  327 
  328 /*
  329  * exported VFS interface (see vfssubr(9))
  330  */
  331 struct  mount *vfs_getvfs(fsid_t *);    /* return vfs given fsid */
  332 int     vfs_export                          /* process mount export info */
  333          (struct mount *, struct netexport *, struct export_args *);
  334 #define vfs_showexport(a, b, c) (void)memset((b), 0, sizeof(*(b)))
  335 struct  netcred *vfs_export_lookup          /* lookup host in fs export list */
  336          (struct mount *, struct netexport *, struct mbuf *);
  337 int     vfs_setpublicfs                     /* set publicly exported fs */
  338          (struct mount *, struct netexport *, struct export_args *);
  339 int     vfs_mountedon(struct vnode *);/* is a vfs mounted on vp */
  340 int     vfs_mountroot(void);
  341 void    vfs_shutdown(void);         /* unmount and sync file systems */
  342 void    vfs_unmountall(struct proc *);      /* unmount file systems */
  343 int     vfs_busy(struct mount *, int, struct simplelock *);
  344 int     vfs_rootmountalloc(char *, char *, struct mount **);
  345 void    vfs_unbusy(struct mount *);
  346 int     vfs_attach(struct vfsops *);
  347 int     vfs_detach(struct vfsops *);
  348 void    vfs_reinit(void);
  349 struct vfsops *vfs_getopsbyname(const char *);
  350 
  351 int     vfs_stdextattrctl(struct mount *, int, struct vnode *,
  352             int, const char *, struct proc *);
  353 
  354 extern  CIRCLEQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
  355 extern  struct vfsops *vfssw[];                 /* filesystem type table */
  356 extern  int nvfssw;
  357 extern  struct nfs_public nfs_pub;
  358 extern  struct simplelock mountlist_slock;
  359 extern  struct simplelock spechash_slock;
  360 long    makefstype(const char *);
  361 int     dounmount(struct mount *, int, struct proc *);
  362 void    vfsinit(void);
  363 void    vfs_opv_init(const struct vnodeopv_desc * const *);
  364 void    vfs_opv_free(const struct vnodeopv_desc * const *);
  365 #ifdef DEBUG
  366 void    vfs_bufstats(void);
  367 #endif
  368 
  369 LIST_HEAD(vfs_list_head, vfsops);
  370 extern struct vfs_list_head vfs_list;
  371 
  372 #else /* _KERNEL */
  373 
  374 #include <sys/cdefs.h>
  375 
  376 __BEGIN_DECLS
  377 #ifdef __LIBC12_SOURCE__
  378 int     fstatfs(int, struct statfs12 *);
  379 int     getfsstat(struct statfs12 *, long, int);
  380 int     statfs(const char *, struct statfs12 *);
  381 int     getmntinfo(struct statfs12 **, int);
  382 #endif
  383 int     getfh(const char *, fhandle_t *);
  384 int     mount(const char *, const char *, int, void *);
  385 int     unmount(const char *, int);
  386 #if defined(_NETBSD_SOURCE)
  387 int     fhopen(const fhandle_t *, int);
  388 int     fhstat(const fhandle_t *, struct stat *);
  389 #ifdef __LIBC12_SOURCE__
  390 int     fhstatfs(const fhandle_t *, struct statfs12 *);
  391 #endif
  392 #endif /* _NETBSD_SOURCE */
  393 __END_DECLS
  394 
  395 #endif /* _KERNEL */
  396 
  397 #endif /* !_SYS_MOUNT_H_ */

Cache object: 1596c12d32efc2c02938185d640dc662


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.