2 * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
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.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
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.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
28 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
30 * Copyright (c) 1989, 1993, 1995
31 * The Regents of the University of California. All rights reserved.
33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions
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.
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
61 * @(#)vfs_conf.c 8.11 (Berkeley) 5/10/95
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,
70 #include <sys/param.h>
71 #include <sys/systm.h>
72 #include <sys/mount_internal.h>
73 #include <sys/vnode_internal.h>
76 * These define the root filesystem, device, and root filesystem type.
79 struct vnode
*rootvnode
;
81 #ifdef CONFIG_IMGSRC_ACCESS
82 struct vnode
*imgsrc_rootvnodes
[MAX_IMAGEBOOT_NESTING
]; /* [0] -> source volume, [1] -> first disk image */
83 #endif /* CONFIG_IMGSRC_ACCESS */
85 int (*mountroot
)(void) = NULL
;
88 * Set up the initial array of known filesystem types.
90 extern struct vfsops mfs_vfsops
;
91 extern int mfs_mountroot(mount_t
, vnode_t
, vfs_context_t
); /* dead */
92 extern struct vfsops hfs_vfsops
;
93 extern int hfs_mountroot(mount_t
, vnode_t
, vfs_context_t
);
94 extern struct vfsops nfs_vfsops
;
95 extern int nfs_mountroot(void);
96 extern struct vfsops afs_vfsops
;
97 extern struct vfsops null_vfsops
;
98 extern struct vfsops devfs_vfsops
;
99 extern struct vfsops routefs_vfsops
;
102 extern struct vfsops mockfs_vfsops
;
103 extern int mockfs_mountroot(mount_t
, vnode_t
, vfs_context_t
);
107 * For nfs_mountroot(void) cast. nfs_mountroot ignores its parameters, if
108 * invoked through this table.
110 typedef int (*mountroot_t
)(mount_t
, vnode_t
, vfs_context_t
);
118 FT_MOCKFS
= 0x6D6F636B
122 * Set up the filesystem operations for vnodes.
124 static struct vfstable vfstbllist
[] = {
125 /* HFS/HFS+ Filesystem */
127 { &hfs_vfsops
, "hfs", FT_HFS
, 0, (MNT_LOCAL
| MNT_DOVOLFS
), hfs_mountroot
, NULL
, 0, 0, VFC_VFSLOCALARGS
| VFC_VFSREADDIR_EXTENDED
| VFC_VFS64BITREADY
| VFC_VFSVNOP_PAGEOUTV2
| VFC_VFSVNOP_PAGEINV2
128 #if CONFIG_SECLUDED_RENAME
129 | VFC_VFSVNOP_SECLUDE_RENAME
134 /* Sun-compatible Network Filesystem */
136 { &nfs_vfsops
, "nfs", FT_NFS
, 0, 0, NULL
, NULL
, 0, 0, VFC_VFSGENERICARGS
| VFC_VFSPREFLIGHT
| VFC_VFS64BITREADY
| VFC_VFSREADDIR_EXTENDED
, NULL
, 0, NULL
},
139 /* Device Filesystem */
142 { &devfs_vfsops
, "devfs", FT_DEVFS
, 0, MNT_MULTILABEL
, NULL
, NULL
, 0, 0, VFC_VFSGENERICARGS
| VFC_VFS64BITREADY
, NULL
, 0, NULL
},
144 { &devfs_vfsops
, "devfs", FT_DEVFS
, 0, 0, NULL
, NULL
, 0, 0, VFC_VFSGENERICARGS
| VFC_VFS64BITREADY
, NULL
, 0, NULL
},
149 #endif /* __LP64__ */
152 /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */
153 { &mockfs_vfsops
, "mockfs", FT_MOCKFS
, 0, MNT_LOCAL
, mockfs_mountroot
, NULL
, 0, 0, VFC_VFSGENERICARGS
, NULL
, 0, NULL
},
157 /* If we are configured for it, mockfs should always be the last standard entry (and thus the last FS we attempt mountroot with) */
158 { &routefs_vfsops
, "routefs", FT_ROUTEFS
, 0, MNT_LOCAL
, NULL
, NULL
, 0, 0, VFC_VFSGENERICARGS
| VFC_VFS64BITREADY
, NULL
, 0, NULL
},
160 {NULL
, "<unassigned>", 0, 0, 0, NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
161 {NULL
, "<unassigned>", 0, 0, 0, NULL
, NULL
, 0, 0, 0, NULL
, 0, NULL
},
165 * vfs_init will set maxvfstypenum to the highest defined type number.
167 const int maxvfsslots
= sizeof(vfstbllist
) / sizeof (struct vfstable
);
168 int numused_vfsslots
= 0;
169 int numregistered_fses
= 0;
170 int maxvfstypenum
= VT_NON
+ 1;
171 struct vfstable
*vfsconf
= vfstbllist
;
175 * vfs_opv_descs enumerates the list of vnode classes, each with it's own
176 * vnode operation vector. It is consulted at system boot to build operation
177 * vectors. It is NULL terminated.
180 extern struct vnodeopv_desc mfs_vnodeop_opv_desc
;
181 extern struct vnodeopv_desc dead_vnodeop_opv_desc
;
183 extern struct vnodeopv_desc fifo_vnodeop_opv_desc
;
185 extern struct vnodeopv_desc spec_vnodeop_opv_desc
;
186 extern struct vnodeopv_desc nfsv2_vnodeop_opv_desc
;
187 extern struct vnodeopv_desc spec_nfsv2nodeop_opv_desc
;
188 extern struct vnodeopv_desc fifo_nfsv2nodeop_opv_desc
;
189 extern struct vnodeopv_desc nfsv4_vnodeop_opv_desc
;
190 extern struct vnodeopv_desc spec_nfsv4nodeop_opv_desc
;
191 extern struct vnodeopv_desc fifo_nfsv4nodeop_opv_desc
;
192 extern struct vnodeopv_desc null_vnodeop_opv_desc
;
193 extern struct vnodeopv_desc hfs_vnodeop_opv_desc
;
195 extern struct vnodeopv_desc hfs_std_vnodeop_opv_desc
;
197 extern struct vnodeopv_desc hfs_specop_opv_desc
;
198 extern struct vnodeopv_desc hfs_fifoop_opv_desc
;
199 extern struct vnodeopv_desc devfs_vnodeop_opv_desc
;
200 extern struct vnodeopv_desc devfs_spec_vnodeop_opv_desc
;
202 extern struct vnodeopv_desc devfs_devfd_vnodeop_opv_desc
;
203 extern struct vnodeopv_desc devfs_fdesc_vnodeop_opv_desc
;
207 extern struct vnodeopv_desc mockfs_vnodeop_opv_desc
;
210 struct vnodeopv_desc
*vfs_opv_descs
[] = {
211 &dead_vnodeop_opv_desc
,
213 &fifo_vnodeop_opv_desc
,
215 &spec_vnodeop_opv_desc
,
217 &mfs_vnodeop_opv_desc
,
220 &nfsv2_vnodeop_opv_desc
,
221 &spec_nfsv2nodeop_opv_desc
,
222 &nfsv4_vnodeop_opv_desc
,
223 &spec_nfsv4nodeop_opv_desc
,
225 &fifo_nfsv2nodeop_opv_desc
,
226 &fifo_nfsv4nodeop_opv_desc
,
230 &hfs_vnodeop_opv_desc
,
232 &hfs_std_vnodeop_opv_desc
,
234 &hfs_specop_opv_desc
,
236 &hfs_fifoop_opv_desc
,
240 &devfs_vnodeop_opv_desc
,
241 &devfs_spec_vnodeop_opv_desc
,
243 &devfs_devfd_vnodeop_opv_desc
,
244 &devfs_fdesc_vnodeop_opv_desc
,
248 &mockfs_vnodeop_opv_desc
,