xref: /freebsd/sys/kern/vfs_mount.c (revision afe61c15161c324a7af299a9b8457aba5afc92db)
1 /*
2  * Copyright (c) 1989, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *	This product includes software developed by the University of
16  *	California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  *	@(#)vfs_conf.c	8.8 (Berkeley) 3/31/94
34  */
35 
36 #include <sys/param.h>
37 #include <sys/mount.h>
38 #include <sys/vnode.h>
39 
40 #ifdef FFS
41 #include <ufs/ffs/ffs_extern.h>
42 
43 /*
44  * This specifies the filesystem used to mount the root.
45  * This specification should be done by /etc/config.
46  */
47 int (*mountroot)() = ffs_mountroot;
48 #endif
49 
50 /*
51  * These define the root filesystem and device.
52  */
53 struct mount *rootfs;
54 struct vnode *rootvnode;
55 
56 /*
57  * Set up the filesystem operations for vnodes.
58  * The types are defined in mount.h.
59  */
60 #ifdef FFS
61 extern	struct vfsops ufs_vfsops;
62 #define	UFS_VFSOPS	&ufs_vfsops
63 #else
64 #define	UFS_VFSOPS	NULL
65 #endif
66 
67 #ifdef LFS
68 extern	struct vfsops lfs_vfsops;
69 #define	LFS_VFSOPS	&lfs_vfsops
70 #else
71 #define	LFS_VFSOPS	NULL
72 #endif
73 
74 #ifdef MFS
75 extern	struct vfsops mfs_vfsops;
76 #define	MFS_VFSOPS	&mfs_vfsops
77 #else
78 #define	MFS_VFSOPS	NULL
79 #endif
80 
81 #ifdef NFS
82 extern	struct vfsops nfs_vfsops;
83 #define	NFS_VFSOPS	&nfs_vfsops
84 #else
85 #define	NFS_VFSOPS	NULL
86 #endif
87 
88 #ifdef FDESC
89 extern	struct vfsops fdesc_vfsops;
90 #define	FDESC_VFSOPS	&fdesc_vfsops
91 #else
92 #define	FDESC_VFSOPS	NULL
93 #endif
94 
95 #ifdef PORTAL
96 extern	struct vfsops portal_vfsops;
97 #define	PORTAL_VFSOPS	&portal_vfsops
98 #else
99 #define	PORTAL_VFSOPS	NULL
100 #endif
101 
102 #ifdef NULLFS
103 extern	struct vfsops null_vfsops;
104 #define NULL_VFSOPS	&null_vfsops
105 #else
106 #define NULL_VFSOPS	NULL
107 #endif
108 
109 #ifdef UMAPFS
110 extern	struct vfsops umap_vfsops;
111 #define UMAP_VFSOPS	&umap_vfsops
112 #else
113 #define UMAP_VFSOPS	NULL
114 #endif
115 
116 #ifdef KERNFS
117 extern	struct vfsops kernfs_vfsops;
118 #define KERNFS_VFSOPS	&kernfs_vfsops
119 #else
120 #define KERNFS_VFSOPS	NULL
121 #endif
122 
123 #ifdef PROCFS
124 extern	struct vfsops procfs_vfsops;
125 #define PROCFS_VFSOPS	&procfs_vfsops
126 #else
127 #define PROCFS_VFSOPS	NULL
128 #endif
129 
130 #ifdef AFS
131 extern	struct vfsops afs_vfsops;
132 #define AFS_VFSOPS	&afs_vfsops
133 #else
134 #define AFS_VFSOPS	NULL
135 #endif
136 
137 #ifdef CD9660
138 extern	struct vfsops cd9660_vfsops;
139 #define CD9660_VFSOPS	&cd9660_vfsops
140 #else
141 #define CD9660_VFSOPS	NULL
142 #endif
143 
144 #ifdef UNION
145 extern	struct vfsops union_vfsops;
146 #define	UNION_VFSOPS	&union_vfsops
147 #else
148 #define	UNION_VFSOPS	NULL
149 #endif
150 
151 struct vfsops *vfssw[] = {
152 	NULL,			/* 0 = MOUNT_NONE */
153 	UFS_VFSOPS,		/* 1 = MOUNT_UFS */
154 	NFS_VFSOPS,		/* 2 = MOUNT_NFS */
155 	MFS_VFSOPS,		/* 3 = MOUNT_MFS */
156 	NULL,			/* 4 = MOUNT_PC */
157 	LFS_VFSOPS,		/* 5 = MOUNT_LFS */
158 	NULL,			/* 6 = MOUNT_LOFS */
159 	FDESC_VFSOPS,		/* 7 = MOUNT_FDESC */
160 	PORTAL_VFSOPS,		/* 8 = MOUNT_PORTAL */
161 	NULL_VFSOPS,		/* 9 = MOUNT_NULL */
162 	UMAP_VFSOPS,		/* 10 = MOUNT_UMAP */
163 	KERNFS_VFSOPS,		/* 11 = MOUNT_KERNFS */
164 	PROCFS_VFSOPS,		/* 12 = MOUNT_PROCFS */
165 	AFS_VFSOPS,		/* 13 = MOUNT_AFS */
166 	CD9660_VFSOPS,		/* 14 = MOUNT_CD9660 */
167 	UNION_VFSOPS,		/* 15 = MOUNT_UNION */
168 	0
169 };
170 
171 
172 /*
173  *
174  * vfs_opv_descs enumerates the list of vnode classes, each with it's own
175  * vnode operation vector.  It is consulted at system boot to build operation
176  * vectors.  It is NULL terminated.
177  *
178  */
179 extern struct vnodeopv_desc ffs_vnodeop_opv_desc;
180 extern struct vnodeopv_desc ffs_specop_opv_desc;
181 extern struct vnodeopv_desc ffs_fifoop_opv_desc;
182 extern struct vnodeopv_desc lfs_vnodeop_opv_desc;
183 extern struct vnodeopv_desc lfs_specop_opv_desc;
184 extern struct vnodeopv_desc lfs_fifoop_opv_desc;
185 extern struct vnodeopv_desc mfs_vnodeop_opv_desc;
186 extern struct vnodeopv_desc dead_vnodeop_opv_desc;
187 extern struct vnodeopv_desc fifo_vnodeop_opv_desc;
188 extern struct vnodeopv_desc spec_vnodeop_opv_desc;
189 extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc;
190 extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc;
191 extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc;
192 extern struct vnodeopv_desc fdesc_vnodeop_opv_desc;
193 extern struct vnodeopv_desc portal_vnodeop_opv_desc;
194 extern struct vnodeopv_desc null_vnodeop_opv_desc;
195 extern struct vnodeopv_desc umap_vnodeop_opv_desc;
196 extern struct vnodeopv_desc kernfs_vnodeop_opv_desc;
197 extern struct vnodeopv_desc procfs_vnodeop_opv_desc;
198 extern struct vnodeopv_desc cd9660_vnodeop_opv_desc;
199 extern struct vnodeopv_desc cd9660_specop_opv_desc;
200 extern struct vnodeopv_desc cd9660_fifoop_opv_desc;
201 extern struct vnodeopv_desc union_vnodeop_opv_desc;
202 
203 struct vnodeopv_desc *vfs_opv_descs[] = {
204 	&ffs_vnodeop_opv_desc,
205 	&ffs_specop_opv_desc,
206 #ifdef FIFO
207 	&ffs_fifoop_opv_desc,
208 #endif
209 	&dead_vnodeop_opv_desc,
210 #ifdef FIFO
211 	&fifo_vnodeop_opv_desc,
212 #endif
213 	&spec_vnodeop_opv_desc,
214 #ifdef LFS
215 	&lfs_vnodeop_opv_desc,
216 	&lfs_specop_opv_desc,
217 #ifdef FIFO
218 	&lfs_fifoop_opv_desc,
219 #endif
220 #endif
221 #ifdef MFS
222 	&mfs_vnodeop_opv_desc,
223 #endif
224 #ifdef NFS
225 	&nfsv2_vnodeop_opv_desc,
226 	&spec_nfsv2nodeop_opv_desc,
227 #ifdef FIFO
228 	&fifo_nfsv2nodeop_opv_desc,
229 #endif
230 #endif
231 #ifdef FDESC
232 	&fdesc_vnodeop_opv_desc,
233 #endif
234 #ifdef PORTAL
235 	&portal_vnodeop_opv_desc,
236 #endif
237 #ifdef NULLFS
238 	&null_vnodeop_opv_desc,
239 #endif
240 #ifdef UMAPFS
241 	&umap_vnodeop_opv_desc,
242 #endif
243 #ifdef KERNFS
244 	&kernfs_vnodeop_opv_desc,
245 #endif
246 #ifdef PROCFS
247 	&procfs_vnodeop_opv_desc,
248 #endif
249 #ifdef CD9660
250 	&cd9660_vnodeop_opv_desc,
251 	&cd9660_specop_opv_desc,
252 #ifdef FIFO
253 	&cd9660_fifoop_opv_desc,
254 #endif
255 #endif
256 #ifdef UNION
257 	&union_vnodeop_opv_desc,
258 #endif
259 	NULL
260 };
261