xref: /illumos-gate/usr/src/uts/common/sys/vfs.h (revision 4b5c8e93cab28d3c65ba9d407fd8f46e3be1db1c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
24  * Copyright 2016 Toomas Soome <tsoome@me.com>
25  */
26 
27 /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 /*
31  * Portions of this source code were derived from Berkeley 4.3 BSD
32  * under license from the Regents of the University of California.
33  */
34 
35 #ifndef _SYS_VFS_H
36 #define	_SYS_VFS_H
37 
38 #include <sys/zone.h>
39 #include <sys/types.h>
40 #include <sys/t_lock.h>
41 #include <sys/cred.h>
42 #include <sys/vnode.h>
43 #include <sys/statvfs.h>
44 #include <sys/refstr.h>
45 #include <sys/avl.h>
46 #include <sys/time.h>
47 
48 #ifdef	__cplusplus
49 extern "C" {
50 #endif
51 
52 /*
53  * Data associated with mounted file systems.
54  */
55 
56 /*
57  * Operations vector.  This is used internal to the kernel; file systems
58  * supply their list of operations via vfs_setfsops().
59  */
60 
61 typedef struct vfsops vfsops_t;
62 
63 /*
64  * File system identifier. Should be unique (at least per machine).
65  */
66 typedef struct {
67 	int val[2];			/* file system id type */
68 } fsid_t;
69 
70 /*
71  * File identifier.  Should be unique per filesystem on a single
72  * machine.  This is typically called by a stateless file server
73  * in order to generate "file handles".
74  *
75  * Many underlying file systems cast a struct fid into other
76  * file system dependent structures which may require 4 byte alignment.
77  * Because a fid starts with a short it may not be 4 byte aligned, the
78  * fid_pad will force the alignment.
79  */
80 #define	MAXFIDSZ	64
81 #define	OLD_MAXFIDSZ	16
82 
83 typedef struct fid {
84 	union {
85 		long fid_pad;
86 		struct {
87 			ushort_t len;	/* length of data in bytes */
88 			char	data[MAXFIDSZ]; /* data (variable len) */
89 		} _fid;
90 	} un;
91 } fid_t;
92 
93 #ifdef _SYSCALL32
94 /*
95  * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk
96  * struct compatibility.
97  */
98 typedef struct fid32 {
99 	union {
100 		int32_t fid_pad;
101 		struct {
102 			uint16_t  len;   /* length of data in bytes */
103 			char    data[MAXFIDSZ]; /* data (variable len) */
104 		} _fid;
105 	} un;
106 } fid32_t;
107 #else /* not _SYSCALL32 */
108 #define	fid32	fid
109 typedef fid_t	fid32_t;
110 #endif /* _SYSCALL32 */
111 
112 #define	fid_len		un._fid.len
113 #define	fid_data	un._fid.data
114 
115 /*
116  * Structure defining a mount option for a filesystem.
117  * option names are found in mntent.h
118  */
119 typedef struct mntopt {
120 	char	*mo_name;	/* option name */
121 	char	**mo_cancel;	/* list of options cancelled by this one */
122 	char	*mo_arg;	/* argument string for this option */
123 	int	mo_flags;	/* flags for this mount option */
124 	void	*mo_data;	/* filesystem specific data */
125 } mntopt_t;
126 
127 /*
128  * Flags that apply to mount options
129  */
130 
131 #define	MO_SET		0x01		/* option is set */
132 #define	MO_NODISPLAY	0x02		/* option not listed in mnttab */
133 #define	MO_HASVALUE	0x04		/* option takes a value */
134 #define	MO_IGNORE	0x08		/* option ignored by parser */
135 #define	MO_DEFAULT	MO_SET		/* option is on by default */
136 #define	MO_TAG		0x10		/* flags a tag set by user program */
137 #define	MO_EMPTY	0x20		/* empty space in option table */
138 
139 #define	VFS_NOFORCEOPT	0x01		/* honor MO_IGNORE (don't set option) */
140 #define	VFS_DISPLAY	0x02		/* Turn off MO_NODISPLAY bit for opt */
141 #define	VFS_NODISPLAY	0x04		/* Turn on MO_NODISPLAY bit for opt */
142 #define	VFS_CREATEOPT	0x08		/* Create the opt if it's not there */
143 
144 /*
145  * Structure holding mount option strings for the mounted file system.
146  */
147 typedef struct mntopts {
148 	uint_t		mo_count;		/* number of entries in table */
149 	mntopt_t	*mo_list;		/* list of mount options */
150 } mntopts_t;
151 
152 /*
153  * The kstat structures associated with the vopstats are kept in an
154  * AVL tree.  This is to avoid the case where a file system does not
155  * use a unique fsid_t for each vfs (e.g., namefs).  In order to do
156  * this, we need a structure that the AVL tree can use that also
157  * references the kstat.
158  * Note that the vks_fsid is generated from the value reported by
159  * VFS_STATVFS().
160  */
161 typedef struct vskstat_anchor {
162 	avl_node_t	vsk_node;	/* Required for use by AVL routines */
163 	kstat_t		*vsk_ksp;	/* kstat structure for vopstats */
164 	ulong_t		vsk_fsid;	/* fsid associated w/this FS */
165 } vsk_anchor_t;
166 
167 extern avl_tree_t	vskstat_tree;
168 extern kmutex_t		vskstat_tree_lock;
169 
170 /*
171  * Structure per mounted file system.  Each mounted file system has
172  * an array of operations and an instance record.
173  *
174  * The file systems are kept on a doubly linked circular list headed by
175  * "rootvfs".
176  * File system implementations should not access this list;
177  * it's intended for use only in the kernel's vfs layer.
178  *
179  * Each zone also has its own list of mounts, containing filesystems mounted
180  * somewhere within the filesystem tree rooted at the zone's rootpath.  The
181  * list is doubly linked to match the global list.
182  *
183  * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and
184  * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that
185  * are set at mount time and can only be modified during a remount.
186  * It is safe to read these fields if you can prevent a remount on the vfs,
187  * or through the convenience funcs vfs_getmntpoint() and vfs_getresource().
188  * The mntopts field may only be accessed through the provided convenience
189  * functions, as it is protected by the vfs list lock. Modifying a mount
190  * option requires grabbing the vfs list write lock, which can be a very
191  * high latency lock.
192  */
193 struct zone;		/* from zone.h */
194 struct fem_head;	/* from fem.h */
195 
196 typedef struct vfs {
197 	struct vfs	*vfs_next;		/* next VFS in VFS list */
198 	struct vfs	*vfs_prev;		/* prev VFS in VFS list */
199 
200 /* vfs_op should not be used directly.  Accessor functions are provided */
201 	vfsops_t	*vfs_op;		/* operations on VFS */
202 
203 	struct vnode	*vfs_vnodecovered;	/* vnode mounted on */
204 	uint_t		vfs_flag;		/* flags */
205 	uint_t		vfs_bsize;		/* native block size */
206 	int		vfs_fstype;		/* file system type index */
207 	fsid_t		vfs_fsid;		/* file system id */
208 	void		*vfs_data;		/* private data */
209 	dev_t		vfs_dev;		/* device of mounted VFS */
210 	ulong_t		vfs_bcount;		/* I/O count (accounting) */
211 	struct vfs	*vfs_list;		/* sync list pointer */
212 	struct vfs	*vfs_hash;		/* hash list pointer */
213 	ksema_t		vfs_reflock;		/* mount/unmount/sync lock */
214 	uint_t		vfs_count;		/* vfs reference count */
215 	mntopts_t	vfs_mntopts;		/* options mounted with */
216 	refstr_t	*vfs_resource;		/* mounted resource name */
217 	refstr_t	*vfs_mntpt;		/* mount point name */
218 	time_t		vfs_mtime;		/* time we were mounted */
219 	struct vfs_impl	*vfs_implp;		/* impl specific data */
220 	/*
221 	 * Zones support.  Note that the zone that "owns" the mount isn't
222 	 * necessarily the same as the zone in which the zone is visible.
223 	 * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to
224 	 * different zones.
225 	 */
226 	struct zone	*vfs_zone;		/* zone that owns the mount */
227 	struct vfs	*vfs_zone_next;		/* next VFS visible in zone */
228 	struct vfs	*vfs_zone_prev;		/* prev VFS visible in zone */
229 
230 	struct fem_head	*vfs_femhead;		/* fs monitoring */
231 	uint32_t	vfs_lofi_id;		/* ID if lofi mount */
232 } vfs_t;
233 
234 #define	vfs_featureset	vfs_implp->vi_featureset
235 #define	vfs_vskap	vfs_implp->vi_vskap
236 #define	vfs_fstypevsp	vfs_implp->vi_fstypevsp
237 #define	vfs_vopstats	vfs_implp->vi_vopstats
238 #define	vfs_hrctime	vfs_implp->vi_hrctime
239 
240 /*
241  * VFS flags.
242  */
243 #define	VFS_RDONLY	0x01		/* read-only vfs */
244 #define	VFS_NOMNTTAB	0x02		/* vfs not seen in mnttab */
245 #define	VFS_NOSETUID	0x08		/* setuid disallowed */
246 #define	VFS_REMOUNT	0x10		/* modify mount options only */
247 #define	VFS_NOTRUNC	0x20		/* does not truncate long file names */
248 #define	VFS_UNLINKABLE	0x40		/* unlink(2) can be applied to root */
249 #define	VFS_PXFS	0x80		/* clustering: global fs proxy vfs */
250 #define	VFS_UNMOUNTED	0x100		/* file system has been unmounted */
251 #define	VFS_NBMAND	0x200		/* allow non-blocking mandatory locks */
252 #define	VFS_XATTR	0x400		/* fs supports extended attributes */
253 #define	VFS_NODEVICES	0x800		/* device-special files disallowed */
254 #define	VFS_NOEXEC	0x1000		/* executables disallowed */
255 #define	VFS_STATS	0x2000		/* file system can collect stats */
256 #define	VFS_XID		0x4000		/* file system supports extended ids */
257 
258 #define	VFS_NORESOURCE	"unspecified_resource"
259 #define	VFS_NOMNTPT	"unspecified_mountpoint"
260 
261 /*
262  * VFS features are implemented as bits set in the vfs_t.
263  * The vfs_feature_t typedef is a 64-bit number that will translate
264  * into an element in an array of bitmaps and a bit in that element.
265  * Developers must not depend on the implementation of this and
266  * need to use vfs_has_feature()/vfs_set_feature() routines.
267  */
268 typedef	uint64_t	vfs_feature_t;
269 
270 #define	VFSFT_XVATTR		0x100000001	/* Supports xvattr for attrs */
271 #define	VFSFT_CASEINSENSITIVE	0x100000002	/* Supports case-insensitive */
272 #define	VFSFT_NOCASESENSITIVE	0x100000004	/* NOT case-sensitive */
273 #define	VFSFT_DIRENTFLAGS	0x100000008	/* Supports dirent flags */
274 #define	VFSFT_ACLONCREATE	0x100000010	/* Supports ACL on create */
275 #define	VFSFT_ACEMASKONACCESS	0x100000020	/* Can use ACEMASK for access */
276 #define	VFSFT_SYSATTR_VIEWS	0x100000040	/* Supports sysattr view i/f */
277 #define	VFSFT_ACCESS_FILTER	0x100000080	/* dirents filtered by access */
278 #define	VFSFT_REPARSE		0x100000100	/* Supports reparse point */
279 #define	VFSFT_ZEROCOPY_SUPPORTED	0x100000200
280 				/* Support loaning /returning cache buffer */
281 /*
282  * Argument structure for mount(2).
283  *
284  * Flags are defined in <sys/mount.h>.
285  *
286  * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
287  * this structure are to be interpreted as kernel addresses.  File systems
288  * should be prepared for this possibility.
289  */
290 struct mounta {
291 	char	*spec;
292 	char	*dir;
293 	int	flags;
294 	char	*fstype;
295 	char	*dataptr;
296 	int	datalen;
297 	char	*optptr;
298 	int	optlen;
299 };
300 
301 /*
302  * Reasons for calling the vfs_mountroot() operation.
303  */
304 enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT};
305 typedef enum whymountroot whymountroot_t;
306 
307 /*
308  * Reasons for calling the VFS_VNSTATE():
309  */
310 enum vntrans {
311 	VNTRANS_EXISTS,
312 	VNTRANS_IDLED,
313 	VNTRANS_RECLAIMED,
314 	VNTRANS_DESTROYED
315 };
316 typedef enum vntrans vntrans_t;
317 
318 /*
319  * VFS_OPS defines all the vfs operations.  It is used to define
320  * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
321  */
322 #define	VFS_OPS								\
323 	int	(*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \
324 	int	(*vfs_unmount)(vfs_t *, int, cred_t *);			\
325 	int	(*vfs_root)(vfs_t *, vnode_t **);			\
326 	int	(*vfs_statvfs)(vfs_t *, statvfs64_t *);			\
327 	int	(*vfs_sync)(vfs_t *, short, cred_t *);			\
328 	int	(*vfs_vget)(vfs_t *, vnode_t **, fid_t *);		\
329 	int	(*vfs_mountroot)(vfs_t *, enum whymountroot);		\
330 	void	(*vfs_freevfs)(vfs_t *);				\
331 	int	(*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t)	/* NB: No ";" */
332 
333 /*
334  * Operations supported on virtual file system.
335  */
336 struct vfsops {
337 	VFS_OPS;	/* Signature of all vfs operations (vfsops) */
338 };
339 
340 extern int	fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *);
341 extern int	fsop_unmount(vfs_t *, int, cred_t *);
342 extern int	fsop_root(vfs_t *, vnode_t **);
343 extern int	fsop_statfs(vfs_t *, statvfs64_t *);
344 extern int	fsop_sync(vfs_t *, short, cred_t *);
345 extern int	fsop_vget(vfs_t *, vnode_t **, fid_t *);
346 extern int	fsop_mountroot(vfs_t *, enum whymountroot);
347 extern void	fsop_freefs(vfs_t *);
348 extern int	fsop_sync_by_kind(int, short, cred_t *);
349 extern int	fsop_vnstate(vfs_t *, vnode_t *, vntrans_t);
350 
351 #define	VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr)
352 #define	VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr)
353 #define	VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp)
354 #define	VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp)
355 #define	VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr)
356 #define	VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp)
357 #define	VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init)
358 #define	VFS_FREEVFS(vfsp) fsop_freefs(vfsp)
359 #define	VFS_VNSTATE(vfsp, vn, ns)	fsop_vnstate(vfsp, vn, ns)
360 
361 #define	VFSNAME_MOUNT		"mount"
362 #define	VFSNAME_UNMOUNT		"unmount"
363 #define	VFSNAME_ROOT		"root"
364 #define	VFSNAME_STATVFS		"statvfs"
365 #define	VFSNAME_SYNC		"sync"
366 #define	VFSNAME_VGET		"vget"
367 #define	VFSNAME_MOUNTROOT	"mountroot"
368 #define	VFSNAME_FREEVFS		"freevfs"
369 #define	VFSNAME_VNSTATE		"vnstate"
370 /*
371  * Filesystem type switch table.
372  */
373 
374 typedef struct vfssw {
375 	char		*vsw_name;	/* type name -- max len _ST_FSTYPSZ */
376 	int		(*vsw_init) (int, char *);
377 				/* init routine (for non-loadable fs only) */
378 	int		vsw_flag;	/* flags */
379 	mntopts_t	vsw_optproto;	/* mount options table prototype */
380 	uint_t		vsw_count;	/* count of references */
381 	kmutex_t	vsw_lock;	/* lock to protect vsw_count */
382 	vfsops_t	vsw_vfsops;	/* filesystem operations vector */
383 } vfssw_t;
384 
385 /*
386  * Filesystem type definition record.  All file systems must export a record
387  * of this type through their modlfs structure.  N.B., changing the version
388  * number requires a change in sys/modctl.h.
389  */
390 
391 typedef struct vfsdef_v5 {
392 	int		def_version;	/* structure version, must be first */
393 	char		*name;		/* filesystem type name */
394 	int		(*init) (int, char *);	/* init routine */
395 	int		flags;		/* filesystem flags */
396 	mntopts_t	*optproto;	/* mount options table prototype */
397 } vfsdef_v5;
398 
399 typedef struct vfsdef_v5 vfsdef_t;
400 
401 enum {
402 	VFSDEF_VERSION = 5
403 };
404 
405 /*
406  * flags for vfssw and vfsdef
407  */
408 #define	VSW_HASPROTO	0x01	/* struct has a mount options prototype */
409 #define	VSW_CANRWRO	0x02	/* file system can transition from rw to ro */
410 #define	VSW_CANREMOUNT	0x04	/* file system supports remounts */
411 #define	VSW_NOTZONESAFE	0x08	/* zone_enter(2) should fail for these files */
412 #define	VSW_VOLATILEDEV	0x10	/* vfs_dev can change each time fs is mounted */
413 #define	VSW_STATS	0x20	/* file system can collect stats */
414 #define	VSW_XID		0x40	/* file system supports extended ids */
415 #define	VSW_CANLOFI	0x80	/* file system supports lofi mounts */
416 #define	VSW_ZMOUNT	0x100	/* file system always allowed in a zone */
417 
418 #define	VSW_INSTALLED	0x8000	/* this vsw is associated with a file system */
419 
420 /*
421  * A flag for vfs_setpath().
422  */
423 #define	VFSSP_VERBATIM	0x1	/* do not prefix the supplied path */
424 
425 #if defined(_KERNEL) || defined(_FAKE_KERNEL)
426 
427 /*
428  * Private vfs data, NOT to be used by a file system implementation.
429  */
430 
431 #define	VFS_FEATURE_MAXSZ	4
432 
433 typedef struct vfs_impl {
434 	/* Counted array - Bitmap of vfs features */
435 	uint32_t	vi_featureset[VFS_FEATURE_MAXSZ];
436 	/*
437 	 * Support for statistics on the vnode operations
438 	 */
439 	vsk_anchor_t	*vi_vskap;		/* anchor for vopstats' kstat */
440 	vopstats_t	*vi_fstypevsp;		/* ptr to per-fstype vopstats */
441 	vopstats_t	vi_vopstats;		/* per-mount vnode op stats */
442 
443 	timespec_t	vi_hrctime; 		/* High-res creation time */
444 
445 	zone_ref_t	vi_zone_ref;		/* reference to zone */
446 } vfs_impl_t;
447 
448 /*
449  * Public operations.
450  */
451 struct umounta;
452 struct statvfsa;
453 struct fstatvfsa;
454 
455 void	vfs_freevfsops(vfsops_t *);
456 int	vfs_freevfsops_by_type(int);
457 void	vfs_setops(vfs_t *, vfsops_t *);
458 vfsops_t *vfs_getops(vfs_t *vfsp);
459 int	vfs_matchops(vfs_t *, vfsops_t *);
460 int	vfs_can_sync(vfs_t *vfsp);
461 vfs_t	*vfs_alloc(int);
462 void	vfs_free(vfs_t *);
463 void	vfs_init(vfs_t *vfsp, vfsops_t *, void *);
464 void	vfsimpl_setup(vfs_t *vfsp);
465 void	vfsimpl_teardown(vfs_t *vfsp);
466 void	vn_exists(vnode_t *);
467 void	vn_idle(vnode_t *);
468 void	vn_reclaim(vnode_t *);
469 void	vn_invalid(vnode_t *);
470 
471 int	rootconf(void);
472 int	svm_rootconf(void);
473 int	domount(char *, struct mounta *, vnode_t *, struct cred *,
474 	    struct vfs **);
475 int	dounmount(struct vfs *, int, cred_t *);
476 int	vfs_lock(struct vfs *);
477 int	vfs_rlock(struct vfs *);
478 void	vfs_lock_wait(struct vfs *);
479 void	vfs_rlock_wait(struct vfs *);
480 void	vfs_unlock(struct vfs *);
481 int	vfs_lock_held(struct vfs *);
482 struct	_kthread *vfs_lock_owner(struct vfs *);
483 void	sync(void);
484 void	vfs_sync(int);
485 void	vfs_mountroot(void);
486 void	vfs_add(vnode_t *, struct vfs *, int);
487 void	vfs_remove(struct vfs *);
488 
489 /* VFS feature routines */
490 void	vfs_set_feature(vfs_t *, vfs_feature_t);
491 void	vfs_clear_feature(vfs_t *, vfs_feature_t);
492 int	vfs_has_feature(vfs_t *, vfs_feature_t);
493 void	vfs_propagate_features(vfs_t *, vfs_t *);
494 
495 /* The following functions are not for general use by filesystems */
496 
497 void	vfs_createopttbl(mntopts_t *, const char *);
498 void	vfs_copyopttbl(const mntopts_t *, mntopts_t *);
499 void	vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *);
500 void	vfs_freeopttbl(mntopts_t *);
501 void	vfs_parsemntopts(mntopts_t *, char *, int);
502 int	vfs_buildoptionstr(const mntopts_t *, char *, int);
503 struct mntopt *vfs_hasopt(const mntopts_t *, const char *);
504 void	vfs_mnttab_modtimeupd(void);
505 
506 void	vfs_clearmntopt(struct vfs *, const char *);
507 void	vfs_setmntopt(struct vfs *, const char *, const char *, int);
508 void	vfs_setresource(struct vfs *, const char *, uint32_t);
509 void	vfs_setmntpoint(struct vfs *, const char *, uint32_t);
510 refstr_t *vfs_getresource(const struct vfs *);
511 refstr_t *vfs_getmntpoint(const struct vfs *);
512 int	vfs_optionisset(const struct vfs *, const char *, char **);
513 int	vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *);
514 int	vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *);
515 void	vfs_syncall(void);
516 void	vfs_syncprogress(void);
517 void	vfsinit(void);
518 void	vfs_unmountall(void);
519 void	vfs_make_fsid(fsid_t *, dev_t, int);
520 void	vfs_addmip(dev_t, struct vfs *);
521 void	vfs_delmip(struct vfs *);
522 int	vfs_devismounted(dev_t);
523 int	vfs_devmounting(dev_t, struct vfs *);
524 int	vfs_opsinuse(vfsops_t *);
525 struct vfs *getvfs(fsid_t *);
526 struct vfs *vfs_dev2vfsp(dev_t);
527 struct vfs *vfs_mntpoint2vfsp(const char *);
528 struct vfssw *allocate_vfssw(const char *);
529 struct vfssw *vfs_getvfssw(const char *);
530 struct vfssw *vfs_getvfsswbyname(const char *);
531 struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *);
532 void	vfs_refvfssw(struct vfssw *);
533 void	vfs_unrefvfssw(struct vfssw *);
534 uint_t	vf_to_stf(uint_t);
535 void	vfs_mnttab_modtime(timespec_t *);
536 void	vfs_mnttab_poll(timespec_t *, struct pollhead **);
537 
538 void	vfs_list_lock(void);
539 void	vfs_list_read_lock(void);
540 void	vfs_list_unlock(void);
541 void	vfs_list_add(struct vfs *);
542 void	vfs_list_remove(struct vfs *);
543 void	vfs_hold(vfs_t *vfsp);
544 void	vfs_rele(vfs_t *vfsp);
545 void	fs_freevfs(vfs_t *);
546 void	vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype);
547 
548 int	vfs_zone_change_safe(vfs_t *);
549 
550 int	vfs_get_lofi(vfs_t *, vnode_t **);
551 
552 #define	VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1))
553 #define	VFS_ON_LIST(vfsp) \
554 	((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL)
555 
556 /*
557  * Globals.
558  */
559 
560 extern struct vfssw vfssw[];		/* table of filesystem types */
561 extern krwlock_t vfssw_lock;
562 extern char rootfstype[];		/* name of root fstype */
563 extern const int nfstype;		/* # of elements in vfssw array */
564 extern vfsops_t *EIO_vfsops;		/* operations for vfs being torn-down */
565 
566 /*
567  * The following variables are private to the the kernel's vfs layer.  File
568  * system implementations should not access them.
569  */
570 extern struct vfs *rootvfs;		/* ptr to root vfs structure */
571 typedef struct {
572 	struct vfs *rvfs_head;		/* head vfs in chain */
573 	kmutex_t rvfs_lock;		/* mutex protecting this chain */
574 	uint32_t rvfs_len;		/* length of this chain */
575 } rvfs_t;
576 extern rvfs_t *rvfs_list;
577 extern int vfshsz;			/* # of elements in rvfs_head array */
578 extern const mntopts_t vfs_mntopts;	/* globally recognized options */
579 
580 #endif /* defined(_KERNEL) */
581 
582 #define	VFS_HOLD(vfsp) { \
583 	vfs_hold(vfsp); \
584 }
585 
586 #define	VFS_RELE(vfsp)	{ \
587 	vfs_rele(vfsp); \
588 }
589 
590 #define	VFS_INIT(vfsp, op, data) { \
591 	vfs_init((vfsp), (op), (data)); \
592 }
593 
594 
595 #define	VFS_INSTALLED(vfsswp)	(((vfsswp)->vsw_flag & VSW_INSTALLED) != 0)
596 #define	ALLOCATED_VFSSW(vswp)		((vswp)->vsw_name[0] != '\0')
597 #define	RLOCK_VFSSW()			(rw_enter(&vfssw_lock, RW_READER))
598 #define	RUNLOCK_VFSSW()			(rw_exit(&vfssw_lock))
599 #define	WLOCK_VFSSW()			(rw_enter(&vfssw_lock, RW_WRITER))
600 #define	WUNLOCK_VFSSW()			(rw_exit(&vfssw_lock))
601 #define	VFSSW_LOCKED()			(RW_LOCK_HELD(&vfssw_lock))
602 #define	VFSSW_WRITE_LOCKED()		(RW_WRITE_HELD(&vfssw_lock))
603 /*
604  * VFS_SYNC flags.
605  */
606 #define	SYNC_ATTR	0x01		/* sync attributes only */
607 #define	SYNC_CLOSE	0x02		/* close open file */
608 #define	SYNC_ALL	0x04		/* force to sync all fs */
609 
610 #ifdef	__cplusplus
611 }
612 #endif
613 
614 #endif	/* _SYS_VFS_H */
615