]> git.saurik.com Git - apple/xnu.git/blame - bsd/vfs/vfs_conf.c
xnu-1228.9.59.tar.gz
[apple/xnu.git] / bsd / vfs / vfs_conf.c
CommitLineData
1c79356b 1/*
2d21ac55 2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
5d5c5d0d 3 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 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.
8f6c56a5 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.
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
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.
8f6c56a5 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 */
78struct mount *rootfs;
79struct vnode *rootvnode;
2d21ac55 80int (*mountroot)(void) = NULL;
1c79356b
A
81
82/*
83 * Set up the initial array of known filesystem types.
84 */
85extern struct vfsops ufs_vfsops;
91447636 86#if FFS
2d21ac55 87extern int ffs_mountroot(mount_t, vnode_t, vfs_context_t);
91447636 88#endif
1c79356b 89extern struct vfsops mfs_vfsops;
2d21ac55 90extern int mfs_mountroot(mount_t, vnode_t, vfs_context_t); /* dead */
1c79356b 91extern struct vfsops hfs_vfsops;
2d21ac55 92extern int hfs_mountroot(mount_t, vnode_t, vfs_context_t);
1c79356b 93extern struct vfsops cd9660_vfsops;
2d21ac55 94extern int cd9660_mountroot(mount_t, vnode_t, vfs_context_t);
1c79356b 95extern struct vfsops nfs_vfsops;
2d21ac55 96extern int nfs_mountroot(void);
1c79356b 97extern struct vfsops afs_vfsops;
1c79356b
A
98extern struct vfsops null_vfsops;
99extern struct vfsops union_vfsops;
1c79356b 100extern struct vfsops fdesc_vfsops;
1c79356b
A
101extern struct vfsops devfs_vfsops;
102
2d21ac55
A
103/*
104 * For nfs_mountroot(void) cast. nfs_mountroot ignores its parameters, if
105 * invoked through this table.
106 */
107typedef int (*mountroot_t)(mount_t, vnode_t, vfs_context_t);
108
1c79356b
A
109/*
110 * Set up the filesystem operations for vnodes.
111 */
6601e61a 112static struct vfstable vfstbllist[] = {
1c79356b
A
113 /* HFS/HFS+ Filesystem */
114#if HFS
2d21ac55 115 { &hfs_vfsops, "hfs", 17, 0, (MNT_LOCAL | MNT_DOVOLFS), hfs_mountroot, NULL, 1, {{0}}, VFC_VFSLOCALARGS | VFC_VFSREADDIR_EXTENDED, NULL, 0, 1},
1c79356b
A
116#endif
117
118 /* Fast Filesystem */
119#if FFS
2d21ac55 120 { &ufs_vfsops, "ufs", 1, 0, MNT_LOCAL, ffs_mountroot, NULL, 0, {{0}}, VFC_VFSLOCALARGS | VFC_VFSREADDIR_EXTENDED, NULL, 0, 0},
1c79356b
A
121#endif
122
123 /* ISO9660 (aka CDROM) Filesystem */
124#if CD9660
2d21ac55 125 { &cd9660_vfsops, "cd9660", 14, 0, MNT_LOCAL, cd9660_mountroot, NULL, 0, {{0}}, VFC_VFSLOCALARGS, NULL, 0, 0},
1c79356b
A
126#endif
127
1c79356b
A
128 /* Memory-based Filesystem */
129#if MFS
2d21ac55 130 { &mfs_vfsops, "mfs", 3, 0, MNT_LOCAL, mfs_mountroot, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
1c79356b
A
131#endif
132
133 /* Sun-compatible Network Filesystem */
134#if NFSCLIENT
2d21ac55 135 { &nfs_vfsops, "nfs", 2, 0, 0, (mountroot_t)nfs_mountroot, NULL, 1, {{0}}, VFC_VFSGENERICARGS|VFC_VFSPREFLIGHT, NULL, 0, 1},
1c79356b
A
136#endif
137
138 /* Andrew Filesystem */
139#if AFS
2d21ac55 140 { &afs_vfsops, "andrewfs", 13, 0, 0, afs_mountroot, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
1c79356b
A
141#endif
142
1c79356b
A
143 /* Loopback (Minimal) Filesystem Layer */
144#if NULLFS
2d21ac55 145 { &null_vfsops, "loopback", 9, 0, 0, NULL, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
1c79356b
A
146#endif
147
148 /* Union (translucent) Filesystem */
149#if UNION
2d21ac55 150 { &union_vfsops, "unionfs", 15, 0, 0, NULL, NULL, 1, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
1c79356b
A
151#endif
152
1c79356b
A
153 /* File Descriptor Filesystem */
154#if FDESC
2d21ac55 155 { &fdesc_vfsops, "fdesc", 7, 0, 0, NULL, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
1c79356b 156#endif
9bccf70c 157
1c79356b
A
158 /* Device Filesystem */
159#if DEVFS
2d21ac55
A
160#if CONFIG_MACF
161 { &devfs_vfsops, "devfs", 19, 0, MNT_MULTILABEL, NULL, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
162#else
163 { &devfs_vfsops, "devfs", 19, 0, 0, NULL, NULL, 0, {{0}}, VFC_VFSGENERICARGS , NULL, 0, 0},
164#endif /* MAC */
1c79356b 165#endif
9bccf70c 166
2d21ac55
A
167
168 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
169 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
170 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
171 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
172 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
173 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
174 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
175 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
176 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
177 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
178 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
179 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
180 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
181 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0},
182 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, {{0}}, 0, NULL, 0, 0}
1c79356b
A
183};
184
185/*
186 * Initially the size of the list, vfs_init will set maxvfsconf
187 * to the highest defined type number.
188 */
6601e61a 189int maxvfsslots = sizeof(vfstbllist) / sizeof (struct vfstable);
1c79356b 190int numused_vfsslots = 0;
6601e61a
A
191int maxvfsconf = sizeof(vfstbllist) / sizeof (struct vfstable);
192struct vfstable *vfsconf = vfstbllist;
1c79356b
A
193
194/*
195 *
196 * vfs_opv_descs enumerates the list of vnode classes, each with it's own
197 * vnode operation vector. It is consulted at system boot to build operation
198 * vectors. It is NULL terminated.
199 *
200 */
91447636 201#if FFS
1c79356b
A
202extern struct vnodeopv_desc ffs_vnodeop_opv_desc;
203extern struct vnodeopv_desc ffs_specop_opv_desc;
204extern struct vnodeopv_desc ffs_fifoop_opv_desc;
91447636 205#endif
1c79356b
A
206extern struct vnodeopv_desc mfs_vnodeop_opv_desc;
207extern struct vnodeopv_desc dead_vnodeop_opv_desc;
2d21ac55 208#if FIFO && SOCKETS
1c79356b 209extern struct vnodeopv_desc fifo_vnodeop_opv_desc;
2d21ac55 210#endif /* SOCKETS */
1c79356b
A
211extern struct vnodeopv_desc spec_vnodeop_opv_desc;
212extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc;
213extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc;
214extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc;
2d21ac55
A
215extern struct vnodeopv_desc nfsv4_vnodeop_opv_desc;
216extern struct vnodeopv_desc spec_nfsv4nodeop_opv_desc;
217extern struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc;
1c79356b 218extern struct vnodeopv_desc fdesc_vnodeop_opv_desc;
1c79356b 219extern struct vnodeopv_desc null_vnodeop_opv_desc;
1c79356b
A
220extern struct vnodeopv_desc hfs_vnodeop_opv_desc;
221extern struct vnodeopv_desc hfs_specop_opv_desc;
222extern struct vnodeopv_desc hfs_fifoop_opv_desc;
1c79356b 223extern struct vnodeopv_desc cd9660_vnodeop_opv_desc;
55e303ae 224extern struct vnodeopv_desc cd9660_cdxaop_opv_desc;
1c79356b
A
225extern struct vnodeopv_desc cd9660_specop_opv_desc;
226extern struct vnodeopv_desc cd9660_fifoop_opv_desc;
227extern struct vnodeopv_desc union_vnodeop_opv_desc;
1c79356b
A
228extern struct vnodeopv_desc devfs_vnodeop_opv_desc;
229extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc;
230
231struct vnodeopv_desc *vfs_opv_descs[] = {
91447636 232#if FFS
1c79356b
A
233 &ffs_vnodeop_opv_desc,
234 &ffs_specop_opv_desc,
235#if FIFO
236 &ffs_fifoop_opv_desc,
91447636 237#endif
1c79356b
A
238#endif
239 &dead_vnodeop_opv_desc,
2d21ac55 240#if FIFO && SOCKETS
1c79356b
A
241 &fifo_vnodeop_opv_desc,
242#endif
243 &spec_vnodeop_opv_desc,
1c79356b
A
244#if MFS
245 &mfs_vnodeop_opv_desc,
246#endif
247#if NFSCLIENT
248 &nfsv2_vnodeop_opv_desc,
249 &spec_nfsv2nodeop_opv_desc,
2d21ac55
A
250 &nfsv4_vnodeop_opv_desc,
251 &spec_nfsv4nodeop_opv_desc,
1c79356b
A
252#if FIFO
253 &fifo_nfsv2nodeop_opv_desc,
2d21ac55 254 &fifo_nfsv4nodeop_opv_desc,
1c79356b
A
255#endif
256#endif
257#if FDESC
258 &fdesc_vnodeop_opv_desc,
259#endif
1c79356b
A
260#if NULLFS
261 &null_vnodeop_opv_desc,
262#endif
1c79356b
A
263#if HFS
264 &hfs_vnodeop_opv_desc,
265 &hfs_specop_opv_desc,
266#if FIFO
267 &hfs_fifoop_opv_desc,
268#endif
269#endif
270#if CD9660
271 &cd9660_vnodeop_opv_desc,
55e303ae 272 &cd9660_cdxaop_opv_desc,
1c79356b
A
273 &cd9660_specop_opv_desc,
274#if FIFO
275 &cd9660_fifoop_opv_desc,
276#endif
277#endif
278#if UNION
279 &union_vnodeop_opv_desc,
280#endif
1c79356b
A
281#if DEVFS
282 &devfs_vnodeop_opv_desc,
283 &devfs_spec_vnodeop_opv_desc,
284#endif
285 NULL
286};