xref: /openbsd-src/sys/kern/vfs_init.c (revision 57593ff0414b90ebf400de19b45bbeaee8108cfb)
1 /*	$OpenBSD: vfs_init.c,v 1.26 2010/09/06 23:44:10 thib 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/time.h>
43 #include <sys/vnode.h>
44 #include <sys/stat.h>
45 #include <sys/namei.h>
46 #include <sys/ucred.h>
47 #include <sys/buf.h>
48 #include <sys/errno.h>
49 #include <sys/malloc.h>
50 #include <sys/pool.h>
51 #include <sys/systm.h>
52 
53 struct pool namei_pool;
54 
55 /* Initialize the vnode structures and initialize each file system type. */
56 void
57 vfsinit(void)
58 {
59 	int i;
60 	struct vfsconf *vfsconflist;
61 	int vfsconflistlen;
62 
63 	pool_init(&namei_pool, MAXPATHLEN, 0, 0, 0, "namei",
64 	    &pool_allocator_nointr);
65 
66 	/* Initialize the vnode table. */
67 	vntblinit();
68 
69 	/* Initialize the vnode name cache. */
70 	nchinit();
71 
72 	/*
73 	 * Stop using vfsconf and maxvfsconf as a temporary storage,
74 	 * set them to their correct values now.
75 	 */
76 	vfsconflist = vfsconf;
77 	vfsconflistlen = maxvfsconf;
78 	vfsconf = NULL;
79 	maxvfsconf = 0;
80 
81 	for (i = 0; i < vfsconflistlen; i++)
82 		vfs_register(&vfsconflist[i]);
83 }
84