2005-01-07 02:29:27 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1989, 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
1997-02-10 02:22:35 +00:00
|
|
|
* @(#)mount.h 8.21 (Berkeley) 5/20/95
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
1994-08-21 04:42:17 +00:00
|
|
|
#ifndef _SYS_MOUNT_H_
|
|
|
|
#define _SYS_MOUNT_H_
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/ucred.h>
|
|
|
|
#include <sys/queue.h>
|
2000-12-04 09:21:05 +00:00
|
|
|
#ifdef _KERNEL
|
2008-03-01 19:47:50 +00:00
|
|
|
#include <sys/lock.h>
|
2002-11-07 21:45:28 +00:00
|
|
|
#include <sys/lockmgr.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/_mutex.h>
|
2014-08-03 03:27:54 +00:00
|
|
|
#include <sys/_sx.h>
|
2000-12-04 09:21:05 +00:00
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2008-04-26 13:04:48 +00:00
|
|
|
/*
|
|
|
|
* NOTE: When changing statfs structure, mount structure, MNT_* flags or
|
|
|
|
* MNTK_* flags also update DDB show mount command in vfs_subr.c.
|
|
|
|
*/
|
|
|
|
|
2002-05-16 21:28:32 +00:00
|
|
|
typedef struct fsid { int32_t val[2]; } fsid_t; /* filesystem id type */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* File identifier.
|
|
|
|
* These are unique per filesystem on a single machine.
|
|
|
|
*/
|
|
|
|
#define MAXFIDSZ 16
|
|
|
|
|
|
|
|
struct fid {
|
|
|
|
u_short fid_len; /* length of data in bytes */
|
2010-09-14 18:58:51 +00:00
|
|
|
u_short fid_data0; /* force longword alignment */
|
1994-05-24 10:09:53 +00:00
|
|
|
char fid_data[MAXFIDSZ]; /* data (variable length) */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2002-05-16 21:28:32 +00:00
|
|
|
* filesystem statistics
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2003-11-12 08:01:40 +00:00
|
|
|
#define MFSNAMELEN 16 /* length of type name including null */
|
|
|
|
#define MNAMELEN 88 /* size of on/from name bufs */
|
|
|
|
#define STATFS_VERSION 0x20030518 /* current version number */
|
|
|
|
struct statfs {
|
|
|
|
uint32_t f_version; /* structure version number */
|
|
|
|
uint32_t f_type; /* type of filesystem */
|
|
|
|
uint64_t f_flags; /* copy of mount exported flags */
|
|
|
|
uint64_t f_bsize; /* filesystem fragment size */
|
|
|
|
uint64_t f_iosize; /* optimal transfer block size */
|
|
|
|
uint64_t f_blocks; /* total data blocks in filesystem */
|
|
|
|
uint64_t f_bfree; /* free blocks in filesystem */
|
|
|
|
int64_t f_bavail; /* free blocks avail to non-superuser */
|
|
|
|
uint64_t f_files; /* total file nodes in filesystem */
|
|
|
|
int64_t f_ffree; /* free nodes avail to non-superuser */
|
|
|
|
uint64_t f_syncwrites; /* count of sync writes since mount */
|
|
|
|
uint64_t f_asyncwrites; /* count of async writes since mount */
|
|
|
|
uint64_t f_syncreads; /* count of sync reads since mount */
|
|
|
|
uint64_t f_asyncreads; /* count of async reads since mount */
|
|
|
|
uint64_t f_spare[10]; /* unused spare */
|
|
|
|
uint32_t f_namemax; /* maximum filename length */
|
|
|
|
uid_t f_owner; /* user that mounted the filesystem */
|
|
|
|
fsid_t f_fsid; /* filesystem id */
|
|
|
|
char f_charspare[80]; /* spare string space */
|
|
|
|
char f_fstypename[MFSNAMELEN]; /* filesystem type name */
|
|
|
|
char f_mntfromname[MNAMELEN]; /* mounted filesystem */
|
|
|
|
char f_mntonname[MNAMELEN]; /* directory on which mounted */
|
|
|
|
};
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2003-11-12 08:01:40 +00:00
|
|
|
#ifdef _KERNEL
|
|
|
|
#define OMFSNAMELEN 16 /* length of fs type name, including null */
|
|
|
|
#define OMNAMELEN (88 - 2 * sizeof(long)) /* size of on/from name bufs */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2002-11-07 21:45:28 +00:00
|
|
|
/* XXX getfsstat.2 is out of date with write and read counter changes here. */
|
|
|
|
/* XXX statfs.2 is out of date with read counter changes here. */
|
2003-11-12 08:01:40 +00:00
|
|
|
struct ostatfs {
|
1996-09-03 07:09:11 +00:00
|
|
|
long f_spare2; /* placeholder */
|
2002-05-16 21:28:32 +00:00
|
|
|
long f_bsize; /* fundamental filesystem block size */
|
1994-05-24 10:09:53 +00:00
|
|
|
long f_iosize; /* optimal transfer block size */
|
2002-05-16 21:28:32 +00:00
|
|
|
long f_blocks; /* total data blocks in filesystem */
|
1994-05-24 10:09:53 +00:00
|
|
|
long f_bfree; /* free blocks in fs */
|
|
|
|
long f_bavail; /* free blocks avail to non-superuser */
|
2002-05-16 21:28:32 +00:00
|
|
|
long f_files; /* total file nodes in filesystem */
|
1994-05-24 10:09:53 +00:00
|
|
|
long f_ffree; /* free file nodes in fs */
|
2002-05-16 21:28:32 +00:00
|
|
|
fsid_t f_fsid; /* filesystem id */
|
1996-09-03 07:09:11 +00:00
|
|
|
uid_t f_owner; /* user that mounted the filesystem */
|
1998-11-15 15:12:58 +00:00
|
|
|
int f_type; /* type of filesystem */
|
1997-11-12 05:42:33 +00:00
|
|
|
int f_flags; /* copy of mount exported flags */
|
2002-11-07 21:45:28 +00:00
|
|
|
long f_syncwrites; /* count of sync writes since mount */
|
|
|
|
long f_asyncwrites; /* count of async writes since mount */
|
2003-11-12 08:01:40 +00:00
|
|
|
char f_fstypename[OMFSNAMELEN]; /* fs type name */
|
|
|
|
char f_mntonname[OMNAMELEN]; /* directory on which mounted */
|
2002-11-07 21:45:28 +00:00
|
|
|
long f_syncreads; /* count of sync reads since mount */
|
|
|
|
long f_asyncreads; /* count of async reads since mount */
|
1999-12-01 02:09:30 +00:00
|
|
|
short f_spares1; /* unused spare */
|
2003-11-12 08:01:40 +00:00
|
|
|
char f_mntfromname[OMNAMELEN];/* mounted filesystem */
|
1999-12-01 02:09:30 +00:00
|
|
|
short f_spares2; /* unused spare */
|
2002-11-07 21:45:28 +00:00
|
|
|
/*
|
|
|
|
* XXX on machines where longs are aligned to 8-byte boundaries, there
|
|
|
|
* is an unnamed int32_t here. This spare was after the apparent end
|
|
|
|
* of the struct until we bit off the read counters from f_mntonname.
|
|
|
|
*/
|
|
|
|
long f_spare[2]; /* unused spare */
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
2002-11-07 21:45:28 +00:00
|
|
|
TAILQ_HEAD(vnodelst, vnode);
|
2004-12-07 08:15:41 +00:00
|
|
|
|
2009-03-02 23:26:30 +00:00
|
|
|
/* Mount options list */
|
|
|
|
TAILQ_HEAD(vfsoptlist, vfsopt);
|
|
|
|
struct vfsopt {
|
|
|
|
TAILQ_ENTRY(vfsopt) link;
|
|
|
|
char *name;
|
|
|
|
void *value;
|
|
|
|
int len;
|
|
|
|
int pos;
|
|
|
|
int seen;
|
|
|
|
};
|
2002-11-07 21:45:28 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
2002-05-16 21:28:32 +00:00
|
|
|
* Structure per mounted filesystem. Each mounted filesystem has an
|
|
|
|
* array of operations and an instance record. The filesystems are
|
1994-05-24 10:09:53 +00:00
|
|
|
* put on a doubly linked list.
|
2001-11-04 18:55:42 +00:00
|
|
|
*
|
2006-02-06 10:19:50 +00:00
|
|
|
* Lock reference:
|
2007-04-01 15:40:56 +00:00
|
|
|
* m - mountlist_mtx
|
2006-02-06 10:19:50 +00:00
|
|
|
* i - interlock
|
2012-05-18 18:35:09 +00:00
|
|
|
* v - vnode freelist mutex
|
2006-02-06 10:19:50 +00:00
|
|
|
*
|
|
|
|
* Unmarked fields are considered stable as long as a ref is held.
|
|
|
|
*
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
struct mount {
|
2006-03-31 03:49:16 +00:00
|
|
|
struct mtx mnt_mtx; /* mount structure interlock */
|
2006-10-03 10:47:04 +00:00
|
|
|
int mnt_gen; /* struct mount generation */
|
2006-03-31 03:49:16 +00:00
|
|
|
#define mnt_startzero mnt_list
|
2006-02-06 10:19:50 +00:00
|
|
|
TAILQ_ENTRY(mount) mnt_list; /* (m) mount list */
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vfsops *mnt_op; /* operations on fs */
|
1995-08-11 11:31:18 +00:00
|
|
|
struct vfsconf *mnt_vfc; /* configuration info */
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *mnt_vnodecovered; /* vnode we mounted on */
|
1998-03-08 09:59:44 +00:00
|
|
|
struct vnode *mnt_syncer; /* syncer vnode */
|
2006-02-06 10:19:50 +00:00
|
|
|
int mnt_ref; /* (i) Reference count */
|
|
|
|
struct vnodelst mnt_nvnodelist; /* (i) list of vnodes */
|
|
|
|
int mnt_nvnodelistsize; /* (i) # of vnodes */
|
2012-05-18 18:35:09 +00:00
|
|
|
struct vnodelst mnt_activevnodelist; /* (v) list of active vnodes */
|
|
|
|
int mnt_activevnodelistsize;/* (v) # of active vnodes */
|
2006-02-06 10:19:50 +00:00
|
|
|
int mnt_writeopcount; /* (i) write syscalls pending */
|
|
|
|
int mnt_kern_flag; /* (i) kernel only flags */
|
2011-07-24 17:43:09 +00:00
|
|
|
uint64_t mnt_flag; /* (i) flags shared with user */
|
2002-05-23 23:18:25 +00:00
|
|
|
struct vfsoptlist *mnt_opt; /* current mount options */
|
|
|
|
struct vfsoptlist *mnt_optnew; /* new options passed to fs */
|
1994-05-24 10:09:53 +00:00
|
|
|
int mnt_maxsymlinklen; /* max size of short symlink */
|
|
|
|
struct statfs mnt_stat; /* cache of filesystem stats */
|
2002-08-19 06:52:21 +00:00
|
|
|
struct ucred *mnt_cred; /* credentials of mounter */
|
2004-07-08 05:47:51 +00:00
|
|
|
void * mnt_data; /* private data */
|
1995-08-28 09:19:25 +00:00
|
|
|
time_t mnt_time; /* last time written*/
|
2002-11-07 21:45:28 +00:00
|
|
|
int mnt_iosize_max; /* max size for clusters, etc */
|
2001-04-25 07:07:52 +00:00
|
|
|
struct netexport *mnt_export; /* export list */
|
2007-04-22 16:18:10 +00:00
|
|
|
struct label *mnt_label; /* MAC label for the fs */
|
2005-03-16 07:35:06 +00:00
|
|
|
u_int mnt_hashseed; /* Random seed for vfs_hash */
|
2008-11-02 10:15:42 +00:00
|
|
|
int mnt_lockref; /* (i) Lock reference count */
|
2006-03-08 23:43:39 +00:00
|
|
|
int mnt_secondary_writes; /* (i) # of secondary writes */
|
|
|
|
int mnt_secondary_accwrites;/* (i) secondary wr. starts */
|
2008-09-16 11:51:06 +00:00
|
|
|
struct thread *mnt_susp_owner; /* (i) thread owning suspension */
|
2006-10-31 21:38:51 +00:00
|
|
|
#define mnt_endzero mnt_gjprovider
|
|
|
|
char *mnt_gjprovider; /* gjournal provider name */
|
2008-06-09 10:31:38 +00:00
|
|
|
struct lock mnt_explock; /* vfs_export walkers lock */
|
2012-09-09 19:17:15 +00:00
|
|
|
TAILQ_ENTRY(mount) mnt_upper_link; /* (m) we in the all uppers */
|
|
|
|
TAILQ_HEAD(, mount) mnt_uppers; /* (m) upper mounts over us*/
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
2003-11-05 04:30:08 +00:00
|
|
|
|
2012-04-17 16:28:22 +00:00
|
|
|
/*
|
|
|
|
* Definitions for MNT_VNODE_FOREACH_ALL.
|
|
|
|
*/
|
|
|
|
struct vnode *__mnt_vnode_next_all(struct vnode **mvp, struct mount *mp);
|
|
|
|
struct vnode *__mnt_vnode_first_all(struct vnode **mvp, struct mount *mp);
|
|
|
|
void __mnt_vnode_markerfree_all(struct vnode **mvp, struct mount *mp);
|
|
|
|
|
2012-12-15 02:03:06 +00:00
|
|
|
#define MNT_VNODE_FOREACH_ALL(vp, mp, mvp) \
|
|
|
|
for (vp = __mnt_vnode_first_all(&(mvp), (mp)); \
|
2012-04-17 16:28:22 +00:00
|
|
|
(vp) != NULL; vp = __mnt_vnode_next_all(&(mvp), (mp)))
|
|
|
|
|
|
|
|
#define MNT_VNODE_FOREACH_ALL_ABORT(mp, mvp) \
|
|
|
|
do { \
|
|
|
|
MNT_ILOCK(mp); \
|
|
|
|
__mnt_vnode_markerfree_all(&(mvp), (mp)); \
|
|
|
|
/* MNT_IUNLOCK(mp); -- done in above function */ \
|
|
|
|
mtx_assert(MNT_MTX(mp), MA_NOTOWNED); \
|
|
|
|
} while (0)
|
|
|
|
|
2012-04-20 06:50:44 +00:00
|
|
|
/*
|
|
|
|
* Definitions for MNT_VNODE_FOREACH_ACTIVE.
|
|
|
|
*/
|
|
|
|
struct vnode *__mnt_vnode_next_active(struct vnode **mvp, struct mount *mp);
|
|
|
|
struct vnode *__mnt_vnode_first_active(struct vnode **mvp, struct mount *mp);
|
|
|
|
void __mnt_vnode_markerfree_active(struct vnode **mvp, struct mount *);
|
|
|
|
|
2012-12-15 02:04:46 +00:00
|
|
|
#define MNT_VNODE_FOREACH_ACTIVE(vp, mp, mvp) \
|
|
|
|
for (vp = __mnt_vnode_first_active(&(mvp), (mp)); \
|
2012-04-20 06:50:44 +00:00
|
|
|
(vp) != NULL; vp = __mnt_vnode_next_active(&(mvp), (mp)))
|
|
|
|
|
|
|
|
#define MNT_VNODE_FOREACH_ACTIVE_ABORT(mp, mvp) \
|
2012-12-15 02:04:46 +00:00
|
|
|
__mnt_vnode_markerfree_active(&(mvp), (mp))
|
2012-04-20 06:50:44 +00:00
|
|
|
|
2003-11-05 04:30:08 +00:00
|
|
|
#define MNT_ILOCK(mp) mtx_lock(&(mp)->mnt_mtx)
|
2006-03-08 23:43:39 +00:00
|
|
|
#define MNT_ITRYLOCK(mp) mtx_trylock(&(mp)->mnt_mtx)
|
2003-11-05 04:30:08 +00:00
|
|
|
#define MNT_IUNLOCK(mp) mtx_unlock(&(mp)->mnt_mtx)
|
2005-01-24 09:53:46 +00:00
|
|
|
#define MNT_MTX(mp) (&(mp)->mnt_mtx)
|
2006-02-06 10:19:50 +00:00
|
|
|
#define MNT_REF(mp) (mp)->mnt_ref++
|
|
|
|
#define MNT_REL(mp) do { \
|
2012-04-11 22:43:40 +00:00
|
|
|
KASSERT((mp)->mnt_ref > 0, ("negative mnt_ref")); \
|
2006-02-06 10:19:50 +00:00
|
|
|
(mp)->mnt_ref--; \
|
|
|
|
if ((mp)->mnt_ref == 0) \
|
|
|
|
wakeup((mp)); \
|
|
|
|
} while (0)
|
2003-11-05 04:30:08 +00:00
|
|
|
|
2000-12-04 09:21:05 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
2009-05-29 15:00:04 +00:00
|
|
|
* User specifiable flags, stored in mnt_flag.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2011-07-24 17:43:09 +00:00
|
|
|
#define MNT_RDONLY 0x0000000000000001ULL /* read only filesystem */
|
|
|
|
#define MNT_SYNCHRONOUS 0x0000000000000002ULL /* fs written synchronously */
|
|
|
|
#define MNT_NOEXEC 0x0000000000000004ULL /* can't exec from filesystem */
|
|
|
|
#define MNT_NOSUID 0x0000000000000008ULL /* don't honor setuid fs bits */
|
|
|
|
#define MNT_NFS4ACLS 0x0000000000000010ULL /* enable NFS version 4 ACLs */
|
|
|
|
#define MNT_UNION 0x0000000000000020ULL /* union with underlying fs */
|
|
|
|
#define MNT_ASYNC 0x0000000000000040ULL /* fs written asynchronously */
|
|
|
|
#define MNT_SUIDDIR 0x0000000000100000ULL /* special SUID dir handling */
|
|
|
|
#define MNT_SOFTDEP 0x0000000000200000ULL /* using soft updates */
|
|
|
|
#define MNT_NOSYMFOLLOW 0x0000000000400000ULL /* do not follow symlinks */
|
|
|
|
#define MNT_GJOURNAL 0x0000000002000000ULL /* GEOM journal support enabled */
|
|
|
|
#define MNT_MULTILABEL 0x0000000004000000ULL /* MAC support for objects */
|
|
|
|
#define MNT_ACLS 0x0000000008000000ULL /* ACL support enabled */
|
|
|
|
#define MNT_NOATIME 0x0000000010000000ULL /* dont update file access time */
|
|
|
|
#define MNT_NOCLUSTERR 0x0000000040000000ULL /* disable cluster read */
|
|
|
|
#define MNT_NOCLUSTERW 0x0000000080000000ULL /* disable cluster write */
|
2011-07-24 18:27:09 +00:00
|
|
|
#define MNT_SUJ 0x0000000100000000ULL /* using journaled soft updates */
|
2014-08-17 09:44:42 +00:00
|
|
|
#define MNT_AUTOMOUNTED 0x0000000200000000ULL /* mounted by automountd(8) */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
1997-11-13 00:28:51 +00:00
|
|
|
* NFS export related mount flags.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2011-07-24 17:43:09 +00:00
|
|
|
#define MNT_EXRDONLY 0x0000000000000080ULL /* exported read only */
|
|
|
|
#define MNT_EXPORTED 0x0000000000000100ULL /* filesystem is exported */
|
|
|
|
#define MNT_DEFEXPORTED 0x0000000000000200ULL /* exported to the world */
|
|
|
|
#define MNT_EXPORTANON 0x0000000000000400ULL /* anon uid mapping for all */
|
|
|
|
#define MNT_EXKERB 0x0000000000000800ULL /* exported with Kerberos */
|
|
|
|
#define MNT_EXPUBLIC 0x0000000020000000ULL /* public export (WebNFS) */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
1997-11-13 00:28:51 +00:00
|
|
|
* Flags set by internal operations,
|
|
|
|
* but visible to the user.
|
|
|
|
* XXX some of these are not quite right.. (I've never seen the root flag set)
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2011-07-24 17:43:09 +00:00
|
|
|
#define MNT_LOCAL 0x0000000000001000ULL /* filesystem is stored locally */
|
|
|
|
#define MNT_QUOTA 0x0000000000002000ULL /* quotas are enabled on fs */
|
|
|
|
#define MNT_ROOTFS 0x0000000000004000ULL /* identifies the root fs */
|
|
|
|
#define MNT_USER 0x0000000000008000ULL /* mounted by a user */
|
|
|
|
#define MNT_IGNORE 0x0000000000800000ULL /* do not show entry in df */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
/*
|
2002-11-07 21:45:28 +00:00
|
|
|
* Mask of flags that are visible to statfs().
|
1997-11-13 00:28:51 +00:00
|
|
|
* XXX I think that this could now become (~(MNT_CMDFLAGS))
|
|
|
|
* but the 'mount' program may need changing to handle this.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
1997-11-13 00:28:51 +00:00
|
|
|
#define MNT_VISFLAGMASK (MNT_RDONLY | MNT_SYNCHRONOUS | MNT_NOEXEC | \
|
2011-07-24 18:27:09 +00:00
|
|
|
MNT_NOSUID | MNT_UNION | MNT_SUJ | \
|
1997-11-13 00:28:51 +00:00
|
|
|
MNT_ASYNC | MNT_EXRDONLY | MNT_EXPORTED | \
|
|
|
|
MNT_DEFEXPORTED | MNT_EXPORTANON| MNT_EXKERB | \
|
|
|
|
MNT_LOCAL | MNT_USER | MNT_QUOTA | \
|
|
|
|
MNT_ROOTFS | MNT_NOATIME | MNT_NOCLUSTERR| \
|
1999-11-01 04:57:43 +00:00
|
|
|
MNT_NOCLUSTERW | MNT_SUIDDIR | MNT_SOFTDEP | \
|
2001-11-05 10:33:45 +00:00
|
|
|
MNT_IGNORE | MNT_EXPUBLIC | MNT_NOSYMFOLLOW | \
|
2010-04-24 07:05:35 +00:00
|
|
|
MNT_GJOURNAL | MNT_MULTILABEL | MNT_ACLS | \
|
2014-08-17 09:44:42 +00:00
|
|
|
MNT_NFS4ACLS | MNT_AUTOMOUNTED)
|
2001-11-05 10:33:45 +00:00
|
|
|
|
2002-11-07 21:45:28 +00:00
|
|
|
/* Mask of flags that can be updated. */
|
2004-11-26 19:28:39 +00:00
|
|
|
#define MNT_UPDATEMASK (MNT_NOSUID | MNT_NOEXEC | \
|
2001-11-05 10:33:45 +00:00
|
|
|
MNT_SYNCHRONOUS | MNT_UNION | MNT_ASYNC | \
|
|
|
|
MNT_NOATIME | \
|
2005-10-23 16:52:13 +00:00
|
|
|
MNT_NOSYMFOLLOW | MNT_IGNORE | \
|
2002-12-27 18:20:16 +00:00
|
|
|
MNT_NOCLUSTERR | MNT_NOCLUSTERW | MNT_SUIDDIR | \
|
2014-08-17 09:44:42 +00:00
|
|
|
MNT_ACLS | MNT_USER | MNT_NFS4ACLS | \
|
|
|
|
MNT_AUTOMOUNTED)
|
2003-03-10 21:55:00 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-11-13 00:28:51 +00:00
|
|
|
* External filesystem command modifier flags.
|
|
|
|
* Unmount can use the MNT_FORCE flag.
|
2005-12-19 03:02:54 +00:00
|
|
|
* XXX: These are not STATES and really should be somewhere else.
|
|
|
|
* XXX: MNT_BYFSID collides with MNT_ACLS, but because MNT_ACLS is only used for
|
|
|
|
* mount(2) and MNT_BYFSID is only used for unmount(2) it's harmless.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2011-07-24 17:43:09 +00:00
|
|
|
#define MNT_UPDATE 0x0000000000010000ULL /* not real mount, just update */
|
|
|
|
#define MNT_DELEXPORT 0x0000000000020000ULL /* delete export host lists */
|
|
|
|
#define MNT_RELOAD 0x0000000000040000ULL /* reload filesystem data */
|
|
|
|
#define MNT_FORCE 0x0000000000080000ULL /* force unmount or readonly */
|
|
|
|
#define MNT_SNAPSHOT 0x0000000001000000ULL /* snapshot the filesystem */
|
|
|
|
#define MNT_BYFSID 0x0000000008000000ULL /* specify filesystem by ID. */
|
2000-07-04 04:58:34 +00:00
|
|
|
#define MNT_CMDFLAGS (MNT_UPDATE | MNT_DELEXPORT | MNT_RELOAD | \
|
2003-07-01 17:40:23 +00:00
|
|
|
MNT_FORCE | MNT_SNAPSHOT | MNT_BYFSID)
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
1997-11-13 00:28:51 +00:00
|
|
|
* Internal filesystem control flags stored in mnt_kern_flag.
|
1997-02-10 02:22:35 +00:00
|
|
|
*
|
1997-11-13 00:28:51 +00:00
|
|
|
* MNTK_UNMOUNT locks the mount entry so that name lookup cannot proceed
|
1997-02-10 02:22:35 +00:00
|
|
|
* past the mount point. This keeps the subtree stable during mounts
|
|
|
|
* and unmounts.
|
2002-04-17 01:07:29 +00:00
|
|
|
*
|
|
|
|
* MNTK_UNMOUNTF permits filesystems to detect a forced unmount while
|
|
|
|
* dounmount() is still waiting to lock the mountpoint. This allows
|
|
|
|
* the filesystem to cancel operations that might otherwise deadlock
|
|
|
|
* with the unmount attempt (used by NFS).
|
2007-09-12 16:31:32 +00:00
|
|
|
*
|
|
|
|
* MNTK_NOINSMNTQ is strict subset of MNTK_UNMOUNT. They are separated
|
|
|
|
* to allow for failed unmount attempt to restore the syncer vnode for
|
|
|
|
* the mount.
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
2002-04-17 01:07:29 +00:00
|
|
|
#define MNTK_UNMOUNTF 0x00000001 /* forced unmount in progress */
|
2006-09-26 04:15:59 +00:00
|
|
|
#define MNTK_ASYNC 0x00000002 /* filtered async flag */
|
2006-09-26 04:17:17 +00:00
|
|
|
#define MNTK_SOFTDEP 0x00000004 /* async disabled by softdep */
|
2007-09-12 16:31:32 +00:00
|
|
|
#define MNTK_NOINSMNTQ 0x00000008 /* insmntque is not allowed */
|
2008-11-02 10:15:42 +00:00
|
|
|
#define MNTK_DRAINING 0x00000010 /* lock draining is happening */
|
1) Fix a deadlock in the VFS:
- threadA runs vfs_rel(mp1)
- threadB does unmount the mp1 fs, sets MNTK_UNMOUNT and drop MNT_ILOCK()
- threadA runs vfs_busy(mp1) and, as long as, MNTK_UNMOUNT is set, sleeps
waiting for threadB to complete the unmount
- threadB, in vfs_mount_destroy(), finds mnt_lock > 0 and sleeps waiting
for the refcount to expire.
Fix the deadlock by adding a flag called MNTK_REFEXPIRE which signals the
unmounter is waiting for mnt_ref to expire.
The vfs_busy contenders got awake, fails, and if they retry the
MNTK_REFEXPIRE won't allow them to sleep again.
2) Simplify significantly the code of vfs_mount_destroy() trimming
unnecessary codes:
- as long as any reference exited, it is no-more possible to have
write-op (primarty and secondary) in progress.
- it is no needed to drop and reacquire the mount lock.
- filling the structures with dummy values is unuseful as long as
it is going to be freed.
Tested by: pho, Andrea Barberio <insomniac at slackware dot it>
Discussed with: kib
2008-12-16 23:16:10 +00:00
|
|
|
#define MNTK_REFEXPIRE 0x00000020 /* refcount expiring is happening */
|
2009-03-11 14:13:47 +00:00
|
|
|
#define MNTK_EXTENDED_SHARED 0x00000040 /* Allow shared locking for more ops */
|
2009-06-04 16:18:07 +00:00
|
|
|
#define MNTK_SHARED_WRITES 0x00000080 /* Allow shared locking for writes */
|
vn_io_fault() is a facility to prevent page faults while filesystems
perform copyin/copyout of the file data into the usermode
buffer. Typical filesystem hold vnode lock and some buffer locks over
the VOP_READ() and VOP_WRITE() operations, and since page fault
handler may need to recurse into VFS to get the page content, a
deadlock is possible.
The facility works by disabling page faults handling for the current
thread and attempting to execute i/o while allowing uiomove() to
access the usermode mapping of the i/o buffer. If all buffer pages are
resident, uiomove() is successfull and request is finished. If EFAULT
is returned from uiomove(), the pages backing i/o buffer are faulted
in and held, and the copyin/out is performed using uiomove_fromphys()
over the held pages for the second attempt of VOP call.
Since pages are hold in chunks to prevent large i/o requests from
starving free pages pool, and since vnode lock is only taken for
i/o over the current chunk, the vnode lock no longer protect atomicity
of the whole i/o request. Use newly added rangelocks to provide the
required atomicity of i/o regardind other i/o and truncations.
Filesystems need to explicitely opt-in into the scheme, by setting the
MNTK_NO_IOPF struct mount flag, and optionally by using
vn_io_fault_uiomove(9) helper which takes care of calling uiomove() or
converting uio into request for uiomove_fromphys().
Reviewed by: bf (comments), mdf, pjd (previous version)
Tested by: pho
Tested by: flo, Gustau P?rez <gperez entel upc edu> (previous version)
MFC after: 2 months
2012-05-30 16:42:08 +00:00
|
|
|
#define MNTK_NO_IOPF 0x00000100 /* Disallow page faults during reads
|
|
|
|
and writes. Filesystem shall properly
|
|
|
|
handle i/o state on EFAULT. */
|
2012-09-09 19:17:15 +00:00
|
|
|
#define MNTK_VGONE_UPPER 0x00000200
|
2012-10-05 14:42:38 +00:00
|
|
|
#define MNTK_VGONE_WAITER 0x00000400
|
2012-09-09 19:11:52 +00:00
|
|
|
#define MNTK_LOOKUP_EXCL_DOTDOT 0x00000800
|
2012-10-05 14:42:38 +00:00
|
|
|
#define MNTK_MARKER 0x00001000
|
2013-03-19 14:33:01 +00:00
|
|
|
#define MNTK_UNMAPPED_BUFS 0x00002000
|
2015-04-15 20:16:31 +00:00
|
|
|
#define MNTK_USES_BCACHE 0x00004000 /* FS uses the buffer cache. */
|
2012-03-09 00:12:05 +00:00
|
|
|
#define MNTK_NOASYNC 0x00800000 /* disable async */
|
1997-11-12 05:42:33 +00:00
|
|
|
#define MNTK_UNMOUNT 0x01000000 /* unmount in progress */
|
|
|
|
#define MNTK_MWAIT 0x02000000 /* waiting for unmount to finish */
|
2000-07-04 04:58:34 +00:00
|
|
|
#define MNTK_SUSPEND 0x08000000 /* request write suspension */
|
2006-03-11 01:08:37 +00:00
|
|
|
#define MNTK_SUSPEND2 0x04000000 /* block secondary writes */
|
2000-07-04 04:58:34 +00:00
|
|
|
#define MNTK_SUSPENDED 0x10000000 /* write operations are suspended */
|
2015-07-05 22:37:33 +00:00
|
|
|
#define MNTK_UNUSED1 0x20000000
|
2006-09-13 18:39:09 +00:00
|
|
|
#define MNTK_LOOKUP_SHARED 0x40000000 /* FS supports shared lock lookups */
|
2009-03-11 14:13:47 +00:00
|
|
|
#define MNTK_NOKNOTE 0x80000000 /* Don't send KNOTEs from VOP hooks */
|
1997-02-10 02:22:35 +00:00
|
|
|
|
2013-11-09 22:28:04 +00:00
|
|
|
#ifdef _KERNEL
|
2013-11-09 20:30:13 +00:00
|
|
|
static inline int
|
|
|
|
MNT_SHARED_WRITES(struct mount *mp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (mp != NULL && (mp->mnt_kern_flag & MNTK_SHARED_WRITES) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
MNT_EXTENDED_SHARED(struct mount *mp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return (mp != NULL && (mp->mnt_kern_flag & MNTK_EXTENDED_SHARED) != 0);
|
|
|
|
}
|
2013-11-09 22:28:04 +00:00
|
|
|
#endif
|
2009-06-08 21:23:54 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
|
|
|
* Sysctl CTL_VFS definitions.
|
|
|
|
*
|
|
|
|
* Second level identifier specifies which filesystem. Second level
|
1997-03-02 17:53:37 +00:00
|
|
|
* identifier VFS_VFSCONF returns information about all filesystems.
|
|
|
|
* Second level identifier VFS_GENERIC is non-terminal.
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
1997-03-02 17:53:37 +00:00
|
|
|
#define VFS_VFSCONF 0 /* get configured filesystems */
|
1997-02-10 02:22:35 +00:00
|
|
|
#define VFS_GENERIC 0 /* generic filesystem information */
|
|
|
|
/*
|
|
|
|
* Third level identifiers for VFS_GENERIC are given below; third
|
|
|
|
* level identifiers for specific filesystems are given in their
|
|
|
|
* mount specific header files.
|
|
|
|
*/
|
|
|
|
#define VFS_MAXTYPENUM 1 /* int: highest defined filesystem type */
|
|
|
|
#define VFS_CONF 2 /* struct: vfsconf for filesystem given
|
|
|
|
as next argument */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flags for various system call interfaces.
|
|
|
|
*
|
|
|
|
* waitfor flags to vfs_sync() and getfsstat()
|
|
|
|
*/
|
1998-03-08 09:59:44 +00:00
|
|
|
#define MNT_WAIT 1 /* synchronously wait for I/O to complete */
|
|
|
|
#define MNT_NOWAIT 2 /* start all I/O, but do not wait for it */
|
1998-02-05 17:27:42 +00:00
|
|
|
#define MNT_LAZY 3 /* push data not written by filesystem syncer */
|
2006-03-08 23:43:39 +00:00
|
|
|
#define MNT_SUSPEND 4 /* Suspend file system after sync */
|
1997-02-10 02:22:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Generic file handle
|
|
|
|
*/
|
|
|
|
struct fhandle {
|
2002-11-07 21:45:28 +00:00
|
|
|
fsid_t fh_fsid; /* Filesystem id of mount point */
|
|
|
|
struct fid fh_fid; /* Filesys specific id */
|
1997-02-10 02:22:35 +00:00
|
|
|
};
|
|
|
|
typedef struct fhandle fhandle_t;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
/*
|
|
|
|
* Old export arguments without security flavor list
|
|
|
|
*/
|
|
|
|
struct oexport_args {
|
|
|
|
int ex_flags; /* export related flags */
|
|
|
|
uid_t ex_root; /* mapping for root uid */
|
|
|
|
struct xucred ex_anon; /* mapping for anonymous user */
|
|
|
|
struct sockaddr *ex_addr; /* net address to which exported */
|
|
|
|
u_char ex_addrlen; /* and the net address length */
|
|
|
|
struct sockaddr *ex_mask; /* mask of valid bits in saddr */
|
|
|
|
u_char ex_masklen; /* and the smask length */
|
|
|
|
char *ex_indexfile; /* index file for WebNFS URLs */
|
|
|
|
};
|
|
|
|
|
1994-09-21 03:47:43 +00:00
|
|
|
/*
|
1997-02-10 02:22:35 +00:00
|
|
|
* Export arguments for local filesystem mount calls.
|
|
|
|
*/
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
#define MAXSECFLAVORS 5
|
1997-02-10 02:22:35 +00:00
|
|
|
struct export_args {
|
|
|
|
int ex_flags; /* export related flags */
|
|
|
|
uid_t ex_root; /* mapping for root uid */
|
2001-02-18 13:30:20 +00:00
|
|
|
struct xucred ex_anon; /* mapping for anonymous user */
|
1997-02-10 02:22:35 +00:00
|
|
|
struct sockaddr *ex_addr; /* net address to which exported */
|
2001-02-18 13:30:20 +00:00
|
|
|
u_char ex_addrlen; /* and the net address length */
|
1997-02-10 02:22:35 +00:00
|
|
|
struct sockaddr *ex_mask; /* mask of valid bits in saddr */
|
2001-02-18 13:30:20 +00:00
|
|
|
u_char ex_masklen; /* and the smask length */
|
1997-07-16 18:04:52 +00:00
|
|
|
char *ex_indexfile; /* index file for WebNFS URLs */
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
int ex_numsecflavors; /* security flavor count */
|
|
|
|
int ex_secflavors[MAXSECFLAVORS]; /* list of security flavors */
|
1997-07-16 18:04:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Structure holding information for a publicly exported filesystem
|
|
|
|
* (WebNFS). Currently the specs allow just for one such filesystem.
|
|
|
|
*/
|
|
|
|
struct nfs_public {
|
|
|
|
int np_valid; /* Do we hold valid information */
|
|
|
|
fhandle_t np_handle; /* Filehandle for pub fs (internal) */
|
|
|
|
struct mount *np_mount; /* Mountpoint of exported fs */
|
|
|
|
char *np_index; /* Index file */
|
1997-02-10 02:22:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Filesystem configuration information. One of these exists for each
|
|
|
|
* type of filesystem supported by the kernel. These are searched at
|
|
|
|
* mount time to identify the requested filesystem.
|
2004-07-30 22:08:52 +00:00
|
|
|
*
|
|
|
|
* XXX: Never change the first two arguments!
|
1994-09-21 03:47:43 +00:00
|
|
|
*/
|
|
|
|
struct vfsconf {
|
2004-07-30 22:08:52 +00:00
|
|
|
u_int vfc_version; /* ABI version number */
|
- Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *.
- Convert several consumers of getvfsbyname() to use struct xvfsconf.
- Correct the getvfsbyname.3 manpage.
- Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the
kernel, and rewrite getvfsbyname() to use this instead of the weird
existing API.
- Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist
sysctl.
- Convert a vfsload() call in nfsiod.c to kldload() and remove the useless
vfsisloadable() and endvfsent() calls.
- Add a warning printf() in vfs_sysctl() to tell people they are using
an old userland.
After these changes, it's possible to modify struct vfsconf without
breaking the binary compatibility. Please note that these changes don't
break this compatibility either.
When bp will have updated mount_smbfs(8) with the patch I sent him, there
will be no more consumers of the {set,get,end}vfsent(), vfsisloadable()
and vfsload() API, and I will promptly delete it.
2002-08-10 20:19:04 +00:00
|
|
|
char vfc_name[MFSNAMELEN]; /* filesystem type name */
|
2004-07-30 22:08:52 +00:00
|
|
|
struct vfsops *vfc_vfsops; /* filesystem operations vector */
|
- Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *.
- Convert several consumers of getvfsbyname() to use struct xvfsconf.
- Correct the getvfsbyname.3 manpage.
- Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the
kernel, and rewrite getvfsbyname() to use this instead of the weird
existing API.
- Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist
sysctl.
- Convert a vfsload() call in nfsiod.c to kldload() and remove the useless
vfsisloadable() and endvfsent() calls.
- Add a warning printf() in vfs_sysctl() to tell people they are using
an old userland.
After these changes, it's possible to modify struct vfsconf without
breaking the binary compatibility. Please note that these changes don't
break this compatibility either.
When bp will have updated mount_smbfs(8) with the patch I sent him, there
will be no more consumers of the {set,get,end}vfsent(), vfsisloadable()
and vfsload() API, and I will promptly delete it.
2002-08-10 20:19:04 +00:00
|
|
|
int vfc_typenum; /* historic filesystem type number */
|
|
|
|
int vfc_refcount; /* number mounted of this type */
|
|
|
|
int vfc_flags; /* permanent flags */
|
|
|
|
struct vfsoptdecl *vfc_opts; /* mount options */
|
2004-07-27 22:32:01 +00:00
|
|
|
TAILQ_ENTRY(vfsconf) vfc_list; /* list of vfscons */
|
- Introduce a new struct xvfsconf, the userland version of struct vfsconf.
- Make getvfsbyname() take a struct xvfsconf *.
- Convert several consumers of getvfsbyname() to use struct xvfsconf.
- Correct the getvfsbyname.3 manpage.
- Create a new vfs.conflist sysctl to dump all the struct xvfsconf in the
kernel, and rewrite getvfsbyname() to use this instead of the weird
existing API.
- Convert some {set,get,end}vfsent() consumers to use the new vfs.conflist
sysctl.
- Convert a vfsload() call in nfsiod.c to kldload() and remove the useless
vfsisloadable() and endvfsent() calls.
- Add a warning printf() in vfs_sysctl() to tell people they are using
an old userland.
After these changes, it's possible to modify struct vfsconf without
breaking the binary compatibility. Please note that these changes don't
break this compatibility either.
When bp will have updated mount_smbfs(8) with the patch I sent him, there
will be no more consumers of the {set,get,end}vfsent(), vfsisloadable()
and vfsload() API, and I will promptly delete it.
2002-08-10 20:19:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Userland version of the struct vfsconf. */
|
|
|
|
struct xvfsconf {
|
|
|
|
struct vfsops *vfc_vfsops; /* filesystem operations vector */
|
|
|
|
char vfc_name[MFSNAMELEN]; /* filesystem type name */
|
|
|
|
int vfc_typenum; /* historic filesystem type number */
|
|
|
|
int vfc_refcount; /* number mounted of this type */
|
|
|
|
int vfc_flags; /* permanent flags */
|
|
|
|
struct vfsconf *vfc_next; /* next in list */
|
|
|
|
};
|
|
|
|
|
2004-04-11 21:26:07 +00:00
|
|
|
#ifndef BURN_BRIDGES
|
1997-03-02 17:53:37 +00:00
|
|
|
struct ovfsconf {
|
|
|
|
void *vfc_vfsops;
|
|
|
|
char vfc_name[32];
|
|
|
|
int vfc_index;
|
|
|
|
int vfc_refcount;
|
|
|
|
int vfc_flags;
|
|
|
|
};
|
2004-04-11 21:26:07 +00:00
|
|
|
#endif
|
1997-03-02 17:53:37 +00:00
|
|
|
|
1995-03-16 20:23:48 +00:00
|
|
|
/*
|
|
|
|
* NB: these flags refer to IMPLEMENTATION properties, not properties of
|
|
|
|
* any actual mounts; i.e., it does not make sense to change the flags.
|
|
|
|
*/
|
1997-02-10 02:22:35 +00:00
|
|
|
#define VFCF_STATIC 0x00010000 /* statically compiled into kernel */
|
|
|
|
#define VFCF_NETWORK 0x00020000 /* may get data over the network */
|
|
|
|
#define VFCF_READONLY 0x00040000 /* writes are not implemented */
|
2007-04-01 13:41:10 +00:00
|
|
|
#define VFCF_SYNTHETIC 0x00080000 /* data does not represent real files */
|
1997-02-10 02:22:35 +00:00
|
|
|
#define VFCF_LOOPBACK 0x00100000 /* aliases some other mounted FS */
|
2007-04-01 15:40:56 +00:00
|
|
|
#define VFCF_UNICODE 0x00200000 /* stores file names as Unicode */
|
2007-04-05 21:03:05 +00:00
|
|
|
#define VFCF_JAIL 0x00400000 /* can be mounted from within a jail */
|
Update ZFS from version 6 to 13 and bring some FreeBSD-specific changes.
This bring huge amount of changes, I'll enumerate only user-visible changes:
- Delegated Administration
Allows regular users to perform ZFS operations, like file system
creation, snapshot creation, etc.
- L2ARC
Level 2 cache for ZFS - allows to use additional disks for cache.
Huge performance improvements mostly for random read of mostly
static content.
- slog
Allow to use additional disks for ZFS Intent Log to speed up
operations like fsync(2).
- vfs.zfs.super_owner
Allows regular users to perform privileged operations on files stored
on ZFS file systems owned by him. Very careful with this one.
- chflags(2)
Not all the flags are supported. This still needs work.
- ZFSBoot
Support to boot off of ZFS pool. Not finished, AFAIK.
Submitted by: dfr
- Snapshot properties
- New failure modes
Before if write requested failed, system paniced. Now one
can select from one of three failure modes:
- panic - panic on write error
- wait - wait for disk to reappear
- continue - serve read requests if possible, block write requests
- Refquota, refreservation properties
Just quota and reservation properties, but don't count space consumed
by children file systems, clones and snapshots.
- Sparse volumes
ZVOLs that don't reserve space in the pool.
- External attributes
Compatible with extattr(2).
- NFSv4-ACLs
Not sure about the status, might not be complete yet.
Submitted by: trasz
- Creation-time properties
- Regression tests for zpool(8) command.
Obtained from: OpenSolaris
2008-11-17 20:49:29 +00:00
|
|
|
#define VFCF_DELEGADMIN 0x00800000 /* supports delegated administration */
|
2013-02-21 19:02:50 +00:00
|
|
|
#define VFCF_SBDRY 0x01000000 /* defer stop requests */
|
1995-03-16 18:31:00 +00:00
|
|
|
|
2004-07-04 20:21:58 +00:00
|
|
|
typedef uint32_t fsctlop_t;
|
|
|
|
|
2004-07-04 10:52:54 +00:00
|
|
|
struct vfsidctl {
|
|
|
|
int vc_vers; /* should be VFSIDCTL_VERS1 (below) */
|
2007-04-01 15:40:56 +00:00
|
|
|
fsid_t vc_fsid; /* fsid to operate on */
|
2004-07-04 20:21:58 +00:00
|
|
|
char vc_fstypename[MFSNAMELEN];
|
|
|
|
/* type of fs 'nfs' or '*' */
|
|
|
|
fsctlop_t vc_op; /* operation VFS_CTL_* (below) */
|
2007-04-01 15:40:56 +00:00
|
|
|
void *vc_ptr; /* pointer to data structure */
|
|
|
|
size_t vc_len; /* sizeof said structure */
|
|
|
|
u_int32_t vc_spare[12]; /* spare (must be zero) */
|
2004-07-04 10:52:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* vfsidctl API version. */
|
|
|
|
#define VFS_CTL_VERS1 0x01
|
|
|
|
|
|
|
|
/*
|
|
|
|
* New style VFS sysctls, do not reuse/conflict with the namespace for
|
|
|
|
* private sysctls.
|
2004-07-04 20:21:58 +00:00
|
|
|
* All "global" sysctl ops have the 33rd bit set:
|
|
|
|
* 0x...1....
|
2004-08-04 18:57:41 +00:00
|
|
|
* Private sysctl ops should have the 33rd bit unset.
|
2004-07-04 10:52:54 +00:00
|
|
|
*/
|
2004-07-04 20:21:58 +00:00
|
|
|
#define VFS_CTL_QUERY 0x00010001 /* anything wrong? (vfsquery) */
|
|
|
|
#define VFS_CTL_TIMEO 0x00010002 /* set timeout for vfs notification */
|
|
|
|
#define VFS_CTL_NOLOCKS 0x00010003 /* disable file locking */
|
2004-07-04 10:52:54 +00:00
|
|
|
|
|
|
|
struct vfsquery {
|
|
|
|
u_int32_t vq_flags;
|
|
|
|
u_int32_t vq_spare[31];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* vfsquery flags */
|
|
|
|
#define VQ_NOTRESP 0x0001 /* server down */
|
|
|
|
#define VQ_NEEDAUTH 0x0002 /* server bad auth */
|
|
|
|
#define VQ_LOWDISK 0x0004 /* we're low on space */
|
|
|
|
#define VQ_MOUNT 0x0008 /* new filesystem arrived */
|
|
|
|
#define VQ_UNMOUNT 0x0010 /* filesystem has left */
|
|
|
|
#define VQ_DEAD 0x0020 /* filesystem is dead, needs force unmount */
|
|
|
|
#define VQ_ASSIST 0x0040 /* filesystem needs assistance from external
|
|
|
|
program */
|
|
|
|
#define VQ_NOTRESPLOCK 0x0080 /* server lockd down */
|
|
|
|
#define VQ_FLAG0100 0x0100 /* placeholder */
|
|
|
|
#define VQ_FLAG0200 0x0200 /* placeholder */
|
|
|
|
#define VQ_FLAG0400 0x0400 /* placeholder */
|
|
|
|
#define VQ_FLAG0800 0x0800 /* placeholder */
|
|
|
|
#define VQ_FLAG1000 0x1000 /* placeholder */
|
|
|
|
#define VQ_FLAG2000 0x2000 /* placeholder */
|
|
|
|
#define VQ_FLAG4000 0x4000 /* placeholder */
|
|
|
|
#define VQ_FLAG8000 0x8000 /* placeholder */
|
|
|
|
|
|
|
|
#ifdef _KERNEL
|
|
|
|
/* Point a sysctl request at a vfsidctl's data. */
|
|
|
|
#define VCTLTOREQ(vc, req) \
|
|
|
|
do { \
|
|
|
|
(req)->newptr = (vc)->vc_ptr; \
|
|
|
|
(req)->newlen = (vc)->vc_len; \
|
|
|
|
(req)->newidx = 0; \
|
|
|
|
} while (0)
|
|
|
|
#endif
|
|
|
|
|
2002-11-07 21:45:28 +00:00
|
|
|
struct iovec;
|
|
|
|
struct uio;
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1994-09-21 03:47:43 +00:00
|
|
|
|
2008-11-02 10:15:42 +00:00
|
|
|
/*
|
|
|
|
* vfs_busy specific flags and mask.
|
|
|
|
*/
|
|
|
|
#define MBF_NOWAIT 0x01
|
|
|
|
#define MBF_MNTLSTLOCK 0x02
|
|
|
|
#define MBF_MASK (MBF_NOWAIT | MBF_MNTLSTLOCK)
|
|
|
|
|
1997-10-12 20:26:33 +00:00
|
|
|
#ifdef MALLOC_DECLARE
|
|
|
|
MALLOC_DECLARE(M_MOUNT);
|
|
|
|
#endif
|
1997-02-10 02:22:35 +00:00
|
|
|
extern int maxvfsconf; /* highest defined filesystem type */
|
1998-09-05 15:17:34 +00:00
|
|
|
extern int nfs_mount_type; /* vfc_typenum for nfs, or -1 */
|
2004-07-27 22:32:01 +00:00
|
|
|
|
|
|
|
TAILQ_HEAD(vfsconfhead, vfsconf);
|
|
|
|
extern struct vfsconfhead vfsconf;
|
1994-09-21 03:47:43 +00:00
|
|
|
|
1997-02-10 02:22:35 +00:00
|
|
|
/*
|
2002-05-16 21:28:32 +00:00
|
|
|
* Operations supported on mounted filesystem.
|
1997-02-10 02:22:35 +00:00
|
|
|
*/
|
2001-02-16 14:31:49 +00:00
|
|
|
struct mount_args;
|
2002-11-07 21:45:28 +00:00
|
|
|
struct nameidata;
|
2004-07-04 10:52:54 +00:00
|
|
|
struct sysctl_req;
|
2004-12-06 13:01:41 +00:00
|
|
|
struct mntarg;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2012-01-17 01:08:01 +00:00
|
|
|
typedef int vfs_cmount_t(struct mntarg *ma, void *data, uint64_t flags);
|
2009-05-11 15:33:26 +00:00
|
|
|
typedef int vfs_unmount_t(struct mount *mp, int mntflags);
|
|
|
|
typedef int vfs_root_t(struct mount *mp, int flags, struct vnode **vpp);
|
|
|
|
typedef int vfs_quotactl_t(struct mount *mp, int cmds, uid_t uid, void *arg);
|
|
|
|
typedef int vfs_statfs_t(struct mount *mp, struct statfs *sbp);
|
|
|
|
typedef int vfs_sync_t(struct mount *mp, int waitfor);
|
2002-08-13 10:05:50 +00:00
|
|
|
typedef int vfs_vget_t(struct mount *mp, ino_t ino, int flags,
|
2002-03-23 08:46:52 +00:00
|
|
|
struct vnode **vpp);
|
2011-05-22 01:07:54 +00:00
|
|
|
typedef int vfs_fhtovp_t(struct mount *mp, struct fid *fhp,
|
|
|
|
int flags, struct vnode **vpp);
|
2002-08-13 10:05:50 +00:00
|
|
|
typedef int vfs_checkexp_t(struct mount *mp, struct sockaddr *nam,
|
Implement support for RPCSEC_GSS authentication to both the NFS client
and server. This replaces the RPC implementation of the NFS client and
server with the newer RPC implementation originally developed
(actually ported from the userland sunrpc code) to support the NFS
Lock Manager. I have tested this code extensively and I believe it is
stable and that performance is at least equal to the legacy RPC
implementation.
The NFS code currently contains support for both the new RPC
implementation and the older legacy implementation inherited from the
original NFS codebase. The default is to use the new implementation -
add the NFS_LEGACYRPC option to fall back to the old code. When I
merge this support back to RELENG_7, I will probably change this so
that users have to 'opt in' to get the new code.
To use RPCSEC_GSS on either client or server, you must build a kernel
which includes the KGSSAPI option and the crypto device. On the
userland side, you must build at least a new libc, mountd, mount_nfs
and gssd. You must install new versions of /etc/rc.d/gssd and
/etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf.
As long as gssd is running, you should be able to mount an NFS
filesystem from a server that requires RPCSEC_GSS authentication. The
mount itself can happen without any kerberos credentials but all
access to the filesystem will be denied unless the accessing user has
a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There
is currently no support for situations where the ticket file is in a
different place, such as when the user logged in via SSH and has
delegated credentials from that login. This restriction is also
present in Solaris and Linux. In theory, we could improve this in
future, possibly using Brooks Davis' implementation of variant
symlinks.
Supporting RPCSEC_GSS on a server is nearly as simple. You must create
service creds for the server in the form 'nfs/<fqdn>@<REALM>' and
install them in /etc/krb5.keytab. The standard heimdal utility ktutil
makes this fairly easy. After the service creds have been created, you
can add a '-sec=krb5' option to /etc/exports and restart both mountd
and nfsd.
The only other difference an administrator should notice is that nfsd
doesn't fork to create service threads any more. In normal operation,
there will be two nfsd processes, one in userland waiting for TCP
connections and one in the kernel handling requests. The latter
process will create as many kthreads as required - these should be
visible via 'top -H'. The code has some support for varying the number
of service threads according to load but initially at least, nfsd uses
a fixed number of threads according to the value supplied to its '-n'
option.
Sponsored by: Isilon Systems
MFC after: 1 month
2008-11-03 10:38:00 +00:00
|
|
|
int *extflagsp, struct ucred **credanonp,
|
|
|
|
int *numsecflavors, int **secflavors);
|
2002-08-13 10:05:50 +00:00
|
|
|
typedef int vfs_init_t(struct vfsconf *);
|
|
|
|
typedef int vfs_uninit_t(struct vfsconf *);
|
|
|
|
typedef int vfs_extattrctl_t(struct mount *mp, int cmd,
|
2002-03-23 08:46:52 +00:00
|
|
|
struct vnode *filename_vp, int attrnamespace,
|
2009-05-11 15:33:26 +00:00
|
|
|
const char *attrname);
|
|
|
|
typedef int vfs_mount_t(struct mount *mp);
|
2004-07-04 20:21:58 +00:00
|
|
|
typedef int vfs_sysctl_t(struct mount *mp, fsctlop_t op,
|
|
|
|
struct sysctl_req *req);
|
2008-09-16 11:51:06 +00:00
|
|
|
typedef void vfs_susp_clean_t(struct mount *mp);
|
2013-05-11 11:17:44 +00:00
|
|
|
typedef void vfs_notify_lowervp_t(struct mount *mp, struct vnode *lowervp);
|
2013-09-01 23:02:59 +00:00
|
|
|
typedef void vfs_purge_t(struct mount *mp);
|
2002-08-13 10:05:50 +00:00
|
|
|
|
|
|
|
struct vfsops {
|
|
|
|
vfs_mount_t *vfs_mount;
|
2004-12-03 19:33:19 +00:00
|
|
|
vfs_cmount_t *vfs_cmount;
|
2002-08-13 10:05:50 +00:00
|
|
|
vfs_unmount_t *vfs_unmount;
|
|
|
|
vfs_root_t *vfs_root;
|
|
|
|
vfs_quotactl_t *vfs_quotactl;
|
|
|
|
vfs_statfs_t *vfs_statfs;
|
|
|
|
vfs_sync_t *vfs_sync;
|
|
|
|
vfs_vget_t *vfs_vget;
|
|
|
|
vfs_fhtovp_t *vfs_fhtovp;
|
|
|
|
vfs_checkexp_t *vfs_checkexp;
|
|
|
|
vfs_init_t *vfs_init;
|
|
|
|
vfs_uninit_t *vfs_uninit;
|
|
|
|
vfs_extattrctl_t *vfs_extattrctl;
|
2004-07-04 10:52:54 +00:00
|
|
|
vfs_sysctl_t *vfs_sysctl;
|
2008-09-16 11:51:06 +00:00
|
|
|
vfs_susp_clean_t *vfs_susp_clean;
|
2013-05-11 11:17:44 +00:00
|
|
|
vfs_notify_lowervp_t *vfs_reclaim_lowervp;
|
|
|
|
vfs_notify_lowervp_t *vfs_unlink_lowervp;
|
2013-09-01 23:02:59 +00:00
|
|
|
vfs_purge_t *vfs_purge;
|
2013-08-24 00:30:32 +00:00
|
|
|
vfs_mount_t *vfs_spare[6]; /* spares for ABI compat */
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
|
|
|
|
2004-12-05 22:41:02 +00:00
|
|
|
vfs_statfs_t __vfs_statfs;
|
|
|
|
|
2013-02-21 19:02:50 +00:00
|
|
|
#define VFS_PROLOGUE(MP) do { \
|
2013-11-09 20:30:13 +00:00
|
|
|
struct mount *mp__; \
|
2013-02-21 19:02:50 +00:00
|
|
|
int _enable_stops; \
|
|
|
|
\
|
2013-11-09 20:30:13 +00:00
|
|
|
mp__ = (MP); \
|
|
|
|
_enable_stops = (mp__ != NULL && \
|
|
|
|
(mp__->mnt_vfc->vfc_flags & VFCF_SBDRY) && sigdeferstop())
|
2013-02-21 19:02:50 +00:00
|
|
|
|
|
|
|
#define VFS_EPILOGUE(MP) \
|
|
|
|
if (_enable_stops) \
|
|
|
|
sigallowstop(); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define VFS_MOUNT(MP) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_mount)(MP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_UNMOUNT(MP, FORCE) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_unmount)(MP, FORCE); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_ROOT(MP, FLAGS, VPP) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_root)(MP, FLAGS, VPP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_QUOTACTL(MP, C, U, A) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_STATFS(MP, SBP) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = __vfs_statfs((MP), (SBP)); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_SYNC(MP, WAIT) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_sync)(MP, WAIT); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_VGET(MP, INO, FLAGS, VPP) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_vget)(MP, INO, FLAGS, VPP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_FHTOVP(MP, FIDP, FLAGS, VPP) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, FLAGS, VPP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_CHECKEXP(MP, NAM, EXFLG, CRED, NUMSEC, SEC) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED, NUMSEC,\
|
|
|
|
SEC); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_EXTATTRCTL(MP, C, FN, NS, N) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_extattrctl)(MP, C, FN, NS, N); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_SYSCTL(MP, OP, REQ) ({ \
|
|
|
|
int _rc; \
|
|
|
|
\
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
_rc = (*(MP)->mnt_op->vfs_sysctl)(MP, OP, REQ); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
_rc; })
|
|
|
|
|
|
|
|
#define VFS_SUSP_CLEAN(MP) do { \
|
2014-10-20 18:00:50 +00:00
|
|
|
if (*(MP)->mnt_op->vfs_susp_clean != NULL) { \
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
(*(MP)->mnt_op->vfs_susp_clean)(MP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
} \
|
2013-02-21 19:02:50 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define VFS_RECLAIM_LOWERVP(MP, VP) do { \
|
|
|
|
if (*(MP)->mnt_op->vfs_reclaim_lowervp != NULL) { \
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
(*(MP)->mnt_op->vfs_reclaim_lowervp)((MP), (VP)); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
1994-09-21 03:47:43 +00:00
|
|
|
|
2013-05-11 11:17:44 +00:00
|
|
|
#define VFS_UNLINK_LOWERVP(MP, VP) do { \
|
|
|
|
if (*(MP)->mnt_op->vfs_unlink_lowervp != NULL) { \
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
(*(MP)->mnt_op->vfs_unlink_lowervp)((MP), (VP)); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2013-09-01 23:02:59 +00:00
|
|
|
#define VFS_PURGE(MP) do { \
|
|
|
|
if (*(MP)->mnt_op->vfs_purge != NULL) { \
|
|
|
|
VFS_PROLOGUE(MP); \
|
|
|
|
(*(MP)->mnt_op->vfs_purge)(MP); \
|
|
|
|
VFS_EPILOGUE(MP); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2005-07-01 16:28:32 +00:00
|
|
|
#define VFS_KNOTE_LOCKED(vp, hint) do \
|
2005-06-09 20:20:31 +00:00
|
|
|
{ \
|
2005-08-06 01:42:04 +00:00
|
|
|
if (((vp)->v_vflag & VV_NOKNOTE) == 0) \
|
2009-06-28 21:49:43 +00:00
|
|
|
VN_KNOTE((vp), (hint), KNF_LISTLOCKED); \
|
2005-07-01 16:28:32 +00:00
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define VFS_KNOTE_UNLOCKED(vp, hint) do \
|
|
|
|
{ \
|
2005-08-06 01:42:04 +00:00
|
|
|
if (((vp)->v_vflag & VV_NOKNOTE) == 0) \
|
2005-07-01 16:28:32 +00:00
|
|
|
VN_KNOTE((vp), (hint), 0); \
|
2005-06-09 20:20:31 +00:00
|
|
|
} while (0)
|
|
|
|
|
2013-05-11 11:17:44 +00:00
|
|
|
#define VFS_NOTIFY_UPPER_RECLAIM 1
|
|
|
|
#define VFS_NOTIFY_UPPER_UNLINK 2
|
|
|
|
|
1998-10-16 03:55:01 +00:00
|
|
|
#include <sys/module.h>
|
1998-11-10 09:04:09 +00:00
|
|
|
|
2004-07-30 22:08:52 +00:00
|
|
|
/*
|
|
|
|
* Version numbers.
|
|
|
|
*/
|
|
|
|
#define VFS_VERSION_00 0x19660120
|
2012-10-22 17:50:54 +00:00
|
|
|
#define VFS_VERSION_01 0x20121030
|
|
|
|
#define VFS_VERSION VFS_VERSION_01
|
2004-07-30 22:08:52 +00:00
|
|
|
|
1998-09-07 13:17:06 +00:00
|
|
|
#define VFS_SET(vfsops, fsname, flags) \
|
1998-11-10 09:04:09 +00:00
|
|
|
static struct vfsconf fsname ## _vfsconf = { \
|
2004-07-30 22:08:52 +00:00
|
|
|
.vfc_version = VFS_VERSION, \
|
2004-07-27 22:32:01 +00:00
|
|
|
.vfc_name = #fsname, \
|
2004-07-30 22:08:52 +00:00
|
|
|
.vfc_vfsops = &vfsops, \
|
2004-07-27 22:32:01 +00:00
|
|
|
.vfc_typenum = -1, \
|
|
|
|
.vfc_flags = flags, \
|
1998-11-10 09:04:09 +00:00
|
|
|
}; \
|
|
|
|
static moduledata_t fsname ## _mod = { \
|
|
|
|
#fsname, \
|
|
|
|
vfs_modevent, \
|
|
|
|
& fsname ## _vfsconf \
|
|
|
|
}; \
|
1998-11-06 16:36:31 +00:00
|
|
|
DECLARE_MODULE(fsname, fsname ## _mod, SI_SUB_VFS, SI_ORDER_MIDDLE)
|
1998-10-16 03:55:01 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* exported vnode operations
|
|
|
|
*/
|
2004-12-07 08:15:41 +00:00
|
|
|
|
2004-04-06 09:14:33 +00:00
|
|
|
int dounmount(struct mount *, int, struct thread *);
|
2004-12-06 13:01:41 +00:00
|
|
|
|
2012-01-17 01:08:01 +00:00
|
|
|
int kernel_mount(struct mntarg *ma, uint64_t flags);
|
2002-03-26 15:33:44 +00:00
|
|
|
int kernel_vmount(int flags, ...);
|
2004-12-06 13:01:41 +00:00
|
|
|
struct mntarg *mount_arg(struct mntarg *ma, const char *name, const void *val, int len);
|
2004-12-07 08:15:41 +00:00
|
|
|
struct mntarg *mount_argb(struct mntarg *ma, int flag, const char *name);
|
2004-12-06 13:01:41 +00:00
|
|
|
struct mntarg *mount_argf(struct mntarg *ma, const char *name, const char *fmt, ...);
|
|
|
|
struct mntarg *mount_argsu(struct mntarg *ma, const char *name, const void *val, int len);
|
2007-08-28 20:28:12 +00:00
|
|
|
void statfs_scale_blocks(struct statfs *sf, long max_size);
|
2004-07-27 22:32:01 +00:00
|
|
|
struct vfsconf *vfs_byname(const char *);
|
2004-12-03 16:11:01 +00:00
|
|
|
struct vfsconf *vfs_byname_kld(const char *, struct thread *td, int *);
|
2007-03-31 22:44:45 +00:00
|
|
|
void vfs_mount_destroy(struct mount *);
|
2004-07-06 09:12:03 +00:00
|
|
|
void vfs_event_signal(fsid_t *, u_int32_t, intptr_t);
|
2007-03-31 22:44:45 +00:00
|
|
|
void vfs_freeopts(struct vfsoptlist *opts);
|
2006-12-16 15:44:03 +00:00
|
|
|
void vfs_deleteopt(struct vfsoptlist *opts, const char *name);
|
2009-03-02 23:26:30 +00:00
|
|
|
int vfs_buildopts(struct uio *auio, struct vfsoptlist **options);
|
2011-07-24 17:43:09 +00:00
|
|
|
int vfs_flagopt(struct vfsoptlist *opts, const char *name, uint64_t *w,
|
|
|
|
uint64_t val);
|
2002-03-26 15:33:44 +00:00
|
|
|
int vfs_getopt(struct vfsoptlist *, const char *, void **, int *);
|
2009-03-02 23:26:30 +00:00
|
|
|
int vfs_getopt_pos(struct vfsoptlist *opts, const char *name);
|
2012-04-07 15:27:34 +00:00
|
|
|
int vfs_getopt_size(struct vfsoptlist *opts, const char *name,
|
|
|
|
off_t *value);
|
2004-12-06 18:18:35 +00:00
|
|
|
char *vfs_getopts(struct vfsoptlist *, const char *, int *error);
|
2002-06-14 20:04:21 +00:00
|
|
|
int vfs_copyopt(struct vfsoptlist *, const char *, void *, int);
|
2004-12-06 18:18:35 +00:00
|
|
|
int vfs_filteropt(struct vfsoptlist *, const char **legal);
|
2009-03-02 23:26:30 +00:00
|
|
|
void vfs_opterror(struct vfsoptlist *opts, const char *fmt, ...);
|
2004-12-06 18:18:35 +00:00
|
|
|
int vfs_scanopt(struct vfsoptlist *opts, const char *name, const char *fmt, ...);
|
2009-03-02 23:26:30 +00:00
|
|
|
int vfs_setopt(struct vfsoptlist *opts, const char *name, void *value,
|
|
|
|
int len);
|
|
|
|
int vfs_setopt_part(struct vfsoptlist *opts, const char *name, void *value,
|
|
|
|
int len);
|
|
|
|
int vfs_setopts(struct vfsoptlist *opts, const char *name,
|
|
|
|
const char *value);
|
1997-07-16 18:04:52 +00:00
|
|
|
int vfs_setpublicfs /* set publicly exported fs */
|
2002-03-23 08:46:52 +00:00
|
|
|
(struct mount *, struct netexport *, struct export_args *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void vfs_msync(struct mount *, int);
|
2008-11-02 10:15:42 +00:00
|
|
|
int vfs_busy(struct mount *, int);
|
2001-04-25 07:07:52 +00:00
|
|
|
int vfs_export /* process mount export info */
|
2002-03-23 08:46:52 +00:00
|
|
|
(struct mount *, struct export_args *);
|
2010-08-28 08:57:15 +00:00
|
|
|
void vfs_allocate_syncvnode(struct mount *);
|
2010-09-11 13:06:06 +00:00
|
|
|
void vfs_deallocate_syncvnode(struct mount *);
|
2012-01-17 01:08:01 +00:00
|
|
|
int vfs_donmount(struct thread *td, uint64_t fsflags,
|
|
|
|
struct uio *fsoptions);
|
2002-03-19 20:18:42 +00:00
|
|
|
void vfs_getnewfsid(struct mount *);
|
2004-06-16 09:47:26 +00:00
|
|
|
struct cdev *vfs_getrootfsid(struct mount *);
|
2002-03-19 20:18:42 +00:00
|
|
|
struct mount *vfs_getvfs(fsid_t *); /* return vfs given fsid */
|
2008-11-29 13:34:59 +00:00
|
|
|
struct mount *vfs_busyfs(fsid_t *);
|
2002-03-19 20:18:42 +00:00
|
|
|
int vfs_modevent(module_t, int, void *);
|
2005-11-08 04:13:39 +00:00
|
|
|
void vfs_mount_error(struct mount *, const char *, ...);
|
2002-07-03 08:52:37 +00:00
|
|
|
void vfs_mountroot(void); /* mount our root filesystem */
|
2004-12-06 18:18:35 +00:00
|
|
|
void vfs_mountedfrom(struct mount *, const char *from);
|
2013-05-11 11:17:44 +00:00
|
|
|
void vfs_notify_upper(struct vnode *, int);
|
2010-10-10 07:05:47 +00:00
|
|
|
void vfs_oexport_conv(const struct oexport_args *oexp,
|
|
|
|
struct export_args *exp);
|
2006-02-06 10:19:50 +00:00
|
|
|
void vfs_ref(struct mount *);
|
|
|
|
void vfs_rel(struct mount *);
|
2007-04-17 21:14:06 +00:00
|
|
|
struct mount *vfs_mount_alloc(struct vnode *, struct vfsconf *, const char *,
|
2008-08-31 14:26:08 +00:00
|
|
|
struct ucred *);
|
2004-07-06 09:37:43 +00:00
|
|
|
int vfs_suser(struct mount *, struct thread *);
|
2008-08-31 14:26:08 +00:00
|
|
|
void vfs_unbusy(struct mount *);
|
2002-03-19 20:18:42 +00:00
|
|
|
void vfs_unmountall(void);
|
2000-05-26 02:09:24 +00:00
|
|
|
extern TAILQ_HEAD(mntlist, mount) mountlist; /* mounted filesystem list */
|
2000-10-04 01:29:17 +00:00
|
|
|
extern struct mtx mountlist_mtx;
|
1997-07-16 18:04:52 +00:00
|
|
|
extern struct nfs_public nfs_pub;
|
2014-08-03 03:27:54 +00:00
|
|
|
extern struct sx vfsconf_sx;
|
|
|
|
#define vfsconf_lock() sx_xlock(&vfsconf_sx)
|
|
|
|
#define vfsconf_unlock() sx_xunlock(&vfsconf_sx)
|
|
|
|
#define vfsconf_slock() sx_slock(&vfsconf_sx)
|
|
|
|
#define vfsconf_sunlock() sx_sunlock(&vfsconf_sx)
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2003-03-10 21:55:00 +00:00
|
|
|
/*
|
|
|
|
* Declarations for these vfs default operations are located in
|
2013-01-24 23:11:51 +00:00
|
|
|
* kern/vfs_default.c. They will be automatically used to replace
|
|
|
|
* null entries in VFS ops tables when registering a new filesystem
|
|
|
|
* type in the global table.
|
2003-03-10 21:55:00 +00:00
|
|
|
*/
|
2002-08-13 10:05:50 +00:00
|
|
|
vfs_root_t vfs_stdroot;
|
|
|
|
vfs_quotactl_t vfs_stdquotactl;
|
|
|
|
vfs_statfs_t vfs_stdstatfs;
|
|
|
|
vfs_sync_t vfs_stdsync;
|
2003-03-11 22:15:10 +00:00
|
|
|
vfs_sync_t vfs_stdnosync;
|
2002-08-13 10:05:50 +00:00
|
|
|
vfs_vget_t vfs_stdvget;
|
|
|
|
vfs_fhtovp_t vfs_stdfhtovp;
|
|
|
|
vfs_checkexp_t vfs_stdcheckexp;
|
|
|
|
vfs_init_t vfs_stdinit;
|
|
|
|
vfs_uninit_t vfs_stduninit;
|
|
|
|
vfs_extattrctl_t vfs_stdextattrctl;
|
2004-07-07 06:58:29 +00:00
|
|
|
vfs_sysctl_t vfs_stdsysctl;
|
1999-09-07 22:42:38 +00:00
|
|
|
|
2014-12-08 16:48:57 +00:00
|
|
|
void syncer_suspend(void);
|
|
|
|
void syncer_resume(void);
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#else /* !_KERNEL */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
2000-10-13 14:04:26 +00:00
|
|
|
struct stat;
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
__BEGIN_DECLS
|
2002-03-19 20:18:42 +00:00
|
|
|
int fhopen(const struct fhandle *, int);
|
|
|
|
int fhstat(const struct fhandle *, struct stat *);
|
|
|
|
int fhstatfs(const struct fhandle *, struct statfs *);
|
|
|
|
int fstatfs(int, struct statfs *);
|
|
|
|
int getfh(const char *, fhandle_t *);
|
|
|
|
int getfsstat(struct statfs *, long, int);
|
|
|
|
int getmntinfo(struct statfs **, int);
|
2004-04-06 08:30:21 +00:00
|
|
|
int lgetfh(const char *, fhandle_t *);
|
2002-03-19 20:18:42 +00:00
|
|
|
int mount(const char *, const char *, int, void *);
|
2004-04-06 09:14:33 +00:00
|
|
|
int nmount(struct iovec *, unsigned int, int);
|
2002-03-19 20:18:42 +00:00
|
|
|
int statfs(const char *, struct statfs *);
|
|
|
|
int unmount(const char *, int);
|
1994-09-22 01:05:09 +00:00
|
|
|
|
|
|
|
/* C library stuff */
|
2004-04-06 09:14:33 +00:00
|
|
|
int getvfsbyname(const char *, struct xvfsconf *);
|
1994-05-24 10:09:53 +00:00
|
|
|
__END_DECLS
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-08-22 14:09:51 +00:00
|
|
|
|
|
|
|
#endif /* !_SYS_MOUNT_H_ */
|