]> git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vfs_conf.c
xnu-1504.3.12.tar.gz
[apple/xnu.git] / bsd / vfs / vfs_conf.c
1 /*
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
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.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
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
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
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 */
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 */
69
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/mount_internal.h>
73 #include <sys/vnode_internal.h>
74
75 #ifndef __LP64__
76 #define VFS_THREAD_SAFE_FLAG VFC_VFSTHREADSAFE /* This is only defined for 32-bit */
77 #else
78 #define VFS_THREAD_SAFE_FLAG 0
79 #endif /* __LP64__ */
80
81
82 /*
83 * These define the root filesystem, device, and root filesystem type.
84 */
85 struct mount *rootfs;
86 struct vnode *rootvnode;
87
88 #ifdef CONFIG_IMGSRC_ACCESS
89 struct vnode *imgsrc_rootvnode;
90 #endif /* IMGSRC_ACESS */
91
92 int (*mountroot)(void) = NULL;
93
94 /*
95 * Set up the initial array of known filesystem types.
96 */
97 extern struct vfsops mfs_vfsops;
98 extern int mfs_mountroot(mount_t, vnode_t, vfs_context_t); /* dead */
99 extern struct vfsops hfs_vfsops;
100 extern int hfs_mountroot(mount_t, vnode_t, vfs_context_t);
101 extern struct vfsops nfs_vfsops;
102 extern int nfs_mountroot(void);
103 extern struct vfsops afs_vfsops;
104 extern struct vfsops null_vfsops;
105 extern struct vfsops union_vfsops;
106 extern struct vfsops devfs_vfsops;
107
108 /*
109 * For nfs_mountroot(void) cast. nfs_mountroot ignores its parameters, if
110 * invoked through this table.
111 */
112 typedef int (*mountroot_t)(mount_t, vnode_t, vfs_context_t);
113
114 /*
115 * Set up the filesystem operations for vnodes.
116 */
117 static struct vfstable vfstbllist[] = {
118 /* HFS/HFS+ Filesystem */
119 #if HFS
120 { &hfs_vfsops, "hfs", 17, 0, (MNT_LOCAL | MNT_DOVOLFS), hfs_mountroot, NULL, 0, 0, VFC_VFSLOCALARGS | VFC_VFSREADDIR_EXTENDED | VFS_THREAD_SAFE_FLAG | VFC_VFS64BITREADY | VFC_VFSVNOP_PAGEOUTV2, NULL, 0},
121 #endif
122
123 /* Memory-based Filesystem */
124
125 #ifndef __LP64__
126 #if MFS
127 { &mfs_vfsops, "mfs", 3, 0, MNT_LOCAL, mfs_mountroot, NULL, 0, 0, VFC_VFSGENERICARGS, NULL, 0},
128 #endif
129 #endif /* __LP64__ */
130
131 /* Sun-compatible Network Filesystem */
132 #if NFSCLIENT
133 { &nfs_vfsops, "nfs", 2, 0, 0, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFC_VFSPREFLIGHT | VFS_THREAD_SAFE_FLAG | VFC_VFS64BITREADY | VFC_VFSREADDIR_EXTENDED, NULL, 0},
134 #endif
135
136 /* Andrew Filesystem */
137 #ifndef __LP64__
138 #if AFS
139 { &afs_vfsops, "andrewfs", 13, 0, 0, afs_mountroot, NULL, 0, 0, VFC_VFSGENERICARGS , NULL, 0},
140 #endif
141 #endif /* __LP64__ */
142
143 /* Loopback (Minimal) Filesystem Layer */
144 #ifndef __LP64__
145 #if NULLFS
146 { &null_vfsops, "loopback", 9, 0, 0, NULL, NULL, 0, 0, VFC_VFSGENERICARGS , NULL, 0},
147 #endif
148 #endif /* __LP64__ */
149
150 /* Union (translucent) Filesystem */
151 #if UNION
152 { &union_vfsops, "unionfs", 15, 0, 0, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFS_THREAD_SAFE_FLAG | VFC_VFS64BITREADY, NULL, 0},
153 #endif
154
155 /* Device Filesystem */
156 #if DEVFS
157 #if CONFIG_MACF
158 { &devfs_vfsops, "devfs", 19, 0, (MNT_DONTBROWSE | MNT_MULTILABEL), NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFS_THREAD_SAFE_FLAG | VFC_VFS64BITREADY, NULL, 0},
159 #else
160 { &devfs_vfsops, "devfs", 19, 0, MNT_DONTBROWSE, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFS_THREAD_SAFE_FLAG | VFC_VFS64BITREADY, NULL, 0},
161 #endif /* MAC */
162 #endif
163
164 #ifndef __LP64__
165 #endif /* __LP64__ */
166
167 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
168 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
169 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
170 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
171 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
172 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
173 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
174 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
175 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
176 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
177 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
178 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
179 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
180 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0},
181 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0}
182 };
183
184 /*
185 * Initially the size of the list, vfs_init will set maxvfsconf
186 * to the highest defined type number.
187 */
188 int maxvfsslots = sizeof(vfstbllist) / sizeof (struct vfstable);
189 int numused_vfsslots = 0;
190 int maxvfsconf = sizeof(vfstbllist) / sizeof (struct vfstable);
191 struct vfstable *vfsconf = vfstbllist;
192
193 /*
194 *
195 * vfs_opv_descs enumerates the list of vnode classes, each with it's own
196 * vnode operation vector. It is consulted at system boot to build operation
197 * vectors. It is NULL terminated.
198 *
199 */
200 extern struct vnodeopv_desc mfs_vnodeop_opv_desc;
201 extern struct vnodeopv_desc dead_vnodeop_opv_desc;
202 #if FIFO && SOCKETS
203 extern struct vnodeopv_desc fifo_vnodeop_opv_desc;
204 #endif /* SOCKETS */
205 extern struct vnodeopv_desc spec_vnodeop_opv_desc;
206 extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc;
207 extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc;
208 extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc;
209 extern struct vnodeopv_desc nfsv4_vnodeop_opv_desc;
210 extern struct vnodeopv_desc spec_nfsv4nodeop_opv_desc;
211 extern struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc;
212 extern struct vnodeopv_desc null_vnodeop_opv_desc;
213 extern struct vnodeopv_desc hfs_vnodeop_opv_desc;
214 extern struct vnodeopv_desc hfs_std_vnodeop_opv_desc;
215 extern struct vnodeopv_desc hfs_specop_opv_desc;
216 extern struct vnodeopv_desc hfs_fifoop_opv_desc;
217 extern struct vnodeopv_desc union_vnodeop_opv_desc;
218 extern struct vnodeopv_desc devfs_vnodeop_opv_desc;
219 extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc;
220 #if FDESC
221 extern struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc;
222 extern struct vnodeopv_desc devfs_fdesc_vnodeop_opv_desc;
223 #endif /* FDESC */
224
225 struct vnodeopv_desc *vfs_opv_descs[] = {
226 &dead_vnodeop_opv_desc,
227 #if FIFO && SOCKETS
228 &fifo_vnodeop_opv_desc,
229 #endif
230 &spec_vnodeop_opv_desc,
231 #if MFS
232 &mfs_vnodeop_opv_desc,
233 #endif
234 #if NFSCLIENT
235 &nfsv2_vnodeop_opv_desc,
236 &spec_nfsv2nodeop_opv_desc,
237 &nfsv4_vnodeop_opv_desc,
238 &spec_nfsv4nodeop_opv_desc,
239 #if FIFO
240 &fifo_nfsv2nodeop_opv_desc,
241 &fifo_nfsv4nodeop_opv_desc,
242 #endif
243 #endif
244 #if NULLFS
245 &null_vnodeop_opv_desc,
246 #endif
247 #if HFS
248 &hfs_vnodeop_opv_desc,
249 &hfs_std_vnodeop_opv_desc,
250 &hfs_specop_opv_desc,
251 #if FIFO
252 &hfs_fifoop_opv_desc,
253 #endif
254 #endif
255 #if UNION
256 &union_vnodeop_opv_desc,
257 #endif
258 #if DEVFS
259 &devfs_vnodeop_opv_desc,
260 &devfs_spec_vnodeop_opv_desc,
261 #if FDESC
262 &devfs_devfd_vnodeop_opv_desc,
263 &devfs_fdesc_vnodeop_opv_desc,
264 #endif /* FDESC */
265 #endif /* DEVFS */
266 NULL
267 };