1 /* $OpenBSD: vfs_init.c,v 1.34 2014/09/08 01:47:06 guenther Exp $ */ 2 /* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */ 3 4 /* 5 * Copyright (c) 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * This code is derived from software contributed 9 * to Berkeley by John Heidemann of the UCLA Ficus project. 10 * 11 * Source: * @(#)i405_init.c 2.10 92/04/27 UCLA Ficus project 12 * 13 * Redistribution and use in source and binary forms, with or without 14 * modification, are permitted provided that the following conditions 15 * are met: 16 * 1. Redistributions of source code must retain the above copyright 17 * notice, this list of conditions and the following disclaimer. 18 * 2. Redistributions in binary form must reproduce the above copyright 19 * notice, this list of conditions and the following disclaimer in the 20 * documentation and/or other materials provided with the distribution. 21 * 3. Neither the name of the University nor the names of its contributors 22 * may be used to endorse or promote products derived from this software 23 * without specific prior written permission. 24 * 25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)vfs_init.c 8.3 (Berkeley) 1/4/94 38 */ 39 40 #include <sys/param.h> 41 #include <sys/mount.h> 42 #include <sys/namei.h> 43 #include <sys/vnode.h> 44 #include <sys/systm.h> 45 #include <sys/pool.h> 46 47 struct pool namei_pool; 48 49 /* This defines the root filesystem. */ 50 struct vnode *rootvnode; 51 52 /* Set up the filesystem operations for vnodes. */ 53 #ifdef FFS 54 extern const struct vfsops ffs_vfsops; 55 #endif 56 57 #ifdef MFS 58 extern const struct vfsops mfs_vfsops; 59 #endif 60 61 #ifdef MSDOSFS 62 extern const struct vfsops msdosfs_vfsops; 63 #endif 64 65 #ifdef NFSCLIENT 66 extern const struct vfsops nfs_vfsops; 67 #endif 68 69 #ifdef CD9660 70 extern const struct vfsops cd9660_vfsops; 71 #endif 72 73 #ifdef EXT2FS 74 extern const struct vfsops ext2fs_vfsops; 75 #endif 76 77 #ifdef NTFS 78 extern const struct vfsops ntfs_vfsops; 79 #endif 80 81 #ifdef UDF 82 extern const struct vfsops udf_vfsops; 83 #endif 84 85 #ifdef FUSE 86 extern const struct vfsops fusefs_vfsops; 87 #endif 88 89 #ifdef TMPFS 90 extern const struct vfsops tmpfs_vfsops; 91 #endif 92 93 /* Set up the filesystem operations for vnodes. */ 94 static struct vfsconf vfsconflist[] = { 95 #ifdef FFS 96 { &ffs_vfsops, MOUNT_FFS, 1, 0, MNT_LOCAL, NULL }, 97 #endif 98 99 #ifdef MFS 100 { &mfs_vfsops, MOUNT_MFS, 3, 0, MNT_LOCAL, NULL }, 101 #endif 102 103 #ifdef EXT2FS 104 { &ext2fs_vfsops, MOUNT_EXT2FS, 17, 0, MNT_LOCAL, NULL }, 105 #endif 106 107 #ifdef CD9660 108 { &cd9660_vfsops, MOUNT_CD9660, 14, 0, MNT_LOCAL, NULL }, 109 #endif 110 111 #ifdef MSDOSFS 112 { &msdosfs_vfsops, MOUNT_MSDOS, 4, 0, MNT_LOCAL, NULL }, 113 #endif 114 115 #ifdef NFSCLIENT 116 { &nfs_vfsops, MOUNT_NFS, 2, 0, 0, NULL }, 117 #endif 118 119 #ifdef NTFS 120 { &ntfs_vfsops, MOUNT_NTFS, 6, 0, MNT_LOCAL, NULL }, 121 #endif 122 123 #ifdef UDF 124 { &udf_vfsops, MOUNT_UDF, 13, 0, MNT_LOCAL, NULL }, 125 #endif 126 127 #ifdef FUSE 128 { &fusefs_vfsops, MOUNT_FUSEFS, 18, 0, MNT_LOCAL, NULL }, 129 #endif 130 131 #ifdef TMPFS 132 { &tmpfs_vfsops, MOUNT_TMPFS, 19, 0, MNT_LOCAL, NULL }, 133 #endif 134 }; 135 136 137 /* 138 * Initially the size of the list, vfsinit will set maxvfsconf 139 * to the highest defined type number. 140 */ 141 int maxvfsconf = sizeof(vfsconflist) / sizeof(struct vfsconf); 142 struct vfsconf *vfsconf = vfsconflist; 143 144 /* Initialize the vnode structures and initialize each file system type. */ 145 void 146 vfsinit(void) 147 { 148 int i; 149 struct vfsconf *vfsconflist; 150 int vfsconflistlen; 151 152 pool_init(&namei_pool, MAXPATHLEN, 0, 0, 0, "namei", 153 &pool_allocator_nointr); 154 155 /* Initialize the vnode table. */ 156 vntblinit(); 157 158 /* Initialize the vnode name cache. */ 159 nchinit(); 160 161 /* 162 * Stop using vfsconf and maxvfsconf as a temporary storage, 163 * set them to their correct values now. 164 */ 165 vfsconflist = vfsconf; 166 vfsconflistlen = maxvfsconf; 167 vfsconf = NULL; 168 maxvfsconf = 0; 169 170 for (i = 0; i < vfsconflistlen; i++) 171 vfs_register(&vfsconflist[i]); 172 } 173