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