| 1 | /*	$OpenBSD: mount.h,v 1.153 2025/01/02 01:19:22 dlg 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 | 	struct refcnt	mnt_refs; |
| 344 | 	int		mnt_flag;		/* flags */ |
| 345 | 	struct statfs	mnt_stat;		/* cache of filesystem stats */ |
| 346 | 	void		*mnt_data;		/* private data */ |
| 347 | }; |
| 348 | |
| 349 | /* |
| 350 | * Mount flags. |
| 351 | * |
| 352 | * Unmount uses MNT_FORCE flag. |
| 353 | */ |
| 354 | #define	MNT_RDONLY	0x00000001	/* read only filesystem */ |
| 355 | #define	MNT_SYNCHRONOUS	0x00000002	/* file system written synchronously */ |
| 356 | #define	MNT_NOEXEC	0x00000004	/* can't exec from filesystem */ |
| 357 | #define	MNT_NOSUID	0x00000008	/* don't honor setuid bits on fs */ |
| 358 | #define	MNT_NODEV	0x00000010	/* don't interpret special files */ |
| 359 | #define	MNT_NOPERM	0x00000020	/* don't enforce permission checks */ |
| 360 | #define	MNT_ASYNC	0x00000040	/* file system written asynchronously */ |
| 361 | #define	MNT_WXALLOWED	0x00000800	/* filesystem allows W|X mappings */ |
| 362 | |
| 363 | /* |
| 364 | * exported mount flags. |
| 365 | */ |
| 366 | #define	MNT_EXRDONLY	0x00000080	/* exported read only */ |
| 367 | #define	MNT_EXPORTED	0x00000100	/* file system is exported */ |
| 368 | #define	MNT_DEFEXPORTED	0x00000200	/* exported to the world */ |
| 369 | #define	MNT_EXPORTANON	0x00000400	/* use anon uid mapping for everyone */ |
| 370 | |
| 371 | /* |
| 372 | * Flags set by internal operations. |
| 373 | */ |
| 374 | #define	MNT_LOCAL	0x00001000	/* filesystem is stored locally */ |
| 375 | #define	MNT_QUOTA	0x00002000	/* quotas are enabled on filesystem */ |
| 376 | #define	MNT_ROOTFS	0x00004000	/* identifies the root filesystem */ |
| 377 | |
| 378 | /* |
| 379 | * Extra post 4.4BSD-lite2 mount flags. |
| 380 | */ |
| 381 | #define MNT_NOATIME	0x00008000	/* don't update access times on fs */ |
| 382 | |
| 383 | /* |
| 384 | * Mask of flags that are visible to statfs() |
| 385 | */ |
| 386 | #define	MNT_VISFLAGMASK	0x0400ffff |
| 387 | |
| 388 | #define	MNT_BITS \ |
| 389 | "\20\001RDONLY\002SYNCHRONOUS\003NOEXEC\004NOSUID\005NODEV\006NOPERM" \ |
| 390 | "\007ASYNC\010EXRDONLY\011EXPORTED\012DEFEXPORTED\013EXPORTANON" \ |
| 391 | "\014WXALLOWED\015LOCAL\016QUOTA\017ROOTFS\020NOATIME\021UPDATE" \ |
| 392 | "\022DELEXPORT\023RELOAD\024FORCE\025STALLED\026SWAPPABLE\031UNMOUNT" \ |
| 393 | "\032WANTRDWR\033SOFTDEP\034DOOMED" |
| 394 | |
| 395 | /* |
| 396 | * filesystem control flags. |
| 397 | */ |
| 398 | #define	MNT_UPDATE	0x00010000	/* not a real mount, just an update */ |
| 399 | #define	MNT_DELEXPORT	0x00020000	/* delete export host lists */ |
| 400 | #define	MNT_RELOAD	0x00040000	/* reload filesystem data */ |
| 401 | #define	MNT_FORCE	0x00080000	/* force unmount or readonly change */ |
| 402 | #define	MNT_STALLED	0x00100000	/* filesystem stalled */ |
| 403 | #define	MNT_SWAPPABLE	0x00200000	/* filesystem can be used for swap */ |
| 404 | #define MNT_UNMOUNT	0x01000000	/* unmount in progress */ |
| 405 | #define MNT_WANTRDWR	0x02000000	/* want upgrade to read/write */ |
| 406 | #define MNT_SOFTDEP 0x04000000 /* soft dependencies being done - now ignored */ |
| 407 | #define MNT_DOOMED	0x08000000	/* device behind filesystem is gone */ |
| 408 | |
| 409 | #ifdef _KERNEL |
| 410 | #define MNT_OP_FLAGS	(MNT_UPDATE | MNT_RELOAD | MNT_FORCE | MNT_WANTRDWR) |
| 411 | #endif |
| 412 | |
| 413 | /* |
| 414 | * Flags for various system call interfaces. |
| 415 | * |
| 416 | * waitfor flags to vfs_sync() and getfsstat() |
| 417 | */ |
| 418 | #define MNT_WAIT	1	/* synchronously wait for I/O to complete */ |
| 419 | #define MNT_NOWAIT	2	/* start all I/O, but do not wait for it */ |
| 420 | #define MNT_LAZY	3	/* push data not written by filesystem syncer */ |
| 421 | |
| 422 | /* |
| 423 | * Generic file handle |
| 424 | */ |
| 425 | struct fhandle { |
| 426 | 	fsid_t	fh_fsid;	/* File system id of mount point */ |
| 427 | 	struct	fid fh_fid;	/* File sys specific id */ |
| 428 | }; |
| 429 | typedef struct fhandle	fhandle_t; |
| 430 | |
| 431 | /* |
| 432 | * Sysctl CTL_VFS definitions. |
| 433 | * |
| 434 | * Second level identifier specifies which filesystem. Second level |
| 435 | * identifier VFS_GENERIC returns information about all filesystems. |
| 436 | */ |
| 437 | #define	VFS_GENERIC	0	/* generic filesystem information */ |
| 438 | /* |
| 439 | * Third level identifiers for VFS_GENERIC are given below; third |
| 440 | * level identifiers for specific filesystems are given in their |
| 441 | * mount specific header files. |
| 442 | */ |
| 443 | #define VFS_MAXTYPENUM	1	/* int: highest defined filesystem type */ |
| 444 | #define VFS_CONF	2	/* struct: vfsconf for filesystem given |
| 445 | 				 as next argument */ |
| 446 | #define VFS_BCACHESTAT	3	/* struct: buffer cache statistics given |
| 447 | 				 as next argument */ |
| 448 | #define	CTL_VFSGENCTL_NAMES { \ |
| 449 | 	{ 0, 0 }, \ |
| 450 | 	{ "maxtypenum", CTLTYPE_INT }, \ |
| 451 | 	{ "conf", CTLTYPE_NODE }, \ |
| 452 | 	{ "bcachestat", CTLTYPE_STRUCT } \ |
| 453 | } |
| 454 | |
| 455 | /* |
| 456 | * Filesystem configuration information. One of these exists for each |
| 457 | * type of filesystem supported by the kernel. These are searched at |
| 458 | * mount time to identify the requested filesystem. |
| 459 | */ |
| 460 | struct vfsconf { |
| 461 | 	const struct vfsops *vfc_vfsops; /* filesystem operations vector */ |
| 462 | 	char	vfc_name[MFSNAMELEN];	/* filesystem type name */ |
| 463 | 	int	vfc_typenum;		/* historic filesystem type number */ |
| 464 | 	u_int	vfc_refcount;		/* number mounted of this type */ |
| 465 | 	int	vfc_flags;		/* permanent flags */ |
| 466 | 	size_t	vfc_datasize;		/* size of data args */ |
| 467 | }; |
| 468 | |
| 469 | /* buffer cache statistics */ |
| 470 | struct bcachestats { |
| 471 | 	int64_t numbufs;		/* number of buffers allocated */ |
| 472 | 	int64_t numbufpages;		/* number of pages in buffer cache */ |
| 473 | 	int64_t numdirtypages; 		/* number of dirty free pages */ |
| 474 | 	int64_t numcleanpages; 		/* number of clean free pages */ |
| 475 | 	int64_t pendingwrites;		/* number of pending writes */ |
| 476 | 	int64_t pendingreads;		/* number of pending reads */ |
| 477 | 	int64_t numwrites;		/* total writes started */ |
| 478 | 	int64_t numreads;		/* total reads started */ |
| 479 | 	int64_t cachehits;		/* total reads found in cache */ |
| 480 | 	int64_t busymapped;		/* number of busy and mapped buffers */ |
| 481 | 	int64_t dmapages;		/* dma reachable pages in buffer cache */ |
| 482 | 	int64_t highpages;		/* pages above dma region */ |
| 483 | 	int64_t delwribufs;		/* delayed write buffers */ |
| 484 | 	int64_t kvaslots;		/* kva slots total */ |
| 485 | 	int64_t kvaslots_avail;		/* available kva slots */ |
| 486 | 	int64_t highflips;		/* total flips to above DMA */ |
| 487 | 	int64_t highflops;		/* total failed flips to above DMA */ |
| 488 | 	int64_t dmaflips;		/* total flips from high to DMA */ |
| 489 | }; |
| 490 | #ifdef _KERNEL |
| 491 | extern struct bcachestats bcstats; |
| 492 | extern long buflowpages, bufhighpages, bufbackpages; |
| 493 | #define BUFPAGES_DEFICIT (((buflowpages - bcstats.numbufpages) < 0) ? 0 \ |
| 494 | : buflowpages - bcstats.numbufpages) |
| 495 | #define BUFPAGES_INACT (((bcstats.numcleanpages - buflowpages) < 0) ? 0 \ |
| 496 | : bcstats.numcleanpages - buflowpages) |
| 497 | extern int bufcachepercent; |
| 498 | extern void bufadjust(int); |
| 499 | struct uvm_constraint_range; |
| 500 | extern unsigned long bufbackoff(struct uvm_constraint_range*, long); |
| 501 | |
| 502 | /* |
| 503 | * Operations supported on mounted file system. |
| 504 | */ |
| 505 | struct nameidata; |
| 506 | struct mbuf; |
| 507 | |
| 508 | extern int maxvfsconf;		/* highest defined filesystem type */ |
| 509 | |
| 510 | struct vfsops { |
| 511 | 	int	(*vfs_mount)(struct mount *mp, const char *path, |
| 512 | 				 void *data, |
| 513 | 				 struct nameidata *ndp, struct proc *p); |
| 514 | 	int	(*vfs_start)(struct mount *mp, int flags, |
| 515 | 				 struct proc *p); |
| 516 | 	int	(*vfs_unmount)(struct mount *mp, int mntflags, |
| 517 | 				 struct proc *p); |
| 518 | 	int	(*vfs_root)(struct mount *mp, struct vnode **vpp); |
| 519 | 	int	(*vfs_quotactl)(struct mount *mp, int cmds, uid_t uid, |
| 520 | 				 caddr_t arg, struct proc *p); |
| 521 | 	int	(*vfs_statfs)(struct mount *mp, struct statfs *sbp, |
| 522 | 				 struct proc *p); |
| 523 | 	int	(*vfs_sync)(struct mount *mp, int waitfor, int stall, |
| 524 | 				 struct ucred *cred, struct proc *p); |
| 525 | 	int	(*vfs_vget)(struct mount *mp, ino_t ino, |
| 526 | 				 struct vnode **vpp); |
| 527 | 	int	(*vfs_fhtovp)(struct mount *mp, struct fid *fhp, |
| 528 | 				 struct vnode **vpp); |
| 529 | 	int	(*vfs_vptofh)(struct vnode *vp, struct fid *fhp); |
| 530 | 	int	(*vfs_init)(struct vfsconf *); |
| 531 | 	int (*vfs_sysctl)(int *, u_int, void *, size_t *, void *, |
| 532 | 				 size_t, struct proc *); |
| 533 | 	int	(*vfs_checkexp)(struct mount *mp, struct mbuf *nam, |
| 534 | 				 int *extflagsp, struct ucred **credanonp); |
| 535 | }; |
| 536 | |
| 537 | #define VFS_MOUNT(MP, PATH, DATA, NDP, P) \ |
| 538 | 	(*(MP)->mnt_op->vfs_mount)(MP, PATH, DATA, NDP, P) |
| 539 | #define VFS_START(MP, FLAGS, P)	 (*(MP)->mnt_op->vfs_start)(MP, FLAGS, P) |
| 540 | #define VFS_UNMOUNT(MP, FORCE, P) (*(MP)->mnt_op->vfs_unmount)(MP, FORCE, P) |
| 541 | #define VFS_ROOT(MP, VPP)	 (*(MP)->mnt_op->vfs_root)(MP, VPP) |
| 542 | #define VFS_QUOTACTL(MP,C,U,A,P) (*(MP)->mnt_op->vfs_quotactl)(MP, C, U, A, P) |
| 543 | #define VFS_STATFS(MP, SBP, P)	 (*(MP)->mnt_op->vfs_statfs)(MP, SBP, P) |
| 544 | #define VFS_SYNC(MP, W, S, C, P) (*(MP)->mnt_op->vfs_sync)(MP, W, S, C, P) |
| 545 | #define VFS_VGET(MP, INO, VPP)	 (*(MP)->mnt_op->vfs_vget)(MP, INO, VPP) |
| 546 | #define VFS_FHTOVP(MP, FIDP, VPP) \ |
| 547 | 	(*(MP)->mnt_op->vfs_fhtovp)(MP, FIDP, VPP) |
| 548 | #define	VFS_VPTOFH(VP, FIDP)	 (*(VP)->v_mount->mnt_op->vfs_vptofh)(VP, FIDP) |
| 549 | #define VFS_CHECKEXP(MP, NAM, EXFLG, CRED) \ |
| 550 | 	(*(MP)->mnt_op->vfs_checkexp)(MP, NAM, EXFLG, CRED) |
| 551 | |
| 552 | /* Set up the filesystem operations for vnodes. */ |
| 553 | extern	const struct vfsops ffs_vfsops; |
| 554 | extern	const struct vfsops mfs_vfsops; |
| 555 | extern	const struct vfsops msdosfs_vfsops; |
| 556 | extern	const struct vfsops nfs_vfsops; |
| 557 | extern	const struct vfsops cd9660_vfsops; |
| 558 | extern	const struct vfsops ext2fs_vfsops; |
| 559 | extern	const struct vfsops ntfs_vfsops; |
| 560 | extern	const struct vfsops udf_vfsops; |
| 561 | extern	const struct vfsops fusefs_vfsops; |
| 562 | extern	const struct vfsops tmpfs_vfsops; |
| 563 | |
| 564 | #include <net/radix.h> |
| 565 | #include <sys/socket.h>		/* XXX for AF_MAX */ |
| 566 | |
| 567 | /* |
| 568 | * Network address lookup element |
| 569 | */ |
| 570 | struct netcred { |
| 571 | 	struct	radix_node netc_rnodes[2]; |
| 572 | 	int	netc_exflags; |
| 573 | 	int	netc_len;			/* size of the allocation */ |
| 574 | 	struct	ucred netc_anon; |
| 575 | }; |
| 576 | |
| 577 | /* |
| 578 | * Network export information |
| 579 | */ |
| 580 | struct netexport { |
| 581 | 	struct	netcred ne_defexported;		/* Default export */ |
| 582 | 	struct	radix_node_head *ne_rtable_inet;/* Individual exports */ |
| 583 | }; |
| 584 | |
| 585 | /* |
| 586 | * exported vnode operations |
| 587 | */ |
| 588 | int	vfs_busy(struct mount *, int); |
| 589 | #define VB_READ		0x01 |
| 590 | #define VB_WRITE	0x02 |
| 591 | #define VB_NOWAIT	0x04	/* immediately fail on busy lock */ |
| 592 | #define VB_WAIT		0x08	/* sleep fail on busy lock */ |
| 593 | #define VB_DUPOK	0x10	/* permit duplicate mount busying */ |
| 594 | |
| 595 | int vfs_isbusy(struct mount *); |
| 596 | struct	mount *vfs_mount_alloc(struct vnode *, struct vfsconf *); |
| 597 | void	vfs_mount_free(struct mount *); |
| 598 | int vfs_mount_foreach_vnode(struct mount *, int (*func)(struct vnode *, |
| 599 | 				 void *), void *); |
| 600 | void	vfs_getnewfsid(struct mount *); |
| 601 | struct	mount *vfs_getvfs(fsid_t *); |
| 602 | int	vfs_mountedon(struct vnode *); |
| 603 | int	vfs_rootmountalloc(char *, char *, struct mount **); |
| 604 | void	vfs_unbusy(struct mount *); |
| 605 | extern	TAILQ_HEAD(mntlist, mount) mountlist; |
| 606 | int	vfs_stall(struct proc *, int); |
| 607 | void	vfs_stall_barrier(void); |
| 608 | |
| 609 | 					 /* process mount export info */ |
| 610 | int	vfs_export(struct mount *, struct netexport *, struct export_args *); |
| 611 | 					 /* lookup host in fs export list */ |
| 612 | struct	netcred *vfs_export_lookup(struct mount *, struct netexport *, |
| 613 | 	 struct mbuf *); |
| 614 | int	vfs_allocate_syncvnode(struct mount *); |
| 615 | |
| 616 | int	vfs_syncwait(struct proc *, int); /* sync and wait for complete */ |
| 617 | void	vfs_shutdown(struct proc *);	 /* unmount and sync file systems */ |
| 618 | int	dounmount(struct mount *, int, struct proc *); |
| 619 | void	vfsinit(void); |
| 620 | struct	vfsconf *vfs_byname(const char *); |
| 621 | struct	vfsconf *vfs_bytypenum(int); |
| 622 | #else /* _KERNEL */ |
| 623 | __BEGIN_DECLS |
| 624 | int	fstatfs(int, struct statfs *); |
| 625 | int	getfh(const char *, fhandle_t *); |
| 626 | int	getfsstat(struct statfs *, size_t, int); |
| 627 | int	getmntinfo(struct statfs **, int); |
| 628 | int	mount(const char *, const char *, int, void *); |
| 629 | int	statfs(const char *, struct statfs *); |
| 630 | int	unmount(const char *, int); |
| 631 | #if __BSD_VISIBLE |
| 632 | struct stat; |
| 633 | int	fhopen(const fhandle_t *, int); |
| 634 | int	fhstat(const fhandle_t *, struct stat *); |
| 635 | int	fhstatfs(const fhandle_t *, struct statfs *); |
| 636 | #endif /* __BSD_VISIBLE */ |
| 637 | __END_DECLS |
| 638 | #endif /* _KERNEL */ |
| 639 | #endif /* !_SYS_MOUNT_H_ */ |