1 /*	$NetBSD: vfs.h,v 1.4 2010/02/28 14:45:47 haad Exp $	*/
2 
3 /*-
4  * Copyright (c) 2007 Pawel Jakub Dawidek <pjd@FreeBSD.org>
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * $FreeBSD: src/sys/compat/opensolaris/sys/vfs.h,v 1.2 2007/06/04 11:31:45 pjd Exp $
29  */
30 
31 #ifndef _OPENSOLARIS_SYS_VFS_H_
32 #define	_OPENSOLARIS_SYS_VFS_H_
33 
34 #include <sys/param.h>
35 
36 #ifdef _KERNEL
37 
38 #include <sys/mount.h>
39 #include <sys/vnode.h>
40 
41 #define	rootdir	rootvnode
42 
43 typedef	struct mount	vfs_t;
44 
45 #define	vfs_flag	mnt_flag
46 #define	vfs_data	mnt_data
47 #define	vfs_count	mnt_refcnt
48 #define	vfs_fsid 	mnt_stat.f_fsid
49 #define	vfs_bsize	mnt_stat.f_bsize
50 
51 #define	v_flag		v_vflag
52 #define	v_vfsp		v_mount
53 
54 #define f_basetype      f_fstypename
55 
56 #define vfs_setfsops(a, b, c)    vfs_attach(&b)
57 #define vfs_freevfsops_by_type(zfsfstype) do { } while (0)
58 
59 #define	VFS_RDONLY	MNT_RDONLY
60 #define	VFS_NOSETUID	MNT_NOSUID
61 #define	VFS_NOEXEC	MNT_NOEXEC
62 #define VFS_NODEVICES   MNT_NODEV
63 #define VFS_NOTRUNC     0
64 
65 #define	VFS_HOLD(vfsp)	do {						\
66 	/* XXXNETBSD nothing */						\
67 } while (0)
68 #define	VFS_RELE(vfsp)	do {						\
69 	/* XXXNETBSD nothing */						\
70 } while (0)
71 
72 #define	VROOT		VV_ROOT
73 
74 /*
75  * Structure defining a mount option for a filesystem.
76  * option names are found in mntent.h
77  */
78 typedef struct mntopt {
79 	char	*mo_name;	/* option name */
80 	char	**mo_cancel;	/* list of options cancelled by this one */
81 	char	*mo_arg;	/* argument string for this option */
82 	int	mo_flags;	/* flags for this mount option */
83 	void	*mo_data;	/* filesystem specific data */
84 } mntopt_t;
85 
86 /*
87  * Flags that apply to mount options
88  */
89 
90 #define	MO_SET		0x01		/* option is set */
91 #define	MO_NODISPLAY	0x02		/* option not listed in mnttab */
92 #define	MO_HASVALUE	0x04		/* option takes a value */
93 #define	MO_IGNORE	0x08		/* option ignored by parser */
94 #define	MO_DEFAULT	MO_SET		/* option is on by default */
95 #define	MO_TAG		0x10		/* flags a tag set by user program */
96 #define	MO_EMPTY	0x20		/* empty space in option table */
97 
98 #define	VFS_NOFORCEOPT	0x01		/* honor MO_IGNORE (don't set option) */
99 #define	VFS_DISPLAY	0x02		/* Turn off MO_NODISPLAY bit for opt */
100 #define	VFS_NODISPLAY	0x04		/* Turn on MO_NODISPLAY bit for opt */
101 #define	VFS_CREATEOPT	0x08		/* Create the opt if it's not there */
102 #define VFS_UNMOUNTED   0x100           /* file system has been unmounted */
103 
104 #define MS_SYSSPACE     0x0008          /* Mounta already in kernel space */
105 #define MS_DATA         0
106 
107 /*
108  * Structure holding mount option strings for the mounted file system.
109  */
110 typedef struct mntopts {
111 	uint_t		mo_count;		/* number of entries in table */
112 	mntopt_t	*mo_list;		/* list of mount options */
113 } mntopts_t;
114 
115  /*
116   * Argument structure for mount(2).
117   *
118   * Flags are defined in <sys/mount.h>.
119   *
120   * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
121   * this structure are to be interpreted as kernel addresses.  File systems
122   * should be prepared for this possibility.
123   */
124 struct mounta {
125 	char fspec[MAXNAMELEN - 1];
126 	char dataptr[MAXPATHLEN];
127 	char optptr[MAXPATHLEN];
128 	char *fstype; /* Unused */
129 	int  mflag;
130 	int  datalen;
131 	int  optlen;
132 	int  flags; /* Unused */
133 };
134 
135 #define vfs_devismounted(dev) 0
136 #define fs_vscan(vp, cr, async) (0)
137 
138 void vfs_setmntopt(vfs_t *vfsp, const char *name, const char *arg,
139     int flags __unused);
140 void vfs_clearmntopt(vfs_t *vfsp, const char *name);
141 int vfs_optionisset(const vfs_t *vfsp, const char *opt, char **argp);
142 int traverse(vnode_t **cvpp, int lktype);
143 int domount(kthread_t *td, vnode_t *vp, const char *fstype, char *fspath,
144     char *fspec, int fsflags);
145 
146 #define vfs_set_feature(vfsp, feature)  do { } while (0)
147 #define vfs_has_feature(vfsp, feature)  (0)
148 
149 int zfs_vfsinit(int fstype, char *name);
150 int zfs_vfsfini(void);
151 
152 #endif	/* _KERNEL */
153 
154 #endif	/* _OPENSOLARIS_SYS_VFS_H_ */
155