]> git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vfs_conf.c
ee09626e12359d95a3752074c1544729ebcb21d6
[apple/xnu.git] / bsd / vfs / vfs_conf.c
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
31 /*
32 * Copyright (c) 1989, 1993, 1995
33 * The Regents of the University of California. All rights reserved.
34 *
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
37 * are met:
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
50 *
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
61 * SUCH DAMAGE.
62 *
63 * @(#)vfs_conf.c 8.11 (Berkeley) 5/10/95
64 */
65
66 #include <sys/param.h>
67 #include <sys/systm.h>
68 #include <sys/mount_internal.h>
69 #include <sys/vnode_internal.h>
70
71 /*
72 * These define the root filesystem, device, and root filesystem type.
73 */
74 struct mount *rootfs;
75 struct vnode *rootvnode;
76 int (*mountroot)() = NULL;
77
78 /*
79 * Set up the initial array of known filesystem types.
80 */
81 extern struct vfsops ufs_vfsops;
82 #if FFS
83 extern int ffs_mountroot();
84 #endif
85 extern struct vfsops mfs_vfsops;
86 extern int mfs_mountroot();
87 extern struct vfsops hfs_vfsops;
88 extern int hfs_mountroot();
89 extern struct vfsops volfs_vfsops;
90 extern struct vfsops cd9660_vfsops;
91 extern int cd9660_mountroot();
92 extern struct vfsops nfs_vfsops;
93 extern int nfs_mountroot();
94 extern struct vfsops afs_vfsops;
95 extern struct vfsops null_vfsops;
96 extern struct vfsops union_vfsops;
97 extern struct vfsops fdesc_vfsops;
98 extern struct vfsops devfs_vfsops;
99
100 /*
101 * Set up the filesystem operations for vnodes.
102 */
103 static struct vfstable vfsconflist[] = {
104 /* HFS/HFS+ Filesystem */
105 #if HFS
106 { &hfs_vfsops, "hfs", 17, 0, MNT_LOCAL | MNT_DOVOLFS, hfs_mountroot, NULL, 0, {0}, VFC_VFSLOCALARGS, 0, 0 },
107 #endif
108
109 /* Fast Filesystem */
110 #if FFS
111 { &ufs_vfsops, "ufs", 1, 0, MNT_LOCAL, ffs_mountroot, NULL, 0, {0}, VFC_VFSLOCALARGS, 0, 0 },
112 #endif
113
114 /* ISO9660 (aka CDROM) Filesystem */
115 #if CD9660
116 { &cd9660_vfsops, "cd9660", 14, 0, MNT_LOCAL, cd9660_mountroot, NULL, 0, {0}, VFC_VFSLOCALARGS, 0, 0 },
117 #endif
118
119 /* Memory-based Filesystem */
120 #if MFS
121 { &mfs_vfsops, "mfs", 3, 0, MNT_LOCAL, mfs_mountroot, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
122 #endif
123
124 /* Sun-compatible Network Filesystem */
125 #if NFSCLIENT
126 { &nfs_vfsops, "nfs", 2, 0, 0, nfs_mountroot, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
127 #endif
128
129 /* Andrew Filesystem */
130 #if AFS
131 { &afs_vfsops, "andrewfs", 13, 0, 0, afs_mountroot, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
132 #endif
133
134 /* Loopback (Minimal) Filesystem Layer */
135 #if NULLFS
136 { &null_vfsops, "loopback", 9, 0, 0, NULL, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
137 #endif
138
139 /* Union (translucent) Filesystem */
140 #if UNION
141 { &union_vfsops, "union", 15, 0, 0, NULL, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
142 #endif
143
144 /* File Descriptor Filesystem */
145 #if FDESC
146 { &fdesc_vfsops, "fdesc", 7, 0, 0, NULL, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
147 #endif
148
149 /* Volume ID Filesystem */
150 #if VOLFS
151 { &volfs_vfsops, "volfs", 18, 0, 0, NULL, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
152 #endif
153
154 /* Device Filesystem */
155 #if DEVFS
156 { &devfs_vfsops, "devfs", 19, 0, 0, NULL, NULL, 0, {0}, VFC_VFSGENERICARGS , 0, 0},
157 #endif
158
159 {0},
160 {0},
161 {0},
162 {0},
163 {0},
164 {0},
165 {0},
166 {0},
167 {0},
168 {0},
169 {0},
170 {0},
171 {0},
172 {0}
173 };
174
175 /*
176 * Initially the size of the list, vfs_init will set maxvfsconf
177 * to the highest defined type number.
178 */
179 int maxvfsslots = sizeof(vfsconflist) / sizeof (struct vfsconf);
180 int numused_vfsslots = 0;
181 int maxvfsconf = sizeof(vfsconflist) / sizeof (struct vfsconf);
182 struct vfstable *vfsconf = vfsconflist;
183
184 /*
185 *
186 * vfs_opv_descs enumerates the list of vnode classes, each with it's own
187 * vnode operation vector. It is consulted at system boot to build operation
188 * vectors. It is NULL terminated.
189 *
190 */
191 #if FFS
192 extern struct vnodeopv_desc ffs_vnodeop_opv_desc;
193 extern struct vnodeopv_desc ffs_specop_opv_desc;
194 extern struct vnodeopv_desc ffs_fifoop_opv_desc;
195 #endif
196 extern struct vnodeopv_desc mfs_vnodeop_opv_desc;
197 extern struct vnodeopv_desc dead_vnodeop_opv_desc;
198 extern struct vnodeopv_desc fifo_vnodeop_opv_desc;
199 extern struct vnodeopv_desc spec_vnodeop_opv_desc;
200 extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc;
201 extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc;
202 extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc;
203 extern struct vnodeopv_desc fdesc_vnodeop_opv_desc;
204 extern struct vnodeopv_desc null_vnodeop_opv_desc;
205 extern struct vnodeopv_desc hfs_vnodeop_opv_desc;
206 extern struct vnodeopv_desc hfs_specop_opv_desc;
207 extern struct vnodeopv_desc hfs_fifoop_opv_desc;
208 extern struct vnodeopv_desc volfs_vnodeop_opv_desc;
209 extern struct vnodeopv_desc cd9660_vnodeop_opv_desc;
210 extern struct vnodeopv_desc cd9660_cdxaop_opv_desc;
211 extern struct vnodeopv_desc cd9660_specop_opv_desc;
212 extern struct vnodeopv_desc cd9660_fifoop_opv_desc;
213 extern struct vnodeopv_desc union_vnodeop_opv_desc;
214 extern struct vnodeopv_desc devfs_vnodeop_opv_desc;
215 extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc;
216
217 struct vnodeopv_desc *vfs_opv_descs[] = {
218 #if FFS
219 &ffs_vnodeop_opv_desc,
220 &ffs_specop_opv_desc,
221 #if FIFO
222 &ffs_fifoop_opv_desc,
223 #endif
224 #endif
225 &dead_vnodeop_opv_desc,
226 #if FIFO
227 &fifo_vnodeop_opv_desc,
228 #endif
229 &spec_vnodeop_opv_desc,
230 #if MFS
231 &mfs_vnodeop_opv_desc,
232 #endif
233 #if NFSCLIENT
234 &nfsv2_vnodeop_opv_desc,
235 &spec_nfsv2nodeop_opv_desc,
236 #if FIFO
237 &fifo_nfsv2nodeop_opv_desc,
238 #endif
239 #endif
240 #if FDESC
241 &fdesc_vnodeop_opv_desc,
242 #endif
243 #if NULLFS
244 &null_vnodeop_opv_desc,
245 #endif
246 #if HFS
247 &hfs_vnodeop_opv_desc,
248 &hfs_specop_opv_desc,
249 #if FIFO
250 &hfs_fifoop_opv_desc,
251 #endif
252 #endif
253 #if CD9660
254 &cd9660_vnodeop_opv_desc,
255 &cd9660_cdxaop_opv_desc,
256 &cd9660_specop_opv_desc,
257 #if FIFO
258 &cd9660_fifoop_opv_desc,
259 #endif
260 #endif
261 #if UNION
262 &union_vnodeop_opv_desc,
263 #endif
264 #if VOLFS
265 &volfs_vnodeop_opv_desc,
266 #endif
267 #if DEVFS
268 &devfs_vnodeop_opv_desc,
269 &devfs_spec_vnodeop_opv_desc,
270 #endif
271 NULL
272 };