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