1 /* $OpenBSD: vfs_init.c,v 1.37 2016/08/25 00:01:13 dlg 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/pool.h> 45 46 struct pool namei_pool; 47 48 /* This defines the root filesystem. */ 49 struct vnode *rootvnode; 50 51 /* Set up the filesystem operations for vnodes. */ 52 #ifdef FFS 53 extern const struct vfsops ffs_vfsops; 54 #endif 55 56 #ifdef MFS 57 extern const struct vfsops mfs_vfsops; 58 #endif 59 60 #ifdef MSDOSFS 61 extern const struct vfsops msdosfs_vfsops; 62 #endif 63 64 #ifdef NFSCLIENT 65 extern const struct vfsops nfs_vfsops; 66 #endif 67 68 #ifdef CD9660 69 extern const struct vfsops cd9660_vfsops; 70 #endif 71 72 #ifdef EXT2FS 73 extern const struct vfsops ext2fs_vfsops; 74 #endif 75 76 #ifdef NTFS 77 extern const struct vfsops ntfs_vfsops; 78 #endif 79 80 #ifdef UDF 81 extern const struct vfsops udf_vfsops; 82 #endif 83 84 #ifdef FUSE 85 extern const struct vfsops fusefs_vfsops; 86 #endif 87 88 #ifdef TMPFS 89 extern const struct vfsops tmpfs_vfsops; 90 #endif 91 92 /* Set up the filesystem operations for vnodes. */ 93 static struct vfsconf vfsconflist[] = { 94 #ifdef FFS 95 { &ffs_vfsops, MOUNT_FFS, 1, 0, MNT_LOCAL, NULL }, 96 #endif 97 98 #ifdef MFS 99 { &mfs_vfsops, MOUNT_MFS, 3, 0, MNT_LOCAL, NULL }, 100 #endif 101 102 #ifdef EXT2FS 103 { &ext2fs_vfsops, MOUNT_EXT2FS, 17, 0, MNT_LOCAL, NULL }, 104 #endif 105 106 #ifdef CD9660 107 { &cd9660_vfsops, MOUNT_CD9660, 14, 0, MNT_LOCAL, NULL }, 108 #endif 109 110 #ifdef MSDOSFS 111 { &msdosfs_vfsops, MOUNT_MSDOS, 4, 0, MNT_LOCAL, NULL }, 112 #endif 113 114 #ifdef NFSCLIENT 115 { &nfs_vfsops, MOUNT_NFS, 2, 0, 0, NULL }, 116 #endif 117 118 #ifdef NTFS 119 { &ntfs_vfsops, MOUNT_NTFS, 6, 0, MNT_LOCAL, NULL }, 120 #endif 121 122 #ifdef UDF 123 { &udf_vfsops, MOUNT_UDF, 13, 0, MNT_LOCAL, NULL }, 124 #endif 125 126 #ifdef FUSE 127 { &fusefs_vfsops, MOUNT_FUSEFS, 18, 0, MNT_LOCAL, NULL }, 128 #endif 129 130 #ifdef TMPFS 131 { &tmpfs_vfsops, MOUNT_TMPFS, 19, 0, MNT_LOCAL, NULL }, 132 #endif 133 }; 134 135 136 /* 137 * Initially the size of the list, vfsinit will set maxvfsconf 138 * to the highest defined type number. 139 */ 140 int maxvfsconf = sizeof(vfsconflist) / sizeof(struct vfsconf); 141 struct vfsconf *vfsconf = vfsconflist; 142 143 /* Initialize the vnode structures and initialize each file system type. */ 144 void 145 vfsinit(void) 146 { 147 int i; 148 struct vfsconf *vfsconflist; 149 int vfsconflistlen; 150 151 pool_init(&namei_pool, MAXPATHLEN, 0, 0, PR_WAITOK, "namei", NULL); 152 pool_setipl(&namei_pool, IPL_NONE); 153 154 /* Initialize the vnode table. */ 155 vntblinit(); 156 157 /* Initialize the vnode name cache. */ 158 nchinit(); 159 160 /* 161 * Stop using vfsconf and maxvfsconf as a temporary storage, 162 * set them to their correct values now. 163 */ 164 vfsconflist = vfsconf; 165 vfsconflistlen = maxvfsconf; 166 vfsconf = NULL; 167 maxvfsconf = 0; 168 169 for (i = 0; i < vfsconflistlen; i++) 170 vfs_register(&vfsconflist[i]); 171 } 172