xref: /openbsd/sys/sys/mount.h (revision 81fb472f)
1 /*	$OpenBSD: mount.h,v 1.151 2024/02/03 18:51:58 beck 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	xucred 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 
135 /*
136  * NFS mount option flags
137  */
138 #define	NFSMNT_RESVPORT		0x00000000  /* always use reserved ports */
139 #define	NFSMNT_SOFT		0x00000001  /* soft mount (hard is default) */
140 #define	NFSMNT_WSIZE		0x00000002  /* set write size */
141 #define	NFSMNT_RSIZE		0x00000004  /* set read size */
142 #define	NFSMNT_TIMEO		0x00000008  /* set initial timeout */
143 #define	NFSMNT_RETRANS		0x00000010  /* set number of request retries */
144 #define	NFSMNT_MAXGRPS		0x00000020  /* set maximum grouplist size */
145 #define	NFSMNT_INT		0x00000040  /* allow interrupts on hard mount */
146 #define	NFSMNT_NOCONN		0x00000080  /* Don't Connect the socket */
147 #define	NFSMNT_NQNFS		0x00000100  /* Use Nqnfs protocol */
148 #define	NFSMNT_NFSV3		0x00000200  /* Use NFS Version 3 protocol */
149 #define	NFSMNT_KERB		0x00000400  /* Use Kerberos authentication */
150 #define	NFSMNT_DUMBTIMR		0x00000800  /* Don't estimate rtt dynamically */
151 #define	NFSMNT_LEASETERM	0x00001000  /* set lease term (nqnfs) */
152 #define	NFSMNT_READAHEAD	0x00002000  /* set read ahead */
153 #define	NFSMNT_DEADTHRESH	0x00004000  /* set dead server retry thresh */
154 #define	NFSMNT_NOAC		0x00008000  /* disable attribute cache */
155 #define	NFSMNT_RDIRPLUS		0x00010000  /* Use Readdirplus for V3 */
156 #define	NFSMNT_READDIRSIZE	0x00020000  /* Set readdir size */
157 
158 /* Flags valid only in mount syscall arguments */
159 #define NFSMNT_ACREGMIN		0x00040000  /* acregmin field valid */
160 #define NFSMNT_ACREGMAX		0x00080000  /* acregmax field valid */
161 #define NFSMNT_ACDIRMIN		0x00100000  /* acdirmin field valid */
162 #define NFSMNT_ACDIRMAX		0x00200000  /* acdirmax field valid */
163 
164 /* Flags valid only in kernel */
165 #define	NFSMNT_INTERNAL		0xfffc0000  /* Bits set internally */
166 #define NFSMNT_HASWRITEVERF	0x00040000  /* Has write verifier for V3 */
167 #define NFSMNT_GOTPATHCONF	0x00080000  /* Got the V3 pathconf info */
168 #define NFSMNT_GOTFSINFO	0x00100000  /* Got the V3 fsinfo */
169 #define	NFSMNT_MNTD		0x00200000  /* Mnt server for mnt point */
170 #define	NFSMNT_DISMINPROG	0x00400000  /* Dismount in progress */
171 #define	NFSMNT_DISMNT		0x00800000  /* Dismounted */
172 #define	NFSMNT_SNDLOCK		0x01000000  /* Send socket lock */
173 #define	NFSMNT_WANTSND		0x02000000  /* Want above */
174 #define	NFSMNT_RCVLOCK		0x04000000  /* Rcv socket lock */
175 #define	NFSMNT_WANTRCV		0x08000000  /* Want above */
176 #define	NFSMNT_WAITAUTH		0x10000000  /* Wait for authentication */
177 #define	NFSMNT_HASAUTH		0x20000000  /* Has authenticator */
178 #define	NFSMNT_WANTAUTH		0x40000000  /* Wants an authenticator */
179 #define	NFSMNT_AUTHERR		0x80000000  /* Authentication error */
180 
181 /*
182  *  Arguments to mount MSDOS filesystems.
183  */
184 struct msdosfs_args {
185 	char	*fspec;		/* blocks special holding the fs to mount */
186 	struct	export_args export_info;
187 				/* network export information */
188 	uid_t	uid;		/* uid that owns msdosfs files */
189 	gid_t	gid;		/* gid that owns msdosfs files */
190 	mode_t  mask;		/* mask to be applied for msdosfs perms */
191 	int	flags;		/* see below */
192 };
193 
194 /*
195  * Msdosfs mount options:
196  */
197 #define	MSDOSFSMNT_SHORTNAME	0x01	/* Force old DOS short names only */
198 #define	MSDOSFSMNT_LONGNAME	0x02	/* Force Win'95 long names */
199 #define	MSDOSFSMNT_NOWIN95	0x04	/* Completely ignore Win95 entries */
200 
201 /*
202  * Arguments to mount ntfs filesystems
203  */
204 struct ntfs_args {
205 	char	*fspec;			/* block special device to mount */
206 	struct	export_args export_info;/* network export information */
207 	uid_t	uid;			/* uid that owns ntfs files */
208 	gid_t	gid;			/* gid that owns ntfs files */
209 	mode_t	mode;			/* mask to be applied for ntfs perms */
210 	u_long	flag;			/* additional flags */
211 };
212 
213 /*
214  * ntfs mount options:
215  */
216 #define	NTFS_MFLAG_CASEINS      0x00000001
217 #define	NTFS_MFLAG_ALLNAMES     0x00000002
218 
219 /* Arguments to mount UDF file systems */
220 struct udf_args {
221 	char *fspec; /* Block special device to mount */
222 	u_int32_t lastblock; /* Special device last block */
223 };
224 
225 /*
226  * Arguments to mount tmpfs file systems
227  */
228 #define TMPFS_ARGS_VERSION	1
229 struct tmpfs_args {
230 	int			ta_version;
231 
232 	/* Size counters. */
233 	ino_t			ta_nodes_max;
234 	off_t			ta_size_max;
235 
236 	/* Root node attributes. */
237 	uid_t			ta_root_uid;
238 	gid_t			ta_root_gid;
239 	mode_t			ta_root_mode;
240 };
241 
242 /*
243  * Arguments to mount fusefs filesystems
244  */
245 struct fusefs_args {
246 	char *name;
247 	int fd;
248 	int max_read;
249 
250 	/*
251 	 * FUSE does not allow the file system to be accessed by other users
252 	 * unless this option is specified. This is to prevent unintentional
253 	 * denial of service to other users if the file system is not
254 	 * responding. e.g. user executes df(1) or cron job that scans mounted
255 	 * file systems.
256 	 */
257 	int allow_other;
258 };
259 
260 /*
261  * file system statistics
262  */
263 
264 #define	MFSNAMELEN	16	/* length of fs type name, including nul */
265 #define	MNAMELEN	90	/* length of buffer for returned name */
266 
267 /* per-filesystem mount options */
268 union mount_info {
269 	struct ufs_args ufs_args;
270 	struct mfs_args mfs_args;
271 	struct nfs_args nfs_args;
272 	struct iso_args iso_args;
273 	struct msdosfs_args msdosfs_args;
274 	struct ntfs_args ntfs_args;
275 	struct tmpfs_args tmpfs_args;
276 	char __align[160];	/* 64-bit alignment and room to grow */
277 };
278 
279 /* new statfs structure with mount options and statvfs fields */
280 struct statfs {
281 	u_int32_t	f_flags;	/* copy of mount flags */
282 	u_int32_t	f_bsize;	/* file system block size */
283 	u_int32_t	f_iosize;	/* optimal transfer block size */
284 
285 					/* unit is f_bsize */
286 	u_int64_t  	f_blocks;	/* total data blocks in file system */
287 	u_int64_t  	f_bfree;	/* free blocks in fs */
288 	int64_t  	f_bavail;	/* free blocks avail to non-superuser */
289 
290 	u_int64_t 	f_files;	/* total file nodes in file system */
291 	u_int64_t  	f_ffree;	/* free file nodes in fs */
292 	int64_t  	f_favail;	/* free file nodes avail to non-root */
293 
294 	u_int64_t  	f_syncwrites;	/* count of sync writes since mount */
295 	u_int64_t  	f_syncreads;	/* count of sync reads since mount */
296 	u_int64_t  	f_asyncwrites;	/* count of async writes since mount */
297 	u_int64_t  	f_asyncreads;	/* count of async reads since mount */
298 
299 	fsid_t	   	f_fsid;		/* file system id */
300 	u_int32_t	f_namemax;      /* maximum filename length */
301 	uid_t	   	f_owner;	/* user that mounted the file system */
302 	u_int64_t  	f_ctime;	/* last mount [-u] time */
303 
304 	char f_fstypename[MFSNAMELEN];	/* fs type name */
305 	char f_mntonname[MNAMELEN];	/* directory on which mounted */
306 	char f_mntfromname[MNAMELEN];	/* mounted file system */
307 	char f_mntfromspec[MNAMELEN];	/* special for mount request */
308 	union mount_info mount_info;	/* per-filesystem mount options */
309 };
310 
311 
312 /*
313  * File system types.
314  */
315 #define	MOUNT_FFS	"ffs"		/* UNIX "Fast" Filesystem */
316 #define	MOUNT_UFS	MOUNT_FFS	/* for compatibility */
317 #define	MOUNT_NFS	"nfs"		/* Network Filesystem */
318 #define	MOUNT_MFS	"mfs"		/* Memory Filesystem */
319 #define	MOUNT_MSDOS	"msdos"		/* MSDOS Filesystem */
320 #define	MOUNT_AFS	"afs"		/* Andrew Filesystem */
321 #define	MOUNT_CD9660	"cd9660"	/* ISO9660 (aka CDROM) Filesystem */
322 #define	MOUNT_EXT2FS	"ext2fs"	/* Second Extended Filesystem */
323 #define	MOUNT_NCPFS	"ncpfs"		/* NetWare Network File System */
324 #define	MOUNT_NTFS	"ntfs"		/* NTFS */
325 #define	MOUNT_UDF	"udf"		/* UDF */
326 #define	MOUNT_TMPFS	"tmpfs"		/* tmpfs */
327 #define	MOUNT_FUSEFS	"fuse"		/* FUSE */
328 
329 /*
330  * Structure per mounted file system.  Each mounted file system has an
331  * array of operations and an instance record.  The file systems are
332  * put on a doubly linked list.
333  */
334 struct mount {
335 	TAILQ_ENTRY(mount) mnt_list;		/* mount list */
336 	SLIST_ENTRY(mount) mnt_dounmount;	/* unmount work queue */
337 	const struct vfsops *mnt_op;		/* operations on fs */
338 	struct vfsconf  *mnt_vfc;               /* configuration info */
339 	struct vnode	*mnt_vnodecovered;	/* vnode we mounted on */
340 	struct vnode    *mnt_syncer;            /* syncer vnode */
341 	TAILQ_HEAD(, vnode) mnt_vnodelist;	/* list of vnodes this mount */
342 	struct rwlock   mnt_lock;               /* mount structure lock */
343 	int		mnt_flag;		/* flags */
344 	struct statfs	mnt_stat;		/* cache of filesystem stats */
345 	void		*mnt_data;		/* private data */
346 };
347 
348 /*
349  * Mount flags.
350  *
351  * Unmount uses MNT_FORCE flag.
352  */
353 #define	MNT_RDONLY	0x00000001	/* read only filesystem */
354 #define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */
355 #define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */
356 #define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */
357 #define	MNT_NODEV	0x00000010	/* don't interpret special files */
358 #define	MNT_NOPERM	0x00000020	/* don't enforce permission checks */
359 #define	MNT_ASYNC	0x00000040	/* file system written asynchronously */
360 #define	MNT_WXALLOWED	0x00000800	/* filesystem allows W|X mappings */
361 
362 /*
363  * exported mount flags.
364  */
365 #define	MNT_EXRDONLY	0x00000080	/* exported read only */
366 #define	MNT_EXPORTED	0x00000100	/* file system is exported */
367 #define	MNT_DEFEXPORTED	0x00000200	/* exported to the world */
368 #define	MNT_EXPORTANON	0x00000400	/* use anon uid mapping for everyone */
369 
370 /*
371  * Flags set by internal operations.
372  */
373 #define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */
374 #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */
375 #define	MNT_ROOTFS	0x00004000	/* identifies the root filesystem */
376 
377 /*
378  * Extra post 4.4BSD-lite2 mount flags.
379  */
380 #define MNT_NOATIME	0x00008000	/* don't update access times on fs */
381 
382 /*
383  * Mask of flags that are visible to statfs()
384  */
385 #define	MNT_VISFLAGMASK	0x0400ffff
386 
387 #define	MNT_BITS \
388     "\20\001RDONLY\002SYNCHRONOUS\003NOEXEC\004NOSUID\005NODEV\006NOPERM" \
389     "\007ASYNC\010EXRDONLY\011EXPORTED\012DEFEXPORTED\013EXPORTANON" \
390     "\014WXALLOWED\015LOCAL\016QUOTA\017ROOTFS\020NOATIME\021UPDATE" \
391     "\022DELEXPORT\023RELOAD\024FORCE\025STALLED\026SWAPPABLE\032WANTRDWR" \
392     "\033SOFTDEP\034DOOMED"
393 
394 /*
395  * filesystem control flags.
396  */
397 #define	MNT_UPDATE	0x00010000	/* not a real mount, just an update */
398 #define	MNT_DELEXPORT	0x00020000	/* delete export host lists */
399 #define	MNT_RELOAD	0x00040000	/* reload filesystem data */
400 #define	MNT_FORCE	0x00080000	/* force unmount or readonly change */
401 #define	MNT_STALLED	0x00100000	/* filesystem stalled */
402 #define	MNT_SWAPPABLE	0x00200000	/* filesystem can be used for swap */
403 #define MNT_WANTRDWR	0x02000000	/* want upgrade to read/write */
404 #define MNT_SOFTDEP     0x04000000      /* soft dependencies being done - now ignored */
405 #define MNT_DOOMED	0x08000000	/* device behind filesystem is gone */
406 
407 #ifdef _KERNEL
408 #define MNT_OP_FLAGS	(MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR)
409 #endif
410 
411 /*
412  * Flags for various system call interfaces.
413  *
414  * waitfor flags to vfs_sync() and getfsstat()
415  */
416 #define MNT_WAIT	1	/* synchronously wait for I/O to complete */
417 #define MNT_NOWAIT	2	/* start all I/O, but do not wait for it */
418 #define MNT_LAZY	3	/* push data not written by filesystem syncer */
419 
420 /*
421  * Generic file handle
422  */
423 struct fhandle {
424 	fsid_t	fh_fsid;	/* File system id of mount point */
425 	struct	fid fh_fid;	/* File sys specific id */
426 };
427 typedef struct fhandle	fhandle_t;
428 
429 /*
430  * Sysctl CTL_VFS definitions.
431  *
432  * Second level identifier specifies which filesystem. Second level
433  * identifier VFS_GENERIC returns information about all filesystems.
434  */
435 #define	VFS_GENERIC	0	/* generic filesystem information */
436 /*
437  * Third level identifiers for VFS_GENERIC are given below; third
438  * level identifiers for specific filesystems are given in their
439  * mount specific header files.
440  */
441 #define VFS_MAXTYPENUM	1	/* int: highest defined filesystem type */
442 #define VFS_CONF	2	/* struct: vfsconf for filesystem given
443 				   as next argument */
444 #define VFS_BCACHESTAT	3	/* struct: buffer cache statistics given
445 				   as next argument */
446 #define	CTL_VFSGENCTL_NAMES { \
447 	{ 0, 0 }, \
448 	{ "maxtypenum", CTLTYPE_INT }, \
449 	{ "conf", CTLTYPE_NODE }, \
450 	{ "bcachestat", CTLTYPE_STRUCT } \
451 }
452 
453 /*
454  * Filesystem configuration information. One of these exists for each
455  * type of filesystem supported by the kernel. These are searched at
456  * mount time to identify the requested filesystem.
457  */
458 struct vfsconf {
459 	const struct vfsops *vfc_vfsops; /* filesystem operations vector */
460 	char	vfc_name[MFSNAMELEN];	/* filesystem type name */
461 	int	vfc_typenum;		/* historic filesystem type number */
462 	u_int	vfc_refcount;		/* number mounted of this type */
463 	int	vfc_flags;		/* permanent flags */
464 	size_t	vfc_datasize;		/* size of data args */
465 };
466 
467 /* buffer cache statistics */
468 struct bcachestats {
469 	int64_t numbufs;		/* number of buffers allocated */
470 	int64_t numbufpages;		/* number of pages in buffer cache */
471 	int64_t numdirtypages; 		/* number of dirty free pages */
472 	int64_t numcleanpages; 		/* number of clean free pages */
473 	int64_t pendingwrites;		/* number of pending writes */
474 	int64_t pendingreads;		/* number of pending reads */
475 	int64_t numwrites;		/* total writes started */
476 	int64_t numreads;		/* total reads started */
477 	int64_t cachehits;		/* total reads found in cache */
478 	int64_t busymapped;		/* number of busy and mapped buffers */
479 	int64_t dmapages;		/* dma reachable pages in buffer cache */
480 	int64_t highpages;		/* pages above dma region */
481 	int64_t delwribufs;		/* delayed write buffers */
482 	int64_t kvaslots;		/* kva slots total */
483 	int64_t kvaslots_avail;		/* available kva slots */
484 	int64_t highflips;		/* total flips to above DMA */
485 	int64_t highflops;		/* total failed flips to above DMA */
486 	int64_t dmaflips;		/* total flips from high to DMA */
487 };
488 #ifdef _KERNEL
489 extern struct bcachestats bcstats;
490 extern long buflowpages, bufhighpages, bufbackpages;
491 #define BUFPAGES_DEFICIT (((buflowpages - bcstats.numbufpages) < 0) ? 0 \
492     : buflowpages - bcstats.numbufpages)
493 #define BUFPAGES_INACT (((bcstats.numcleanpages - buflowpages) < 0) ? 0 \
494     : bcstats.numcleanpages - buflowpages)
495 extern int bufcachepercent;
496 extern void bufadjust(int);
497 struct uvm_constraint_range;
498 extern int bufbackoff(struct uvm_constraint_range*, long);
499 
500 /*
501  * Operations supported on mounted file system.
502  */
503 struct nameidata;
504 struct mbuf;
505 
506 extern int maxvfsconf;		/* highest defined filesystem type */
507 
508 struct vfsops {
509 	int	(*vfs_mount)(struct mount *mp, const char *path,
510 				    void *data,
511 				    struct nameidata *ndp, struct proc *p);
512 	int	(*vfs_start)(struct mount *mp, int flags,
513 				    struct proc *p);
514 	int	(*vfs_unmount)(struct mount *mp, int mntflags,
515 				    struct proc *p);
516 	int	(*vfs_root)(struct mount *mp, struct vnode **vpp);
517 	int	(*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid,
518 				    caddr_t arg, struct proc *p);
519 	int	(*vfs_statfs)(struct mount *mp, struct statfs *sbp,
520 				    struct proc *p);
521 	int	(*vfs_sync)(struct mount *mp, int waitfor, int stall,
522 				    struct ucred *cred, struct proc *p);
523 	int	(*vfs_vget)(struct mount *mp, ino_t ino,
524 				    struct vnode **vpp);
525 	int	(*vfs_fhtovp)(struct mount *mp, struct fid *fhp,
526 				     struct vnode **vpp);
527 	int	(*vfs_vptofh)(struct vnode *vp, struct fid *fhp);
528 	int	(*vfs_init)(struct vfsconf *);
529 	int     (*vfs_sysctl)(int *, u_int, void *, size_t *, void *,
530 				     size_t, struct proc *);
531 	int	(*vfs_checkexp)(struct mount *mp, struct mbuf *nam,
532 				    int *extflagsp, struct ucred **credanonp);
533 };
534 
535 #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \
536 	(*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P)
537 #define VFS_START(MP, FLAGS, P)	  (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P)
538 #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P)
539 #define VFS_ROOT(MP, VPP)	  (*(MP)->mnt_op->vfs_root)(MP, VPP)
540 #define VFS_QUOTACTL(MP,C,U,A,P)  (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P)
541 #define VFS_STATFS(MP, SBP, P)	  (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P)
542 #define VFS_SYNC(MP, W, S, C, P)  (*(MP)->mnt_op->vfs_sync)(MP, W, S, C, P)
543 #define VFS_VGET(MP, INO, VPP)	  (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP)
544 #define VFS_FHTOVP(MP, FIDP, VPP) \
545 	(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP)
546 #define	VFS_VPTOFH(VP, FIDP)	  (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP)
547 #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \
548 	(*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED)
549 
550 /* Set up the filesystem operations for vnodes. */
551 extern	const struct vfsops ffs_vfsops;
552 extern	const struct vfsops mfs_vfsops;
553 extern	const struct vfsops msdosfs_vfsops;
554 extern	const struct vfsops nfs_vfsops;
555 extern	const struct vfsops cd9660_vfsops;
556 extern	const struct vfsops ext2fs_vfsops;
557 extern	const struct vfsops ntfs_vfsops;
558 extern	const struct vfsops udf_vfsops;
559 extern	const struct vfsops fusefs_vfsops;
560 extern	const struct vfsops tmpfs_vfsops;
561 
562 #include <net/radix.h>
563 #include <sys/socket.h>		/* XXX for AF_MAX */
564 
565 /*
566  * Network address lookup element
567  */
568 struct netcred {
569 	struct	radix_node netc_rnodes[2];
570 	int	netc_exflags;
571 	int	netc_len;			/* size of the allocation */
572 	struct	ucred netc_anon;
573 };
574 
575 /*
576  * Network export information
577  */
578 struct netexport {
579 	struct	netcred ne_defexported;		/* Default export */
580 	struct	radix_node_head *ne_rtable_inet;/* Individual exports */
581 };
582 
583 /*
584  * exported vnode operations
585  */
586 int	vfs_busy(struct mount *, int);
587 #define VB_READ		0x01
588 #define VB_WRITE	0x02
589 #define VB_NOWAIT	0x04	/* immediately fail on busy lock */
590 #define VB_WAIT		0x08	/* sleep fail on busy lock */
591 #define VB_DUPOK	0x10	/* permit duplicate mount busying */
592 
593 int     vfs_isbusy(struct mount *);
594 struct	mount *vfs_mount_alloc(struct vnode *, struct vfsconf *);
595 void	vfs_mount_free(struct mount *);
596 int     vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *,
597 				    void *), void *);
598 void	vfs_getnewfsid(struct mount *);
599 struct	mount *vfs_getvfs(fsid_t *);
600 int	vfs_mountedon(struct vnode *);
601 int	vfs_rootmountalloc(char *, char *, struct mount **);
602 void	vfs_unbusy(struct mount *);
603 extern	TAILQ_HEAD(mntlist, mount) mountlist;
604 int	vfs_stall(struct proc *, int);
605 void	vfs_stall_barrier(void);
606 
607 					    /* process mount export info */
608 int	vfs_export(struct mount *, struct netexport *, struct export_args *);
609 					    /* lookup host in fs export list */
610 struct	netcred *vfs_export_lookup(struct mount *, struct netexport *,
611 	    struct mbuf *);
612 int	vfs_allocate_syncvnode(struct mount *);
613 
614 int	vfs_syncwait(struct proc *, int);   /* sync and wait for complete */
615 void	vfs_shutdown(struct proc *);	    /* unmount and sync file systems */
616 int	dounmount(struct mount *, int, struct proc *);
617 void	vfsinit(void);
618 struct	vfsconf *vfs_byname(const char *);
619 struct	vfsconf *vfs_bytypenum(int);
620 #else /* _KERNEL */
621 __BEGIN_DECLS
622 int	fstatfs(int, struct statfs *);
623 int	getfh(const char *, fhandle_t *);
624 int	getfsstat(struct statfs *, size_t, int);
625 int	getmntinfo(struct statfs **, int);
626 int	mount(const char *, const char *, int, void *);
627 int	statfs(const char *, struct statfs *);
628 int	unmount(const char *, int);
629 #if __BSD_VISIBLE
630 struct stat;
631 int	fhopen(const fhandle_t *, int);
632 int	fhstat(const fhandle_t *, struct stat *);
633 int	fhstatfs(const fhandle_t *, struct statfs *);
634 #endif /* __BSD_VISIBLE */
635 __END_DECLS
636 #endif /* _KERNEL */
637 #endif /* !_SYS_MOUNT_H_ */
638