]> git.saurik.com Git - apple/xnu.git/blame - bsd/vfs/vfs_conf.c
xnu-4903.241.1.tar.gz
[apple/xnu.git] / bsd / vfs / vfs_conf.c
CommitLineData
1c79356b 1/*
fe8ab488 2 * Copyright (c) 2000-2014 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;
b7266188
A
80
81#ifdef CONFIG_IMGSRC_ACCESS
6d2010ae
A
82struct vnode *imgsrc_rootvnodes[MAX_IMAGEBOOT_NESTING]; /* [0] -> source volume, [1] -> first disk image */
83#endif /* CONFIG_IMGSRC_ACCESS */
b7266188 84
2d21ac55 85int (*mountroot)(void) = NULL;
1c79356b
A
86
87/*
88 * Set up the initial array of known filesystem types.
89 */
1c79356b 90extern struct vfsops mfs_vfsops;
2d21ac55 91extern int mfs_mountroot(mount_t, vnode_t, vfs_context_t); /* dead */
1c79356b 92extern struct vfsops nfs_vfsops;
2d21ac55 93extern int nfs_mountroot(void);
1c79356b 94extern struct vfsops afs_vfsops;
1c79356b 95extern struct vfsops null_vfsops;
1c79356b 96extern struct vfsops devfs_vfsops;
490019cf 97extern struct vfsops routefs_vfsops;
39037602 98extern struct vfsops nullfs_vfsops;
1c79356b 99
39236c6e
A
100#if MOCKFS
101extern struct vfsops mockfs_vfsops;
102extern int mockfs_mountroot(mount_t, vnode_t, vfs_context_t);
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 */
109typedef int (*mountroot_t)(mount_t, vnode_t, vfs_context_t);
110
fe8ab488
A
111enum 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 123static struct vfstable vfstbllist[] = {
1c79356b
A
124 /* Sun-compatible Network Filesystem */
125#if NFSCLIENT
fe8ab488 126 { &nfs_vfsops, "nfs", FT_NFS, 0, 0, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFC_VFSPREFLIGHT | VFC_VFS64BITREADY | VFC_VFSREADDIR_EXTENDED, NULL, 0, NULL},
1c79356b
A
127#endif
128
1c79356b
A
129 /* Device Filesystem */
130#if DEVFS
2d21ac55 131#if CONFIG_MACF
fe8ab488 132 { &devfs_vfsops, "devfs", FT_DEVFS, 0, MNT_MULTILABEL, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFC_VFS64BITREADY, NULL, 0, NULL},
2d21ac55 133#else
fe8ab488 134 { &devfs_vfsops, "devfs", FT_DEVFS, 0, 0, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFC_VFS64BITREADY, NULL, 0, NULL},
2d21ac55 135#endif /* MAC */
1c79356b 136#endif
9bccf70c 137
b0d623f7
A
138#ifndef __LP64__
139#endif /* __LP64__ */
2d21ac55 140
39037602
A
141#if NULLFS
142 { &nullfs_vfsops, "nullfs", FT_NULLFS, 0, (MNT_DONTBROWSE | MNT_RDONLY), NULL, NULL, 0, 0, VFC_VFS64BITREADY, NULL, 0, NULL},
143#endif /* NULLFS */
144
39236c6e
A
145#if MOCKFS
146 /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */
fe8ab488 147 { &mockfs_vfsops, "mockfs", FT_MOCKFS, 0, MNT_LOCAL, mockfs_mountroot, NULL, 0, 0, VFC_VFSGENERICARGS, NULL, 0, NULL},
39236c6e
A
148#endif /* MOCKFS */
149
490019cf
A
150#if ROUTEFS
151 /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */
152 { &routefs_vfsops, "routefs", FT_ROUTEFS, 0, MNT_LOCAL, NULL, NULL, 0, 0, VFC_VFSGENERICARGS | VFC_VFS64BITREADY, NULL, 0, NULL},
153#endif /* ROUTEFS */
fe8ab488
A
154 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0, NULL},
155 {NULL, "<unassigned>", 0, 0, 0, NULL, NULL, 0, 0, 0, NULL, 0, NULL},
1c79356b
A
156};
157
158/*
fe8ab488 159 * vfs_init will set maxvfstypenum to the highest defined type number.
1c79356b 160 */
fe8ab488 161const int maxvfsslots = sizeof(vfstbllist) / sizeof (struct vfstable);
1c79356b 162int numused_vfsslots = 0;
fe8ab488
A
163int numregistered_fses = 0;
164int maxvfstypenum = VT_NON + 1;
6601e61a 165struct vfstable *vfsconf = vfstbllist;
1c79356b
A
166
167/*
168 *
169 * vfs_opv_descs enumerates the list of vnode classes, each with it's own
170 * vnode operation vector. It is consulted at system boot to build operation
171 * vectors. It is NULL terminated.
172 *
173 */
1c79356b
A
174extern struct vnodeopv_desc mfs_vnodeop_opv_desc;
175extern struct vnodeopv_desc dead_vnodeop_opv_desc;
2d21ac55 176#if FIFO && SOCKETS
1c79356b 177extern struct vnodeopv_desc fifo_vnodeop_opv_desc;
2d21ac55 178#endif /* SOCKETS */
1c79356b
A
179extern struct vnodeopv_desc spec_vnodeop_opv_desc;
180extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc;
181extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc;
182extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc;
2d21ac55
A
183extern struct vnodeopv_desc nfsv4_vnodeop_opv_desc;
184extern struct vnodeopv_desc spec_nfsv4nodeop_opv_desc;
185extern struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc;
1c79356b 186extern struct vnodeopv_desc null_vnodeop_opv_desc;
1c79356b
A
187extern struct vnodeopv_desc devfs_vnodeop_opv_desc;
188extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc;
b0d623f7
A
189#if FDESC
190extern struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc;
191extern struct vnodeopv_desc devfs_fdesc_vnodeop_opv_desc;
192#endif /* FDESC */
1c79356b 193
39236c6e
A
194#if MOCKFS
195extern struct vnodeopv_desc mockfs_vnodeop_opv_desc;
196#endif /* MOCKFS */
197
39037602
A
198extern struct vnodeopv_desc nullfs_vnodeop_opv_desc;
199
1c79356b 200struct vnodeopv_desc *vfs_opv_descs[] = {
1c79356b 201 &dead_vnodeop_opv_desc,
2d21ac55 202#if FIFO && SOCKETS
1c79356b
A
203 &fifo_vnodeop_opv_desc,
204#endif
205 &spec_vnodeop_opv_desc,
1c79356b
A
206#if MFS
207 &mfs_vnodeop_opv_desc,
208#endif
209#if NFSCLIENT
210 &nfsv2_vnodeop_opv_desc,
211 &spec_nfsv2nodeop_opv_desc,
2d21ac55
A
212 &nfsv4_vnodeop_opv_desc,
213 &spec_nfsv4nodeop_opv_desc,
1c79356b
A
214#if FIFO
215 &fifo_nfsv2nodeop_opv_desc,
2d21ac55 216 &fifo_nfsv4nodeop_opv_desc,
1c79356b
A
217#endif
218#endif
1c79356b
A
219#if DEVFS
220 &devfs_vnodeop_opv_desc,
221 &devfs_spec_vnodeop_opv_desc,
b0d623f7
A
222#if FDESC
223 &devfs_devfd_vnodeop_opv_desc,
224 &devfs_fdesc_vnodeop_opv_desc,
225#endif /* FDESC */
226#endif /* DEVFS */
39037602
A
227#if NULLFS
228 &nullfs_vnodeop_opv_desc,
229#endif /* NULLFS */
39236c6e
A
230#if MOCKFS
231 &mockfs_vnodeop_opv_desc,
232#endif /* MOCKFS */
1c79356b
A
233 NULL
234};