xref: /titanic_44/usr/src/uts/common/sys/vfs.h (revision 22ca5eba2a84a9612aa439c234327fda99608f01)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55a59a8b3Srsb  * Common Development and Distribution License (the "License").
65a59a8b3Srsb  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
21*22ca5ebaSYuri Pankov 
227c478bd9Sstevel@tonic-gate /*
230fbb751dSJohn Levon  * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24*22ca5ebaSYuri Pankov  * Copyright 2016 Nexenta Systems, Inc.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
327c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef _SYS_VFS_H
367c478bd9Sstevel@tonic-gate #define	_SYS_VFS_H
377c478bd9Sstevel@tonic-gate 
38a19609f8Sjv227347 #include <sys/zone.h>
397c478bd9Sstevel@tonic-gate #include <sys/types.h>
407c478bd9Sstevel@tonic-gate #include <sys/t_lock.h>
417c478bd9Sstevel@tonic-gate #include <sys/cred.h>
427c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
437c478bd9Sstevel@tonic-gate #include <sys/statvfs.h>
447c478bd9Sstevel@tonic-gate #include <sys/refstr.h>
45ddfcde86Srsb #include <sys/avl.h>
46835ee219SRobert Harris #include <sys/time.h>
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
497c478bd9Sstevel@tonic-gate extern "C" {
507c478bd9Sstevel@tonic-gate #endif
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * Data associated with mounted file systems.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate /*
577c478bd9Sstevel@tonic-gate  * Operations vector.  This is used internal to the kernel; file systems
587c478bd9Sstevel@tonic-gate  * supply their list of operations via vfs_setfsops().
597c478bd9Sstevel@tonic-gate  */
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate typedef struct vfsops vfsops_t;
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate /*
647c478bd9Sstevel@tonic-gate  * File system identifier. Should be unique (at least per machine).
657c478bd9Sstevel@tonic-gate  */
667c478bd9Sstevel@tonic-gate typedef struct {
677c478bd9Sstevel@tonic-gate 	int val[2];			/* file system id type */
687c478bd9Sstevel@tonic-gate } fsid_t;
697c478bd9Sstevel@tonic-gate 
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate  * File identifier.  Should be unique per filesystem on a single
727c478bd9Sstevel@tonic-gate  * machine.  This is typically called by a stateless file server
737c478bd9Sstevel@tonic-gate  * in order to generate "file handles".
747c478bd9Sstevel@tonic-gate  *
757c478bd9Sstevel@tonic-gate  * Do not change the definition of struct fid ... fid_t without
767c478bd9Sstevel@tonic-gate  * letting the CacheFS group know about it!  They will have to do at
777c478bd9Sstevel@tonic-gate  * least two things, in the same change that changes this structure:
787c478bd9Sstevel@tonic-gate  *   1. change CFSVERSION in usr/src/uts/common/sys/fs/cachefs_fs.h
797c478bd9Sstevel@tonic-gate  *   2. put the old version # in the canupgrade array
807c478bd9Sstevel@tonic-gate  *	in cachfs_upgrade() in usr/src/cmd/fs.d/cachefs/fsck/fsck.c
817c478bd9Sstevel@tonic-gate  * This is necessary because CacheFS stores FIDs on disk.
827c478bd9Sstevel@tonic-gate  *
837c478bd9Sstevel@tonic-gate  * Many underlying file systems cast a struct fid into other
847c478bd9Sstevel@tonic-gate  * file system dependent structures which may require 4 byte alignment.
857c478bd9Sstevel@tonic-gate  * Because a fid starts with a short it may not be 4 byte aligned, the
867c478bd9Sstevel@tonic-gate  * fid_pad will force the alignment.
877c478bd9Sstevel@tonic-gate  */
887c478bd9Sstevel@tonic-gate #define	MAXFIDSZ	64
897c478bd9Sstevel@tonic-gate #define	OLD_MAXFIDSZ	16
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate typedef struct fid {
927c478bd9Sstevel@tonic-gate 	union {
937c478bd9Sstevel@tonic-gate 		long fid_pad;
947c478bd9Sstevel@tonic-gate 		struct {
957c478bd9Sstevel@tonic-gate 			ushort_t len;	/* length of data in bytes */
967c478bd9Sstevel@tonic-gate 			char	data[MAXFIDSZ]; /* data (variable len) */
977c478bd9Sstevel@tonic-gate 		} _fid;
987c478bd9Sstevel@tonic-gate 	} un;
997c478bd9Sstevel@tonic-gate } fid_t;
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk
1047c478bd9Sstevel@tonic-gate  * struct compatibility.
1057c478bd9Sstevel@tonic-gate  */
1067c478bd9Sstevel@tonic-gate typedef struct fid32 {
1077c478bd9Sstevel@tonic-gate 	union {
1087c478bd9Sstevel@tonic-gate 		int32_t fid_pad;
1097c478bd9Sstevel@tonic-gate 		struct {
1107c478bd9Sstevel@tonic-gate 			uint16_t  len;   /* length of data in bytes */
1117c478bd9Sstevel@tonic-gate 			char    data[MAXFIDSZ]; /* data (variable len) */
1127c478bd9Sstevel@tonic-gate 		} _fid;
1137c478bd9Sstevel@tonic-gate 	} un;
1147c478bd9Sstevel@tonic-gate } fid32_t;
1157c478bd9Sstevel@tonic-gate #else /* not _SYSCALL32 */
1167c478bd9Sstevel@tonic-gate #define	fid32	fid
1177c478bd9Sstevel@tonic-gate typedef fid_t	fid32_t;
1187c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate #define	fid_len		un._fid.len
1217c478bd9Sstevel@tonic-gate #define	fid_data	un._fid.data
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate /*
1247c478bd9Sstevel@tonic-gate  * Structure defining a mount option for a filesystem.
1257c478bd9Sstevel@tonic-gate  * option names are found in mntent.h
1267c478bd9Sstevel@tonic-gate  */
1277c478bd9Sstevel@tonic-gate typedef struct mntopt {
1287c478bd9Sstevel@tonic-gate 	char	*mo_name;	/* option name */
1297c478bd9Sstevel@tonic-gate 	char	**mo_cancel;	/* list of options cancelled by this one */
1307c478bd9Sstevel@tonic-gate 	char	*mo_arg;	/* argument string for this option */
1317c478bd9Sstevel@tonic-gate 	int	mo_flags;	/* flags for this mount option */
1327c478bd9Sstevel@tonic-gate 	void	*mo_data;	/* filesystem specific data */
1337c478bd9Sstevel@tonic-gate } mntopt_t;
1347c478bd9Sstevel@tonic-gate 
1357c478bd9Sstevel@tonic-gate /*
1367c478bd9Sstevel@tonic-gate  * Flags that apply to mount options
1377c478bd9Sstevel@tonic-gate  */
1387c478bd9Sstevel@tonic-gate 
1397c478bd9Sstevel@tonic-gate #define	MO_SET		0x01		/* option is set */
1407c478bd9Sstevel@tonic-gate #define	MO_NODISPLAY	0x02		/* option not listed in mnttab */
1417c478bd9Sstevel@tonic-gate #define	MO_HASVALUE	0x04		/* option takes a value */
1427c478bd9Sstevel@tonic-gate #define	MO_IGNORE	0x08		/* option ignored by parser */
1437c478bd9Sstevel@tonic-gate #define	MO_DEFAULT	MO_SET		/* option is on by default */
1447c478bd9Sstevel@tonic-gate #define	MO_TAG		0x10		/* flags a tag set by user program */
1457c478bd9Sstevel@tonic-gate #define	MO_EMPTY	0x20		/* empty space in option table */
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate #define	VFS_NOFORCEOPT	0x01		/* honor MO_IGNORE (don't set option) */
1487c478bd9Sstevel@tonic-gate #define	VFS_DISPLAY	0x02		/* Turn off MO_NODISPLAY bit for opt */
1497c478bd9Sstevel@tonic-gate #define	VFS_NODISPLAY	0x04		/* Turn on MO_NODISPLAY bit for opt */
1507c478bd9Sstevel@tonic-gate #define	VFS_CREATEOPT	0x08		/* Create the opt if it's not there */
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate /*
1537c478bd9Sstevel@tonic-gate  * Structure holding mount option strings for the mounted file system.
1547c478bd9Sstevel@tonic-gate  */
1557c478bd9Sstevel@tonic-gate typedef struct mntopts {
1567c478bd9Sstevel@tonic-gate 	uint_t		mo_count;		/* number of entries in table */
1577c478bd9Sstevel@tonic-gate 	mntopt_t	*mo_list;		/* list of mount options */
1587c478bd9Sstevel@tonic-gate } mntopts_t;
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate /*
1615a59a8b3Srsb  * The kstat structures associated with the vopstats are kept in an
1625a59a8b3Srsb  * AVL tree.  This is to avoid the case where a file system does not
1635a59a8b3Srsb  * use a unique fsid_t for each vfs (e.g., namefs).  In order to do
1645a59a8b3Srsb  * this, we need a structure that the AVL tree can use that also
1655a59a8b3Srsb  * references the kstat.
1665a59a8b3Srsb  * Note that the vks_fsid is generated from the value reported by
1675a59a8b3Srsb  * VFS_STATVFS().
1685a59a8b3Srsb  */
1695a59a8b3Srsb typedef struct vskstat_anchor {
1705a59a8b3Srsb 	avl_node_t	vsk_node;	/* Required for use by AVL routines */
1715a59a8b3Srsb 	kstat_t		*vsk_ksp;	/* kstat structure for vopstats */
1725a59a8b3Srsb 	ulong_t		vsk_fsid;	/* fsid associated w/this FS */
1735a59a8b3Srsb } vsk_anchor_t;
1745a59a8b3Srsb 
1755a59a8b3Srsb extern avl_tree_t	vskstat_tree;
1765a59a8b3Srsb extern kmutex_t		vskstat_tree_lock;
1775a59a8b3Srsb 
1785a59a8b3Srsb /*
1797c478bd9Sstevel@tonic-gate  * Structure per mounted file system.  Each mounted file system has
1807c478bd9Sstevel@tonic-gate  * an array of operations and an instance record.
1817c478bd9Sstevel@tonic-gate  *
1827c478bd9Sstevel@tonic-gate  * The file systems are kept on a doubly linked circular list headed by
1837c478bd9Sstevel@tonic-gate  * "rootvfs".
1847c478bd9Sstevel@tonic-gate  * File system implementations should not access this list;
1857c478bd9Sstevel@tonic-gate  * it's intended for use only in the kernel's vfs layer.
1867c478bd9Sstevel@tonic-gate  *
1877c478bd9Sstevel@tonic-gate  * Each zone also has its own list of mounts, containing filesystems mounted
1887c478bd9Sstevel@tonic-gate  * somewhere within the filesystem tree rooted at the zone's rootpath.  The
1897c478bd9Sstevel@tonic-gate  * list is doubly linked to match the global list.
1907c478bd9Sstevel@tonic-gate  *
1917c478bd9Sstevel@tonic-gate  * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and
1927c478bd9Sstevel@tonic-gate  * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that
1937c478bd9Sstevel@tonic-gate  * are set at mount time and can only be modified during a remount.
1947c478bd9Sstevel@tonic-gate  * It is safe to read these fields if you can prevent a remount on the vfs,
1957c478bd9Sstevel@tonic-gate  * or through the convenience funcs vfs_getmntpoint() and vfs_getresource().
1967c478bd9Sstevel@tonic-gate  * The mntopts field may only be accessed through the provided convenience
1977c478bd9Sstevel@tonic-gate  * functions, as it is protected by the vfs list lock. Modifying a mount
1987c478bd9Sstevel@tonic-gate  * option requires grabbing the vfs list write lock, which can be a very
1997c478bd9Sstevel@tonic-gate  * high latency lock.
2007c478bd9Sstevel@tonic-gate  */
2017c478bd9Sstevel@tonic-gate struct zone;		/* from zone.h */
2027c478bd9Sstevel@tonic-gate struct fem_head;	/* from fem.h */
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate typedef struct vfs {
2057c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_next;		/* next VFS in VFS list */
2067c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_prev;		/* prev VFS in VFS list */
2079eb202c2SArne Jansen 	avl_node_t	vfs_avldev;		/* by dev index */
2089eb202c2SArne Jansen 	avl_node_t	vfs_avlmntpnt;		/* by mntpnt index */
2099eb202c2SArne Jansen 	/*
2109eb202c2SArne Jansen 	 * global mount count to define an order on entries in
2119eb202c2SArne Jansen 	 * the avl trees with same dev/mountpoint
2129eb202c2SArne Jansen 	 */
2139eb202c2SArne Jansen 	uint64_t	vfs_mntix;
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /* vfs_op should not be used directly.  Accessor functions are provided */
2167c478bd9Sstevel@tonic-gate 	vfsops_t	*vfs_op;		/* operations on VFS */
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate 	struct vnode	*vfs_vnodecovered;	/* vnode mounted on */
2197c478bd9Sstevel@tonic-gate 	uint_t		vfs_flag;		/* flags */
2207c478bd9Sstevel@tonic-gate 	uint_t		vfs_bsize;		/* native block size */
2217c478bd9Sstevel@tonic-gate 	int		vfs_fstype;		/* file system type index */
2227c478bd9Sstevel@tonic-gate 	fsid_t		vfs_fsid;		/* file system id */
2237c478bd9Sstevel@tonic-gate 	void		*vfs_data;		/* private data */
2247c478bd9Sstevel@tonic-gate 	dev_t		vfs_dev;		/* device of mounted VFS */
2257c478bd9Sstevel@tonic-gate 	ulong_t		vfs_bcount;		/* I/O count (accounting) */
2267c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_list;		/* sync list pointer */
2277c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_hash;		/* hash list pointer */
2287c478bd9Sstevel@tonic-gate 	ksema_t		vfs_reflock;		/* mount/unmount/sync lock */
2297c478bd9Sstevel@tonic-gate 	uint_t		vfs_count;		/* vfs reference count */
2307c478bd9Sstevel@tonic-gate 	mntopts_t	vfs_mntopts;		/* options mounted with */
2317c478bd9Sstevel@tonic-gate 	refstr_t	*vfs_resource;		/* mounted resource name */
2327c478bd9Sstevel@tonic-gate 	refstr_t	*vfs_mntpt;		/* mount point name */
2337c478bd9Sstevel@tonic-gate 	time_t		vfs_mtime;		/* time we were mounted */
234a19609f8Sjv227347 	struct vfs_impl	*vfs_implp;		/* impl specific data */
2357c478bd9Sstevel@tonic-gate 	/*
2367c478bd9Sstevel@tonic-gate 	 * Zones support.  Note that the zone that "owns" the mount isn't
2377c478bd9Sstevel@tonic-gate 	 * necessarily the same as the zone in which the zone is visible.
2387c478bd9Sstevel@tonic-gate 	 * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to
2397c478bd9Sstevel@tonic-gate 	 * different zones.
2407c478bd9Sstevel@tonic-gate 	 */
2417c478bd9Sstevel@tonic-gate 	struct zone	*vfs_zone;		/* zone that owns the mount */
2427c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_zone_next;		/* next VFS visible in zone */
2437c478bd9Sstevel@tonic-gate 	struct vfs	*vfs_zone_prev;		/* prev VFS visible in zone */
24493239addSjohnlev 
245da6c28aaSamw 	struct fem_head	*vfs_femhead;		/* fs monitoring */
24693239addSjohnlev 	minor_t		vfs_lofi_minor;		/* minor if lofi mount */
2477c478bd9Sstevel@tonic-gate } vfs_t;
2487c478bd9Sstevel@tonic-gate 
249da6c28aaSamw #define	vfs_featureset	vfs_implp->vi_featureset
250ddfcde86Srsb #define	vfs_vskap	vfs_implp->vi_vskap
251ddfcde86Srsb #define	vfs_fstypevsp	vfs_implp->vi_fstypevsp
252ddfcde86Srsb #define	vfs_vopstats	vfs_implp->vi_vopstats
253835ee219SRobert Harris #define	vfs_hrctime	vfs_implp->vi_hrctime
254ddfcde86Srsb 
2557c478bd9Sstevel@tonic-gate /*
2567c478bd9Sstevel@tonic-gate  * VFS flags.
2577c478bd9Sstevel@tonic-gate  */
2587c478bd9Sstevel@tonic-gate #define	VFS_RDONLY	0x01		/* read-only vfs */
2597c478bd9Sstevel@tonic-gate #define	VFS_NOMNTTAB	0x02		/* vfs not seen in mnttab */
2607c478bd9Sstevel@tonic-gate #define	VFS_NOSETUID	0x08		/* setuid disallowed */
2617c478bd9Sstevel@tonic-gate #define	VFS_REMOUNT	0x10		/* modify mount options only */
2627c478bd9Sstevel@tonic-gate #define	VFS_NOTRUNC	0x20		/* does not truncate long file names */
2637c478bd9Sstevel@tonic-gate #define	VFS_UNLINKABLE	0x40		/* unlink(2) can be applied to root */
2647c478bd9Sstevel@tonic-gate #define	VFS_PXFS	0x80		/* clustering: global fs proxy vfs */
2657c478bd9Sstevel@tonic-gate #define	VFS_UNMOUNTED	0x100		/* file system has been unmounted */
2667c478bd9Sstevel@tonic-gate #define	VFS_NBMAND	0x200		/* allow non-blocking mandatory locks */
2677c478bd9Sstevel@tonic-gate #define	VFS_XATTR	0x400		/* fs supports extended attributes */
2687c478bd9Sstevel@tonic-gate #define	VFS_NODEVICES	0x800		/* device-special files disallowed */
2697c478bd9Sstevel@tonic-gate #define	VFS_NOEXEC	0x1000		/* executables disallowed */
2705a59a8b3Srsb #define	VFS_STATS	0x2000		/* file system can collect stats */
271f48205beScasper #define	VFS_XID		0x4000		/* file system supports extended ids */
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate #define	VFS_NORESOURCE	"unspecified_resource"
2747c478bd9Sstevel@tonic-gate #define	VFS_NOMNTPT	"unspecified_mountpoint"
2757c478bd9Sstevel@tonic-gate 
2767c478bd9Sstevel@tonic-gate /*
277da6c28aaSamw  * VFS features are implemented as bits set in the vfs_t.
278da6c28aaSamw  * The vfs_feature_t typedef is a 64-bit number that will translate
279da6c28aaSamw  * into an element in an array of bitmaps and a bit in that element.
280da6c28aaSamw  * Developers must not depend on the implementation of this and
281da6c28aaSamw  * need to use vfs_has_feature()/vfs_set_feature() routines.
282da6c28aaSamw  */
283da6c28aaSamw typedef	uint64_t	vfs_feature_t;
284da6c28aaSamw 
285da6c28aaSamw #define	VFSFT_XVATTR		0x100000001	/* Supports xvattr for attrs */
286da6c28aaSamw #define	VFSFT_CASEINSENSITIVE	0x100000002	/* Supports case-insensitive */
287da6c28aaSamw #define	VFSFT_NOCASESENSITIVE	0x100000004	/* NOT case-sensitive */
288da6c28aaSamw #define	VFSFT_DIRENTFLAGS	0x100000008	/* Supports dirent flags */
289da6c28aaSamw #define	VFSFT_ACLONCREATE	0x100000010	/* Supports ACL on create */
290da6c28aaSamw #define	VFSFT_ACEMASKONACCESS	0x100000020	/* Can use ACEMASK for access */
2919660e5cbSJanice Chang #define	VFSFT_SYSATTR_VIEWS	0x100000040	/* Supports sysattr view i/f */
292e802abbdSTim Haley #define	VFSFT_ACCESS_FILTER	0x100000080	/* dirents filtered by access */
2937a286c47SDai Ngo #define	VFSFT_REPARSE		0x100000100	/* Supports reparse point */
294c242f9a0Schunli zhang - Sun Microsystems - Irvine United States #define	VFSFT_ZEROCOPY_SUPPORTED	0x100000200
295c242f9a0Schunli zhang - Sun Microsystems - Irvine United States 				/* Support loaning /returning cache buffer */
296da6c28aaSamw /*
2977c478bd9Sstevel@tonic-gate  * Argument structure for mount(2).
2987c478bd9Sstevel@tonic-gate  *
2997c478bd9Sstevel@tonic-gate  * Flags are defined in <sys/mount.h>.
3007c478bd9Sstevel@tonic-gate  *
3017c478bd9Sstevel@tonic-gate  * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
3027c478bd9Sstevel@tonic-gate  * this structure are to be interpreted as kernel addresses.  File systems
3037c478bd9Sstevel@tonic-gate  * should be prepared for this possibility.
3047c478bd9Sstevel@tonic-gate  */
3057c478bd9Sstevel@tonic-gate struct mounta {
3067c478bd9Sstevel@tonic-gate 	char	*spec;
3077c478bd9Sstevel@tonic-gate 	char	*dir;
3087c478bd9Sstevel@tonic-gate 	int	flags;
3097c478bd9Sstevel@tonic-gate 	char	*fstype;
3107c478bd9Sstevel@tonic-gate 	char	*dataptr;
3117c478bd9Sstevel@tonic-gate 	int	datalen;
3127c478bd9Sstevel@tonic-gate 	char	*optptr;
3137c478bd9Sstevel@tonic-gate 	int	optlen;
3147c478bd9Sstevel@tonic-gate };
3157c478bd9Sstevel@tonic-gate 
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate  * Reasons for calling the vfs_mountroot() operation.
3187c478bd9Sstevel@tonic-gate  */
3197c478bd9Sstevel@tonic-gate enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT};
3207c478bd9Sstevel@tonic-gate typedef enum whymountroot whymountroot_t;
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate /*
3237c478bd9Sstevel@tonic-gate  * Reasons for calling the VFS_VNSTATE():
3247c478bd9Sstevel@tonic-gate  */
3257c478bd9Sstevel@tonic-gate enum vntrans {
3267c478bd9Sstevel@tonic-gate 	VNTRANS_EXISTS,
3277c478bd9Sstevel@tonic-gate 	VNTRANS_IDLED,
3287c478bd9Sstevel@tonic-gate 	VNTRANS_RECLAIMED,
3297c478bd9Sstevel@tonic-gate 	VNTRANS_DESTROYED
3307c478bd9Sstevel@tonic-gate };
3317c478bd9Sstevel@tonic-gate typedef enum vntrans vntrans_t;
3327c478bd9Sstevel@tonic-gate 
333aa59c4cbSrsb /*
334aa59c4cbSrsb  * VFS_OPS defines all the vfs operations.  It is used to define
335aa59c4cbSrsb  * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
336aa59c4cbSrsb  */
337aa59c4cbSrsb #define	VFS_OPS								\
338aa59c4cbSrsb 	int	(*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \
339aa59c4cbSrsb 	int	(*vfs_unmount)(vfs_t *, int, cred_t *);			\
340aa59c4cbSrsb 	int	(*vfs_root)(vfs_t *, vnode_t **);			\
341aa59c4cbSrsb 	int	(*vfs_statvfs)(vfs_t *, statvfs64_t *);			\
342aa59c4cbSrsb 	int	(*vfs_sync)(vfs_t *, short, cred_t *);			\
343aa59c4cbSrsb 	int	(*vfs_vget)(vfs_t *, vnode_t **, fid_t *);		\
344aa59c4cbSrsb 	int	(*vfs_mountroot)(vfs_t *, enum whymountroot);		\
345aa59c4cbSrsb 	void	(*vfs_freevfs)(vfs_t *);				\
346aa59c4cbSrsb 	int	(*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t)	/* NB: No ";" */
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate  * Operations supported on virtual file system.
3507c478bd9Sstevel@tonic-gate  */
3517c478bd9Sstevel@tonic-gate struct vfsops {
352aa59c4cbSrsb 	VFS_OPS;	/* Signature of all vfs operations (vfsops) */
3537c478bd9Sstevel@tonic-gate };
3547c478bd9Sstevel@tonic-gate 
3557c478bd9Sstevel@tonic-gate extern int	fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *);
3567c478bd9Sstevel@tonic-gate extern int	fsop_unmount(vfs_t *, int, cred_t *);
3577c478bd9Sstevel@tonic-gate extern int	fsop_root(vfs_t *, vnode_t **);
3587c478bd9Sstevel@tonic-gate extern int	fsop_statfs(vfs_t *, statvfs64_t *);
3597c478bd9Sstevel@tonic-gate extern int	fsop_sync(vfs_t *, short, cred_t *);
3607c478bd9Sstevel@tonic-gate extern int	fsop_vget(vfs_t *, vnode_t **, fid_t *);
3617c478bd9Sstevel@tonic-gate extern int	fsop_mountroot(vfs_t *, enum whymountroot);
3627c478bd9Sstevel@tonic-gate extern void	fsop_freefs(vfs_t *);
3637c478bd9Sstevel@tonic-gate extern int	fsop_sync_by_kind(int, short, cred_t *);
3647c478bd9Sstevel@tonic-gate extern int	fsop_vnstate(vfs_t *, vnode_t *, vntrans_t);
3657c478bd9Sstevel@tonic-gate 
3667c478bd9Sstevel@tonic-gate #define	VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr)
3677c478bd9Sstevel@tonic-gate #define	VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr)
3687c478bd9Sstevel@tonic-gate #define	VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp)
3697c478bd9Sstevel@tonic-gate #define	VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp)
3707c478bd9Sstevel@tonic-gate #define	VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr)
3717c478bd9Sstevel@tonic-gate #define	VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp)
3727c478bd9Sstevel@tonic-gate #define	VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init)
3737c478bd9Sstevel@tonic-gate #define	VFS_FREEVFS(vfsp) fsop_freefs(vfsp)
3747c478bd9Sstevel@tonic-gate #define	VFS_VNSTATE(vfsp, vn, ns)	fsop_vnstate(vfsp, vn, ns)
3757c478bd9Sstevel@tonic-gate 
3767c478bd9Sstevel@tonic-gate #define	VFSNAME_MOUNT		"mount"
3777c478bd9Sstevel@tonic-gate #define	VFSNAME_UNMOUNT		"unmount"
3787c478bd9Sstevel@tonic-gate #define	VFSNAME_ROOT		"root"
3797c478bd9Sstevel@tonic-gate #define	VFSNAME_STATVFS		"statvfs"
3807c478bd9Sstevel@tonic-gate #define	VFSNAME_SYNC		"sync"
3817c478bd9Sstevel@tonic-gate #define	VFSNAME_VGET		"vget"
3827c478bd9Sstevel@tonic-gate #define	VFSNAME_MOUNTROOT	"mountroot"
3837c478bd9Sstevel@tonic-gate #define	VFSNAME_FREEVFS		"freevfs"
3847c478bd9Sstevel@tonic-gate #define	VFSNAME_VNSTATE		"vnstate"
3857c478bd9Sstevel@tonic-gate /*
3867c478bd9Sstevel@tonic-gate  * Filesystem type switch table.
3877c478bd9Sstevel@tonic-gate  */
3887c478bd9Sstevel@tonic-gate 
3897c478bd9Sstevel@tonic-gate typedef struct vfssw {
3907c478bd9Sstevel@tonic-gate 	char		*vsw_name;	/* type name -- max len _ST_FSTYPSZ */
3917c478bd9Sstevel@tonic-gate 	int		(*vsw_init) (int, char *);
3927c478bd9Sstevel@tonic-gate 				/* init routine (for non-loadable fs only) */
3937c478bd9Sstevel@tonic-gate 	int		vsw_flag;	/* flags */
3947c478bd9Sstevel@tonic-gate 	mntopts_t	vsw_optproto;	/* mount options table prototype */
3957c478bd9Sstevel@tonic-gate 	uint_t		vsw_count;	/* count of references */
3967c478bd9Sstevel@tonic-gate 	kmutex_t	vsw_lock;	/* lock to protect vsw_count */
3977c478bd9Sstevel@tonic-gate 	vfsops_t	vsw_vfsops;	/* filesystem operations vector */
3987c478bd9Sstevel@tonic-gate } vfssw_t;
3997c478bd9Sstevel@tonic-gate 
4007c478bd9Sstevel@tonic-gate /*
4017c478bd9Sstevel@tonic-gate  * Filesystem type definition record.  All file systems must export a record
402da6c28aaSamw  * of this type through their modlfs structure.  N.B., changing the version
403da6c28aaSamw  * number requires a change in sys/modctl.h.
4047c478bd9Sstevel@tonic-gate  */
4057c478bd9Sstevel@tonic-gate 
406d7334e51Srm15945 typedef struct vfsdef_v5 {
4077c478bd9Sstevel@tonic-gate 	int		def_version;	/* structure version, must be first */
4087c478bd9Sstevel@tonic-gate 	char		*name;		/* filesystem type name */
4097c478bd9Sstevel@tonic-gate 	int		(*init) (int, char *);	/* init routine */
4107c478bd9Sstevel@tonic-gate 	int		flags;		/* filesystem flags */
4117c478bd9Sstevel@tonic-gate 	mntopts_t	*optproto;	/* mount options table prototype */
412d7334e51Srm15945 } vfsdef_v5;
4137c478bd9Sstevel@tonic-gate 
414d7334e51Srm15945 typedef struct vfsdef_v5 vfsdef_t;
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate enum {
417d7334e51Srm15945 	VFSDEF_VERSION = 5
4187c478bd9Sstevel@tonic-gate };
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate /*
4217c478bd9Sstevel@tonic-gate  * flags for vfssw and vfsdef
4227c478bd9Sstevel@tonic-gate  */
4237c478bd9Sstevel@tonic-gate #define	VSW_HASPROTO	0x01	/* struct has a mount options prototype */
4247c478bd9Sstevel@tonic-gate #define	VSW_CANRWRO	0x02	/* file system can transition from rw to ro */
4257c478bd9Sstevel@tonic-gate #define	VSW_CANREMOUNT	0x04	/* file system supports remounts */
4267c478bd9Sstevel@tonic-gate #define	VSW_NOTZONESAFE	0x08	/* zone_enter(2) should fail for these files */
4277c478bd9Sstevel@tonic-gate #define	VSW_VOLATILEDEV	0x10	/* vfs_dev can change each time fs is mounted */
4285a59a8b3Srsb #define	VSW_STATS	0x20	/* file system can collect stats */
429f48205beScasper #define	VSW_XID		0x40	/* file system supports extended ids */
43043d5cd3dSjohnlev #define	VSW_CANLOFI	0x80	/* file system supports lofi mounts */
4310fbb751dSJohn Levon #define	VSW_ZMOUNT	0x100	/* file system always allowed in a zone */
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate #define	VSW_INSTALLED	0x8000	/* this vsw is associated with a file system */
4347c478bd9Sstevel@tonic-gate 
435d7de0ceaSRobert Harris /*
436d7de0ceaSRobert Harris  * A flag for vfs_setpath().
437d7de0ceaSRobert Harris  */
438d7de0ceaSRobert Harris #define	VFSSP_VERBATIM	0x1	/* do not prefix the supplied path */
439d7de0ceaSRobert Harris 
440b819cea2SGordon Ross #if defined(_KERNEL) || defined(_FAKE_KERNEL)
441a19609f8Sjv227347 
442a19609f8Sjv227347 /*
443a19609f8Sjv227347  * Private vfs data, NOT to be used by a file system implementation.
444a19609f8Sjv227347  */
445a19609f8Sjv227347 
446a19609f8Sjv227347 #define	VFS_FEATURE_MAXSZ	4
447a19609f8Sjv227347 
448a19609f8Sjv227347 typedef struct vfs_impl {
449a19609f8Sjv227347 	/* Counted array - Bitmap of vfs features */
450a19609f8Sjv227347 	uint32_t	vi_featureset[VFS_FEATURE_MAXSZ];
451a19609f8Sjv227347 	/*
452a19609f8Sjv227347 	 * Support for statistics on the vnode operations
453a19609f8Sjv227347 	 */
454a19609f8Sjv227347 	vsk_anchor_t	*vi_vskap;		/* anchor for vopstats' kstat */
455a19609f8Sjv227347 	vopstats_t	*vi_fstypevsp;		/* ptr to per-fstype vopstats */
456a19609f8Sjv227347 	vopstats_t	vi_vopstats;		/* per-mount vnode op stats */
457a19609f8Sjv227347 
458a19609f8Sjv227347 	timespec_t	vi_hrctime; 		/* High-res creation time */
459a19609f8Sjv227347 
460a19609f8Sjv227347 	zone_ref_t	vi_zone_ref;		/* reference to zone */
461a19609f8Sjv227347 } vfs_impl_t;
462a19609f8Sjv227347 
4637c478bd9Sstevel@tonic-gate /*
4647c478bd9Sstevel@tonic-gate  * Public operations.
4657c478bd9Sstevel@tonic-gate  */
4667c478bd9Sstevel@tonic-gate struct umounta;
4677c478bd9Sstevel@tonic-gate struct statvfsa;
4687c478bd9Sstevel@tonic-gate struct fstatvfsa;
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate void	vfs_freevfsops(vfsops_t *);
4717c478bd9Sstevel@tonic-gate int	vfs_freevfsops_by_type(int);
4727c478bd9Sstevel@tonic-gate void	vfs_setops(vfs_t *, vfsops_t *);
4737c478bd9Sstevel@tonic-gate vfsops_t *vfs_getops(vfs_t *vfsp);
4747c478bd9Sstevel@tonic-gate int	vfs_matchops(vfs_t *, vfsops_t *);
4757c478bd9Sstevel@tonic-gate int	vfs_can_sync(vfs_t *vfsp);
476da6c28aaSamw vfs_t	*vfs_alloc(int);
477da6c28aaSamw void	vfs_free(vfs_t *);
4787c478bd9Sstevel@tonic-gate void	vfs_init(vfs_t *vfsp, vfsops_t *, void *);
479ddfcde86Srsb void	vfsimpl_setup(vfs_t *vfsp);
480ddfcde86Srsb void	vfsimpl_teardown(vfs_t *vfsp);
4817c478bd9Sstevel@tonic-gate void	vn_exists(vnode_t *);
4827c478bd9Sstevel@tonic-gate void	vn_idle(vnode_t *);
4837c478bd9Sstevel@tonic-gate void	vn_reclaim(vnode_t *);
4847c478bd9Sstevel@tonic-gate void	vn_invalid(vnode_t *);
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate int	rootconf(void);
4877c478bd9Sstevel@tonic-gate int	domount(char *, struct mounta *, vnode_t *, struct cred *,
4887c478bd9Sstevel@tonic-gate 	    struct vfs **);
4897c478bd9Sstevel@tonic-gate int	dounmount(struct vfs *, int, cred_t *);
4907c478bd9Sstevel@tonic-gate int	vfs_lock(struct vfs *);
4917c478bd9Sstevel@tonic-gate int	vfs_rlock(struct vfs *);
4927c478bd9Sstevel@tonic-gate void	vfs_lock_wait(struct vfs *);
4937c478bd9Sstevel@tonic-gate void	vfs_rlock_wait(struct vfs *);
4947c478bd9Sstevel@tonic-gate void	vfs_unlock(struct vfs *);
4957c478bd9Sstevel@tonic-gate int	vfs_lock_held(struct vfs *);
4967c478bd9Sstevel@tonic-gate struct	_kthread *vfs_lock_owner(struct vfs *);
4977c478bd9Sstevel@tonic-gate void	sync(void);
4987c478bd9Sstevel@tonic-gate void	vfs_sync(int);
4997c478bd9Sstevel@tonic-gate void	vfs_mountroot(void);
5007c478bd9Sstevel@tonic-gate void	vfs_add(vnode_t *, struct vfs *, int);
5017c478bd9Sstevel@tonic-gate void	vfs_remove(struct vfs *);
5027c478bd9Sstevel@tonic-gate 
503da6c28aaSamw /* VFS feature routines */
504da6c28aaSamw void	vfs_set_feature(vfs_t *, vfs_feature_t);
50544bffe01SMark Shellenbaum void	vfs_clear_feature(vfs_t *, vfs_feature_t);
506da6c28aaSamw int	vfs_has_feature(vfs_t *, vfs_feature_t);
50779a28c7aSmarks void	vfs_propagate_features(vfs_t *, vfs_t *);
508da6c28aaSamw 
5097c478bd9Sstevel@tonic-gate /* The following functions are not for general use by filesystems */
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate void	vfs_createopttbl(mntopts_t *, const char *);
5127c478bd9Sstevel@tonic-gate void	vfs_copyopttbl(const mntopts_t *, mntopts_t *);
5137c478bd9Sstevel@tonic-gate void	vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *);
5147c478bd9Sstevel@tonic-gate void	vfs_freeopttbl(mntopts_t *);
5157c478bd9Sstevel@tonic-gate void	vfs_parsemntopts(mntopts_t *, char *, int);
5167c478bd9Sstevel@tonic-gate int	vfs_buildoptionstr(const mntopts_t *, char *, int);
5177c478bd9Sstevel@tonic-gate struct mntopt *vfs_hasopt(const mntopts_t *, const char *);
5187c478bd9Sstevel@tonic-gate void	vfs_mnttab_modtimeupd(void);
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate void	vfs_clearmntopt(struct vfs *, const char *);
5217c478bd9Sstevel@tonic-gate void	vfs_setmntopt(struct vfs *, const char *, const char *, int);
522d7de0ceaSRobert Harris void	vfs_setresource(struct vfs *, const char *, uint32_t);
523d7de0ceaSRobert Harris void	vfs_setmntpoint(struct vfs *, const char *, uint32_t);
5247c478bd9Sstevel@tonic-gate refstr_t *vfs_getresource(const struct vfs *);
5257c478bd9Sstevel@tonic-gate refstr_t *vfs_getmntpoint(const struct vfs *);
5267c478bd9Sstevel@tonic-gate int	vfs_optionisset(const struct vfs *, const char *, char **);
5277c478bd9Sstevel@tonic-gate int	vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *);
5287c478bd9Sstevel@tonic-gate int	vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *);
5297c478bd9Sstevel@tonic-gate void	vfs_syncall(void);
5307c478bd9Sstevel@tonic-gate void	vfs_syncprogress(void);
5317c478bd9Sstevel@tonic-gate void	vfsinit(void);
5327c478bd9Sstevel@tonic-gate void	vfs_unmountall(void);
5337c478bd9Sstevel@tonic-gate void	vfs_make_fsid(fsid_t *, dev_t, int);
5347c478bd9Sstevel@tonic-gate void	vfs_addmip(dev_t, struct vfs *);
5357c478bd9Sstevel@tonic-gate void	vfs_delmip(struct vfs *);
5367c478bd9Sstevel@tonic-gate int	vfs_devismounted(dev_t);
5377c478bd9Sstevel@tonic-gate int	vfs_devmounting(dev_t, struct vfs *);
5387c478bd9Sstevel@tonic-gate int	vfs_opsinuse(vfsops_t *);
5397c478bd9Sstevel@tonic-gate struct vfs *getvfs(fsid_t *);
5407c478bd9Sstevel@tonic-gate struct vfs *vfs_dev2vfsp(dev_t);
5417c478bd9Sstevel@tonic-gate struct vfs *vfs_mntpoint2vfsp(const char *);
54243d5cd3dSjohnlev struct vfssw *allocate_vfssw(const char *);
54343d5cd3dSjohnlev struct vfssw *vfs_getvfssw(const char *);
54443d5cd3dSjohnlev struct vfssw *vfs_getvfsswbyname(const char *);
5457c478bd9Sstevel@tonic-gate struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *);
5467c478bd9Sstevel@tonic-gate void	vfs_refvfssw(struct vfssw *);
5477c478bd9Sstevel@tonic-gate void	vfs_unrefvfssw(struct vfssw *);
5487c478bd9Sstevel@tonic-gate uint_t	vf_to_stf(uint_t);
5497c478bd9Sstevel@tonic-gate void	vfs_mnttab_modtime(timespec_t *);
5507c478bd9Sstevel@tonic-gate void	vfs_mnttab_poll(timespec_t *, struct pollhead **);
5517c478bd9Sstevel@tonic-gate 
5527c478bd9Sstevel@tonic-gate void	vfs_list_lock(void);
5537c478bd9Sstevel@tonic-gate void	vfs_list_read_lock(void);
5547c478bd9Sstevel@tonic-gate void	vfs_list_unlock(void);
5557c478bd9Sstevel@tonic-gate void	vfs_list_add(struct vfs *);
5567c478bd9Sstevel@tonic-gate void	vfs_list_remove(struct vfs *);
5577c478bd9Sstevel@tonic-gate void	vfs_hold(vfs_t *vfsp);
5587c478bd9Sstevel@tonic-gate void	vfs_rele(vfs_t *vfsp);
5597c478bd9Sstevel@tonic-gate void	fs_freevfs(vfs_t *);
5607c478bd9Sstevel@tonic-gate void	vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype);
5617c478bd9Sstevel@tonic-gate 
5627c478bd9Sstevel@tonic-gate int	vfs_zone_change_safe(vfs_t *);
5637c478bd9Sstevel@tonic-gate 
56493239addSjohnlev int	vfs_get_lofi(vfs_t *, vnode_t **);
56593239addSjohnlev 
5667c478bd9Sstevel@tonic-gate #define	VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1))
5677c478bd9Sstevel@tonic-gate #define	VFS_ON_LIST(vfsp) \
5687c478bd9Sstevel@tonic-gate 	((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL)
5697c478bd9Sstevel@tonic-gate 
5707c478bd9Sstevel@tonic-gate /*
5717c478bd9Sstevel@tonic-gate  * Globals.
5727c478bd9Sstevel@tonic-gate  */
5737c478bd9Sstevel@tonic-gate 
5747c478bd9Sstevel@tonic-gate extern struct vfssw vfssw[];		/* table of filesystem types */
5757c478bd9Sstevel@tonic-gate extern krwlock_t vfssw_lock;
5767c478bd9Sstevel@tonic-gate extern char rootfstype[];		/* name of root fstype */
5777c478bd9Sstevel@tonic-gate extern const int nfstype;		/* # of elements in vfssw array */
5787c478bd9Sstevel@tonic-gate extern vfsops_t *EIO_vfsops;		/* operations for vfs being torn-down */
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate /*
5817c478bd9Sstevel@tonic-gate  * The following variables are private to the the kernel's vfs layer.  File
5827c478bd9Sstevel@tonic-gate  * system implementations should not access them.
5837c478bd9Sstevel@tonic-gate  */
5847c478bd9Sstevel@tonic-gate extern struct vfs *rootvfs;		/* ptr to root vfs structure */
5857c478bd9Sstevel@tonic-gate typedef struct {
5867c478bd9Sstevel@tonic-gate 	struct vfs *rvfs_head;		/* head vfs in chain */
5877c478bd9Sstevel@tonic-gate 	kmutex_t rvfs_lock;		/* mutex protecting this chain */
5887c478bd9Sstevel@tonic-gate 	uint32_t rvfs_len;		/* length of this chain */
5897c478bd9Sstevel@tonic-gate } rvfs_t;
5907c478bd9Sstevel@tonic-gate extern rvfs_t *rvfs_list;
5917c478bd9Sstevel@tonic-gate extern int vfshsz;			/* # of elements in rvfs_head array */
5927c478bd9Sstevel@tonic-gate extern const mntopts_t vfs_mntopts;	/* globally recognized options */
5937c478bd9Sstevel@tonic-gate 
5947c478bd9Sstevel@tonic-gate #endif /* defined(_KERNEL) */
5957c478bd9Sstevel@tonic-gate 
5967c478bd9Sstevel@tonic-gate #define	VFS_HOLD(vfsp) { \
5977c478bd9Sstevel@tonic-gate 	vfs_hold(vfsp); \
5987c478bd9Sstevel@tonic-gate }
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate #define	VFS_RELE(vfsp)	{ \
6017c478bd9Sstevel@tonic-gate 	vfs_rele(vfsp); \
6027c478bd9Sstevel@tonic-gate }
6037c478bd9Sstevel@tonic-gate 
604ddfcde86Srsb #define	VFS_INIT(vfsp, op, data) { \
605ddfcde86Srsb 	vfs_init((vfsp), (op), (data)); \
6067c478bd9Sstevel@tonic-gate }
6077c478bd9Sstevel@tonic-gate 
608ddfcde86Srsb 
6097c478bd9Sstevel@tonic-gate #define	VFS_INSTALLED(vfsswp)	(((vfsswp)->vsw_flag & VSW_INSTALLED) != 0)
6107c478bd9Sstevel@tonic-gate #define	ALLOCATED_VFSSW(vswp)		((vswp)->vsw_name[0] != '\0')
6117c478bd9Sstevel@tonic-gate #define	RLOCK_VFSSW()			(rw_enter(&vfssw_lock, RW_READER))
6127c478bd9Sstevel@tonic-gate #define	RUNLOCK_VFSSW()			(rw_exit(&vfssw_lock))
6137c478bd9Sstevel@tonic-gate #define	WLOCK_VFSSW()			(rw_enter(&vfssw_lock, RW_WRITER))
6147c478bd9Sstevel@tonic-gate #define	WUNLOCK_VFSSW()			(rw_exit(&vfssw_lock))
6157c478bd9Sstevel@tonic-gate #define	VFSSW_LOCKED()			(RW_LOCK_HELD(&vfssw_lock))
6167c478bd9Sstevel@tonic-gate #define	VFSSW_WRITE_LOCKED()		(RW_WRITE_HELD(&vfssw_lock))
6177c478bd9Sstevel@tonic-gate /*
6187c478bd9Sstevel@tonic-gate  * VFS_SYNC flags.
6197c478bd9Sstevel@tonic-gate  */
6207c478bd9Sstevel@tonic-gate #define	SYNC_ATTR	0x01		/* sync attributes only */
6217c478bd9Sstevel@tonic-gate #define	SYNC_CLOSE	0x02		/* close open file */
6227c478bd9Sstevel@tonic-gate #define	SYNC_ALL	0x04		/* force to sync all fs */
6237c478bd9Sstevel@tonic-gate 
6247c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
6257c478bd9Sstevel@tonic-gate }
6267c478bd9Sstevel@tonic-gate #endif
6277c478bd9Sstevel@tonic-gate 
6287c478bd9Sstevel@tonic-gate #endif	/* _SYS_VFS_H */
629