]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
cb323159 | 2 | * Copyright (c) 2000-2019 Apple Inc. All rights reserved. |
5d5c5d0d | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
0a7de745 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
0a7de745 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
0a7de745 | 17 | * |
2d21ac55 A |
18 | * The Original Code and all software distributed under the License are |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
0a7de745 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
1c79356b A |
27 | */ |
28 | /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */ | |
29 | /* | |
30 | * Copyright (c) 1989, 1993, 1995 | |
31 | * The Regents of the University of California. All rights reserved. | |
32 | * | |
33 | * Redistribution and use in source and binary forms, with or without | |
34 | * modification, are permitted provided that the following conditions | |
35 | * are met: | |
36 | * 1. Redistributions of source code must retain the above copyright | |
37 | * notice, this list of conditions and the following disclaimer. | |
38 | * 2. Redistributions in binary form must reproduce the above copyright | |
39 | * notice, this list of conditions and the following disclaimer in the | |
40 | * documentation and/or other materials provided with the distribution. | |
41 | * 3. All advertising materials mentioning features or use of this software | |
42 | * must display the following acknowledgement: | |
43 | * This product includes software developed by the University of | |
44 | * California, Berkeley and its contributors. | |
45 | * 4. Neither the name of the University nor the names of its contributors | |
46 | * may be used to endorse or promote products derived from this software | |
47 | * without specific prior written permission. | |
48 | * | |
49 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
50 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
52 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
55 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
56 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
57 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
58 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
59 | * SUCH DAMAGE. | |
60 | * | |
61 | * @(#)vfs_conf.c 8.11 (Berkeley) 5/10/95 | |
62 | */ | |
2d21ac55 A |
63 | /* |
64 | * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce | |
65 | * support for mandatory and extensible security protections. This notice | |
66 | * is included in support of clause 2.2 (b) of the Apple Public License, | |
67 | * Version 2.0. | |
68 | */ | |
1c79356b A |
69 | |
70 | #include <sys/param.h> | |
71 | #include <sys/systm.h> | |
91447636 A |
72 | #include <sys/mount_internal.h> |
73 | #include <sys/vnode_internal.h> | |
1c79356b | 74 | |
ea3f0419 A |
75 | #include <nfs/nfs_conf.h> |
76 | ||
1c79356b A |
77 | /* |
78 | * These define the root filesystem, device, and root filesystem type. | |
79 | */ | |
80 | struct mount *rootfs; | |
81 | struct vnode *rootvnode; | |
b7266188 A |
82 | |
83 | #ifdef CONFIG_IMGSRC_ACCESS | |
0a7de745 | 84 | struct vnode *imgsrc_rootvnodes[MAX_IMAGEBOOT_NESTING]; /* [0] -> source volume, [1] -> first disk image */ |
6d2010ae | 85 | #endif /* CONFIG_IMGSRC_ACCESS */ |
b7266188 | 86 | |
2d21ac55 | 87 | int (*mountroot)(void) = NULL; |
1c79356b A |
88 | |
89 | /* | |
90 | * Set up the initial array of known filesystem types. | |
91 | */ | |
0a7de745 A |
92 | extern struct vfsops mfs_vfsops; |
93 | extern int mfs_mountroot(mount_t, vnode_t, vfs_context_t); /* dead */ | |
94 | extern struct vfsops nfs_vfsops; | |
95 | extern int nfs_mountroot(void); | |
96 | extern struct vfsops afs_vfsops; | |
97 | extern struct vfsops null_vfsops; | |
98 | extern struct vfsops devfs_vfsops; | |
cb323159 | 99 | extern const struct vfsops routefs_vfsops; |
39037602 | 100 | extern struct vfsops nullfs_vfsops; |
1c79356b | 101 | |
39236c6e | 102 | #if MOCKFS |
0a7de745 A |
103 | extern struct vfsops mockfs_vfsops; |
104 | extern int mockfs_mountroot(mount_t, vnode_t, vfs_context_t); | |
39236c6e A |
105 | #endif /* MOCKFS */ |
106 | ||
2d21ac55 A |
107 | /* |
108 | * For nfs_mountroot(void) cast. nfs_mountroot ignores its parameters, if | |
109 | * invoked through this table. | |
110 | */ | |
111 | typedef int (*mountroot_t)(mount_t, vnode_t, vfs_context_t); | |
112 | ||
fe8ab488 A |
113 | enum fs_type_num { |
114 | FT_NFS = 2, | |
fe8ab488 A |
115 | FT_DEVFS = 19, |
116 | FT_SYNTHFS = 20, | |
490019cf | 117 | FT_ROUTEFS = 21, |
39037602 | 118 | FT_NULLFS = 22, |
fe8ab488 A |
119 | FT_MOCKFS = 0x6D6F636B |
120 | }; | |
121 | ||
1c79356b A |
122 | /* |
123 | * Set up the filesystem operations for vnodes. | |
124 | */ | |
6601e61a | 125 | static struct vfstable vfstbllist[] = { |
1c79356b | 126 | /* Sun-compatible Network Filesystem */ |
ea3f0419 | 127 | #if CONFIG_NFS_CLIENT |
cb323159 A |
128 | { |
129 | .vfc_vfsops = &nfs_vfsops, | |
130 | .vfc_name = "nfs", | |
131 | .vfc_typenum = FT_NFS, | |
132 | .vfc_refcount = 0, | |
133 | .vfc_flags = 0, | |
134 | .vfc_mountroot = NULL, | |
135 | .vfc_next = NULL, | |
136 | .vfc_reserved1 = 0, | |
137 | .vfc_reserved2 = 0, | |
138 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFSPREFLIGHT | VFC_VFS64BITREADY | VFC_VFSREADDIR_EXTENDED, | |
139 | .vfc_descptr = NULL, | |
140 | .vfc_descsize = 0, | |
141 | .vfc_sysctl = NULL | |
142 | }, | |
ea3f0419 | 143 | #endif /* CONFIG_NFS_CLIENT */ |
1c79356b | 144 | |
1c79356b A |
145 | /* Device Filesystem */ |
146 | #if DEVFS | |
2d21ac55 | 147 | #if CONFIG_MACF |
cb323159 A |
148 | { |
149 | .vfc_vfsops = &devfs_vfsops, | |
150 | .vfc_name = "devfs", | |
151 | .vfc_typenum = FT_DEVFS, | |
152 | .vfc_refcount = 0, | |
153 | .vfc_flags = MNT_MULTILABEL, | |
154 | .vfc_mountroot = NULL, | |
155 | .vfc_next = NULL, | |
156 | .vfc_reserved1 = 0, | |
157 | .vfc_reserved2 = 0, | |
158 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
159 | .vfc_descptr = NULL, | |
160 | .vfc_descsize = 0, | |
161 | .vfc_sysctl = NULL | |
162 | }, | |
163 | #else /* !CONFIG_MAC */ | |
164 | { | |
165 | .vfc_vfsops = &devfs_vfsops, | |
166 | .vfc_name = "devfs", | |
167 | .vfc_typenum = FT_DEVFS, | |
168 | .vfc_refcount = 0, | |
169 | .vfc_flags = 0, | |
170 | .vfc_mountroot = NULL, | |
171 | .vfc_next = NULL, | |
172 | .vfc_reserved1 = 0, | |
173 | .vfc_reserved2 = 0, | |
174 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
175 | .vfc_descptr = NULL, | |
176 | .vfc_descsize = 0, | |
177 | .vfc_sysctl = NULL | |
178 | }, | |
179 | #endif /* CONFIG_MAC */ | |
180 | #endif /* DEVFS */ | |
9bccf70c | 181 | |
b0d623f7 A |
182 | #ifndef __LP64__ |
183 | #endif /* __LP64__ */ | |
2d21ac55 | 184 | |
39037602 | 185 | #if NULLFS |
cb323159 A |
186 | { |
187 | .vfc_vfsops = &nullfs_vfsops, | |
188 | .vfc_name = "nullfs", | |
189 | .vfc_typenum = FT_NULLFS, | |
190 | .vfc_refcount = 0, | |
191 | .vfc_flags = MNT_DONTBROWSE | MNT_RDONLY, | |
192 | .vfc_mountroot = NULL, | |
193 | .vfc_next = NULL, | |
194 | .vfc_reserved1 = 0, | |
195 | .vfc_reserved2 = 0, | |
196 | .vfc_vfsflags = VFC_VFS64BITREADY, | |
197 | .vfc_descptr = NULL, | |
198 | .vfc_descsize = 0, | |
199 | .vfc_sysctl = NULL | |
200 | }, | |
39037602 A |
201 | #endif /* NULLFS */ |
202 | ||
39236c6e A |
203 | #if MOCKFS |
204 | /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */ | |
cb323159 A |
205 | { |
206 | .vfc_vfsops = &mockfs_vfsops, | |
207 | .vfc_name = "mockfs", | |
208 | .vfc_typenum = FT_MOCKFS, | |
209 | .vfc_refcount = 0, | |
210 | .vfc_flags = MNT_LOCAL, | |
211 | .vfc_mountroot = mockfs_mountroot, | |
212 | .vfc_next = NULL, | |
213 | .vfc_reserved1 = 0, | |
214 | .vfc_reserved2 = 0, | |
215 | .vfc_vfsflags = VFC_VFSGENERICARGS, | |
216 | .vfc_descptr = NULL, | |
217 | .vfc_descsize = 0, | |
218 | .vfc_sysctl = NULL | |
219 | }, | |
39236c6e A |
220 | #endif /* MOCKFS */ |
221 | ||
490019cf A |
222 | #if ROUTEFS |
223 | /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */ | |
cb323159 A |
224 | { |
225 | .vfc_vfsops = &routefs_vfsops, | |
226 | .vfc_name = "routefs", | |
227 | .vfc_typenum = FT_ROUTEFS, | |
228 | .vfc_refcount = 0, | |
229 | .vfc_flags = MNT_LOCAL, | |
230 | .vfc_mountroot = NULL, | |
231 | .vfc_next = NULL, | |
232 | .vfc_reserved1 = 0, | |
233 | .vfc_reserved2 = 0, | |
234 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
235 | .vfc_descptr = NULL, | |
236 | .vfc_descsize = 0, | |
237 | .vfc_sysctl = NULL | |
238 | }, | |
490019cf | 239 | #endif /* ROUTEFS */ |
cb323159 A |
240 | |
241 | { | |
242 | .vfc_vfsops = NULL, | |
243 | .vfc_name = "<unassigned>", | |
244 | .vfc_typenum = 0, | |
245 | .vfc_refcount = 0, | |
246 | .vfc_flags = 0, | |
247 | .vfc_mountroot = NULL, | |
248 | .vfc_next = NULL, | |
249 | .vfc_reserved1 = 0, | |
250 | .vfc_reserved2 = 0, | |
251 | .vfc_vfsflags = 0, | |
252 | .vfc_descptr = NULL, | |
253 | .vfc_descsize = 0, | |
254 | .vfc_sysctl = NULL | |
255 | }, | |
256 | { | |
257 | .vfc_vfsops = NULL, | |
258 | .vfc_name = "<unassigned>", | |
259 | .vfc_typenum = 0, | |
260 | .vfc_refcount = 0, | |
261 | .vfc_flags = 0, | |
262 | .vfc_mountroot = NULL, | |
263 | .vfc_next = NULL, | |
264 | .vfc_reserved1 = 0, | |
265 | .vfc_reserved2 = 0, | |
266 | .vfc_vfsflags = 0, | |
267 | .vfc_descptr = NULL, | |
268 | .vfc_descsize = 0, | |
269 | .vfc_sysctl = NULL | |
270 | }, | |
1c79356b A |
271 | }; |
272 | ||
273 | /* | |
fe8ab488 | 274 | * vfs_init will set maxvfstypenum to the highest defined type number. |
1c79356b | 275 | */ |
0a7de745 | 276 | const int maxvfsslots = sizeof(vfstbllist) / sizeof(struct vfstable); |
1c79356b | 277 | int numused_vfsslots = 0; |
fe8ab488 A |
278 | int numregistered_fses = 0; |
279 | int maxvfstypenum = VT_NON + 1; | |
6601e61a | 280 | struct vfstable *vfsconf = vfstbllist; |
1c79356b A |
281 | |
282 | /* | |
283 | * | |
284 | * vfs_opv_descs enumerates the list of vnode classes, each with it's own | |
285 | * vnode operation vector. It is consulted at system boot to build operation | |
286 | * vectors. It is NULL terminated. | |
287 | * | |
288 | */ | |
1c79356b | 289 | extern struct vnodeopv_desc mfs_vnodeop_opv_desc; |
cb323159 | 290 | extern const struct vnodeopv_desc dead_vnodeop_opv_desc; |
2d21ac55 | 291 | #if FIFO && SOCKETS |
cb323159 | 292 | extern const struct vnodeopv_desc fifo_vnodeop_opv_desc; |
2d21ac55 | 293 | #endif /* SOCKETS */ |
cb323159 A |
294 | extern const struct vnodeopv_desc spec_vnodeop_opv_desc; |
295 | extern const struct vnodeopv_desc nfsv2_vnodeop_opv_desc; | |
296 | extern const struct vnodeopv_desc spec_nfsv2nodeop_opv_desc; | |
297 | extern const struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc; | |
298 | #if CONFIG_NFS4 | |
299 | extern const struct vnodeopv_desc nfsv4_vnodeop_opv_desc; | |
300 | extern const struct vnodeopv_desc spec_nfsv4nodeop_opv_desc; | |
301 | extern const struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc; | |
302 | #endif | |
1c79356b | 303 | extern struct vnodeopv_desc null_vnodeop_opv_desc; |
1c79356b A |
304 | extern struct vnodeopv_desc devfs_vnodeop_opv_desc; |
305 | extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc; | |
b0d623f7 A |
306 | #if FDESC |
307 | extern struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc; | |
cb323159 | 308 | extern const struct vnodeopv_desc devfs_fdesc_vnodeop_opv_desc; |
b0d623f7 | 309 | #endif /* FDESC */ |
1c79356b | 310 | |
39236c6e | 311 | #if MOCKFS |
cb323159 | 312 | extern const struct vnodeopv_desc mockfs_vnodeop_opv_desc; |
39236c6e A |
313 | #endif /* MOCKFS */ |
314 | ||
cb323159 | 315 | extern const struct vnodeopv_desc nullfs_vnodeop_opv_desc; |
39037602 | 316 | |
cb323159 | 317 | const struct vnodeopv_desc *vfs_opv_descs[] = { |
1c79356b | 318 | &dead_vnodeop_opv_desc, |
2d21ac55 | 319 | #if FIFO && SOCKETS |
1c79356b A |
320 | &fifo_vnodeop_opv_desc, |
321 | #endif | |
322 | &spec_vnodeop_opv_desc, | |
1c79356b A |
323 | #if MFS |
324 | &mfs_vnodeop_opv_desc, | |
325 | #endif | |
ea3f0419 | 326 | #if CONFIG_NFS_CLIENT |
1c79356b A |
327 | &nfsv2_vnodeop_opv_desc, |
328 | &spec_nfsv2nodeop_opv_desc, | |
cb323159 | 329 | #if CONFIG_NFS4 |
2d21ac55 A |
330 | &nfsv4_vnodeop_opv_desc, |
331 | &spec_nfsv4nodeop_opv_desc, | |
cb323159 | 332 | #endif |
1c79356b A |
333 | #if FIFO |
334 | &fifo_nfsv2nodeop_opv_desc, | |
cb323159 | 335 | #if CONFIG_NFS4 |
2d21ac55 | 336 | &fifo_nfsv4nodeop_opv_desc, |
cb323159 A |
337 | #endif /* CONFIG_NFS4 */ |
338 | #endif /* FIFO */ | |
ea3f0419 | 339 | #endif /* CONFIG_NFS_CLIENT */ |
1c79356b A |
340 | #if DEVFS |
341 | &devfs_vnodeop_opv_desc, | |
342 | &devfs_spec_vnodeop_opv_desc, | |
b0d623f7 A |
343 | #if FDESC |
344 | &devfs_devfd_vnodeop_opv_desc, | |
345 | &devfs_fdesc_vnodeop_opv_desc, | |
346 | #endif /* FDESC */ | |
347 | #endif /* DEVFS */ | |
39037602 A |
348 | #if NULLFS |
349 | &nullfs_vnodeop_opv_desc, | |
350 | #endif /* NULLFS */ | |
39236c6e A |
351 | #if MOCKFS |
352 | &mockfs_vnodeop_opv_desc, | |
353 | #endif /* MOCKFS */ | |
1c79356b A |
354 | NULL |
355 | }; |