]>
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 A |
74 | |
75 | /* | |
76 | * These define the root filesystem, device, and root filesystem type. | |
77 | */ | |
78 | struct mount *rootfs; | |
79 | struct vnode *rootvnode; | |
b7266188 A |
80 | |
81 | #ifdef CONFIG_IMGSRC_ACCESS | |
0a7de745 | 82 | struct vnode *imgsrc_rootvnodes[MAX_IMAGEBOOT_NESTING]; /* [0] -> source volume, [1] -> first disk image */ |
6d2010ae | 83 | #endif /* CONFIG_IMGSRC_ACCESS */ |
b7266188 | 84 | |
2d21ac55 | 85 | int (*mountroot)(void) = NULL; |
1c79356b A |
86 | |
87 | /* | |
88 | * Set up the initial array of known filesystem types. | |
89 | */ | |
0a7de745 A |
90 | extern struct vfsops mfs_vfsops; |
91 | extern int mfs_mountroot(mount_t, vnode_t, vfs_context_t); /* dead */ | |
92 | extern struct vfsops nfs_vfsops; | |
93 | extern int nfs_mountroot(void); | |
94 | extern struct vfsops afs_vfsops; | |
95 | extern struct vfsops null_vfsops; | |
96 | extern struct vfsops devfs_vfsops; | |
cb323159 | 97 | extern const struct vfsops routefs_vfsops; |
39037602 | 98 | extern struct vfsops nullfs_vfsops; |
1c79356b | 99 | |
39236c6e | 100 | #if MOCKFS |
0a7de745 A |
101 | extern struct vfsops mockfs_vfsops; |
102 | extern int mockfs_mountroot(mount_t, vnode_t, vfs_context_t); | |
39236c6e A |
103 | #endif /* MOCKFS */ |
104 | ||
2d21ac55 A |
105 | /* |
106 | * For nfs_mountroot(void) cast. nfs_mountroot ignores its parameters, if | |
107 | * invoked through this table. | |
108 | */ | |
109 | typedef int (*mountroot_t)(mount_t, vnode_t, vfs_context_t); | |
110 | ||
fe8ab488 A |
111 | enum fs_type_num { |
112 | FT_NFS = 2, | |
fe8ab488 A |
113 | FT_DEVFS = 19, |
114 | FT_SYNTHFS = 20, | |
490019cf | 115 | FT_ROUTEFS = 21, |
39037602 | 116 | FT_NULLFS = 22, |
fe8ab488 A |
117 | FT_MOCKFS = 0x6D6F636B |
118 | }; | |
119 | ||
1c79356b A |
120 | /* |
121 | * Set up the filesystem operations for vnodes. | |
122 | */ | |
6601e61a | 123 | static struct vfstable vfstbllist[] = { |
1c79356b A |
124 | /* Sun-compatible Network Filesystem */ |
125 | #if NFSCLIENT | |
cb323159 A |
126 | { |
127 | .vfc_vfsops = &nfs_vfsops, | |
128 | .vfc_name = "nfs", | |
129 | .vfc_typenum = FT_NFS, | |
130 | .vfc_refcount = 0, | |
131 | .vfc_flags = 0, | |
132 | .vfc_mountroot = NULL, | |
133 | .vfc_next = NULL, | |
134 | .vfc_reserved1 = 0, | |
135 | .vfc_reserved2 = 0, | |
136 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFSPREFLIGHT | VFC_VFS64BITREADY | VFC_VFSREADDIR_EXTENDED, | |
137 | .vfc_descptr = NULL, | |
138 | .vfc_descsize = 0, | |
139 | .vfc_sysctl = NULL | |
140 | }, | |
141 | #endif /* NFSCLIENT */ | |
1c79356b | 142 | |
1c79356b A |
143 | /* Device Filesystem */ |
144 | #if DEVFS | |
2d21ac55 | 145 | #if CONFIG_MACF |
cb323159 A |
146 | { |
147 | .vfc_vfsops = &devfs_vfsops, | |
148 | .vfc_name = "devfs", | |
149 | .vfc_typenum = FT_DEVFS, | |
150 | .vfc_refcount = 0, | |
151 | .vfc_flags = MNT_MULTILABEL, | |
152 | .vfc_mountroot = NULL, | |
153 | .vfc_next = NULL, | |
154 | .vfc_reserved1 = 0, | |
155 | .vfc_reserved2 = 0, | |
156 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
157 | .vfc_descptr = NULL, | |
158 | .vfc_descsize = 0, | |
159 | .vfc_sysctl = NULL | |
160 | }, | |
161 | #else /* !CONFIG_MAC */ | |
162 | { | |
163 | .vfc_vfsops = &devfs_vfsops, | |
164 | .vfc_name = "devfs", | |
165 | .vfc_typenum = FT_DEVFS, | |
166 | .vfc_refcount = 0, | |
167 | .vfc_flags = 0, | |
168 | .vfc_mountroot = NULL, | |
169 | .vfc_next = NULL, | |
170 | .vfc_reserved1 = 0, | |
171 | .vfc_reserved2 = 0, | |
172 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
173 | .vfc_descptr = NULL, | |
174 | .vfc_descsize = 0, | |
175 | .vfc_sysctl = NULL | |
176 | }, | |
177 | #endif /* CONFIG_MAC */ | |
178 | #endif /* DEVFS */ | |
9bccf70c | 179 | |
b0d623f7 A |
180 | #ifndef __LP64__ |
181 | #endif /* __LP64__ */ | |
2d21ac55 | 182 | |
39037602 | 183 | #if NULLFS |
cb323159 A |
184 | { |
185 | .vfc_vfsops = &nullfs_vfsops, | |
186 | .vfc_name = "nullfs", | |
187 | .vfc_typenum = FT_NULLFS, | |
188 | .vfc_refcount = 0, | |
189 | .vfc_flags = MNT_DONTBROWSE | MNT_RDONLY, | |
190 | .vfc_mountroot = NULL, | |
191 | .vfc_next = NULL, | |
192 | .vfc_reserved1 = 0, | |
193 | .vfc_reserved2 = 0, | |
194 | .vfc_vfsflags = VFC_VFS64BITREADY, | |
195 | .vfc_descptr = NULL, | |
196 | .vfc_descsize = 0, | |
197 | .vfc_sysctl = NULL | |
198 | }, | |
39037602 A |
199 | #endif /* NULLFS */ |
200 | ||
39236c6e A |
201 | #if MOCKFS |
202 | /* 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 |
203 | { |
204 | .vfc_vfsops = &mockfs_vfsops, | |
205 | .vfc_name = "mockfs", | |
206 | .vfc_typenum = FT_MOCKFS, | |
207 | .vfc_refcount = 0, | |
208 | .vfc_flags = MNT_LOCAL, | |
209 | .vfc_mountroot = mockfs_mountroot, | |
210 | .vfc_next = NULL, | |
211 | .vfc_reserved1 = 0, | |
212 | .vfc_reserved2 = 0, | |
213 | .vfc_vfsflags = VFC_VFSGENERICARGS, | |
214 | .vfc_descptr = NULL, | |
215 | .vfc_descsize = 0, | |
216 | .vfc_sysctl = NULL | |
217 | }, | |
39236c6e A |
218 | #endif /* MOCKFS */ |
219 | ||
490019cf A |
220 | #if ROUTEFS |
221 | /* 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 |
222 | { |
223 | .vfc_vfsops = &routefs_vfsops, | |
224 | .vfc_name = "routefs", | |
225 | .vfc_typenum = FT_ROUTEFS, | |
226 | .vfc_refcount = 0, | |
227 | .vfc_flags = MNT_LOCAL, | |
228 | .vfc_mountroot = NULL, | |
229 | .vfc_next = NULL, | |
230 | .vfc_reserved1 = 0, | |
231 | .vfc_reserved2 = 0, | |
232 | .vfc_vfsflags = VFC_VFSGENERICARGS | VFC_VFS64BITREADY, | |
233 | .vfc_descptr = NULL, | |
234 | .vfc_descsize = 0, | |
235 | .vfc_sysctl = NULL | |
236 | }, | |
490019cf | 237 | #endif /* ROUTEFS */ |
cb323159 A |
238 | |
239 | { | |
240 | .vfc_vfsops = NULL, | |
241 | .vfc_name = "<unassigned>", | |
242 | .vfc_typenum = 0, | |
243 | .vfc_refcount = 0, | |
244 | .vfc_flags = 0, | |
245 | .vfc_mountroot = NULL, | |
246 | .vfc_next = NULL, | |
247 | .vfc_reserved1 = 0, | |
248 | .vfc_reserved2 = 0, | |
249 | .vfc_vfsflags = 0, | |
250 | .vfc_descptr = NULL, | |
251 | .vfc_descsize = 0, | |
252 | .vfc_sysctl = NULL | |
253 | }, | |
254 | { | |
255 | .vfc_vfsops = NULL, | |
256 | .vfc_name = "<unassigned>", | |
257 | .vfc_typenum = 0, | |
258 | .vfc_refcount = 0, | |
259 | .vfc_flags = 0, | |
260 | .vfc_mountroot = NULL, | |
261 | .vfc_next = NULL, | |
262 | .vfc_reserved1 = 0, | |
263 | .vfc_reserved2 = 0, | |
264 | .vfc_vfsflags = 0, | |
265 | .vfc_descptr = NULL, | |
266 | .vfc_descsize = 0, | |
267 | .vfc_sysctl = NULL | |
268 | }, | |
1c79356b A |
269 | }; |
270 | ||
271 | /* | |
fe8ab488 | 272 | * vfs_init will set maxvfstypenum to the highest defined type number. |
1c79356b | 273 | */ |
0a7de745 | 274 | const int maxvfsslots = sizeof(vfstbllist) / sizeof(struct vfstable); |
1c79356b | 275 | int numused_vfsslots = 0; |
fe8ab488 A |
276 | int numregistered_fses = 0; |
277 | int maxvfstypenum = VT_NON + 1; | |
6601e61a | 278 | struct vfstable *vfsconf = vfstbllist; |
1c79356b A |
279 | |
280 | /* | |
281 | * | |
282 | * vfs_opv_descs enumerates the list of vnode classes, each with it's own | |
283 | * vnode operation vector. It is consulted at system boot to build operation | |
284 | * vectors. It is NULL terminated. | |
285 | * | |
286 | */ | |
1c79356b | 287 | extern struct vnodeopv_desc mfs_vnodeop_opv_desc; |
cb323159 | 288 | extern const struct vnodeopv_desc dead_vnodeop_opv_desc; |
2d21ac55 | 289 | #if FIFO && SOCKETS |
cb323159 | 290 | extern const struct vnodeopv_desc fifo_vnodeop_opv_desc; |
2d21ac55 | 291 | #endif /* SOCKETS */ |
cb323159 A |
292 | extern const struct vnodeopv_desc spec_vnodeop_opv_desc; |
293 | extern const struct vnodeopv_desc nfsv2_vnodeop_opv_desc; | |
294 | extern const struct vnodeopv_desc spec_nfsv2nodeop_opv_desc; | |
295 | extern const struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc; | |
296 | #if CONFIG_NFS4 | |
297 | extern const struct vnodeopv_desc nfsv4_vnodeop_opv_desc; | |
298 | extern const struct vnodeopv_desc spec_nfsv4nodeop_opv_desc; | |
299 | extern const struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc; | |
300 | #endif | |
1c79356b | 301 | extern struct vnodeopv_desc null_vnodeop_opv_desc; |
1c79356b A |
302 | extern struct vnodeopv_desc devfs_vnodeop_opv_desc; |
303 | extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc; | |
b0d623f7 A |
304 | #if FDESC |
305 | extern struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc; | |
cb323159 | 306 | extern const struct vnodeopv_desc devfs_fdesc_vnodeop_opv_desc; |
b0d623f7 | 307 | #endif /* FDESC */ |
1c79356b | 308 | |
39236c6e | 309 | #if MOCKFS |
cb323159 | 310 | extern const struct vnodeopv_desc mockfs_vnodeop_opv_desc; |
39236c6e A |
311 | #endif /* MOCKFS */ |
312 | ||
cb323159 | 313 | extern const struct vnodeopv_desc nullfs_vnodeop_opv_desc; |
39037602 | 314 | |
cb323159 | 315 | const struct vnodeopv_desc *vfs_opv_descs[] = { |
1c79356b | 316 | &dead_vnodeop_opv_desc, |
2d21ac55 | 317 | #if FIFO && SOCKETS |
1c79356b A |
318 | &fifo_vnodeop_opv_desc, |
319 | #endif | |
320 | &spec_vnodeop_opv_desc, | |
1c79356b A |
321 | #if MFS |
322 | &mfs_vnodeop_opv_desc, | |
323 | #endif | |
324 | #if NFSCLIENT | |
325 | &nfsv2_vnodeop_opv_desc, | |
326 | &spec_nfsv2nodeop_opv_desc, | |
cb323159 | 327 | #if CONFIG_NFS4 |
2d21ac55 A |
328 | &nfsv4_vnodeop_opv_desc, |
329 | &spec_nfsv4nodeop_opv_desc, | |
cb323159 | 330 | #endif |
1c79356b A |
331 | #if FIFO |
332 | &fifo_nfsv2nodeop_opv_desc, | |
cb323159 | 333 | #if CONFIG_NFS4 |
2d21ac55 | 334 | &fifo_nfsv4nodeop_opv_desc, |
cb323159 A |
335 | #endif /* CONFIG_NFS4 */ |
336 | #endif /* FIFO */ | |
337 | #endif /* NFSCLIENT */ | |
1c79356b A |
338 | #if DEVFS |
339 | &devfs_vnodeop_opv_desc, | |
340 | &devfs_spec_vnodeop_opv_desc, | |
b0d623f7 A |
341 | #if FDESC |
342 | &devfs_devfd_vnodeop_opv_desc, | |
343 | &devfs_fdesc_vnodeop_opv_desc, | |
344 | #endif /* FDESC */ | |
345 | #endif /* DEVFS */ | |
39037602 A |
346 | #if NULLFS |
347 | &nullfs_vnodeop_opv_desc, | |
348 | #endif /* NULLFS */ | |
39236c6e A |
349 | #if MOCKFS |
350 | &mockfs_vnodeop_opv_desc, | |
351 | #endif /* MOCKFS */ | |
1c79356b A |
352 | NULL |
353 | }; |