Deleted Added
full compact
vfs_mount.c (4370) vfs_mount.c (10358)
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 1995 Artisoft, Inc. All Rights Reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the

--- 14 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)vfs_conf.c 8.8 (Berkeley) 3/31/94
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the

--- 14 unchanged lines hidden (view full) ---

27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)vfs_conf.c 8.8 (Berkeley) 3/31/94
34 * $Id: vfs_conf.c,v 1.5 1994/09/21 03:46:47 wollman Exp $
35 * $Id: vfs_conf.c,v 1.6 1994/11/12 01:47:43 phk Exp $
35 */
36
36 */
37
37#include <sys/param.h>
38#include <sys/mount.h>
39#include <sys/vnode.h>
38/*
39 * PURPOSE: This file abstracts the root mounting interface from
40 * the per file system semantics for handling mounts,
41 * the overall intent of which is to move the BSD
42 * internals dependence out of the FS code, both to
43 * make the FS code more portable and to free up some
44 * of the BSD internals so that they may more easily
45 * be changed.
46 *
47 * NOTE1: Code is single entry/single exit to aid debugging
48 * and conversion for kernel multithreading.
49 *
50 * NOTE2: Code notes lock state in headers on entry and exit
51 * as an aid to conversion for kernel multithreading
52 * on SMP reentrancy
53 */
54#include <sys/param.h> /* dev_t (types.h)*/
55#include <sys/systm.h> /* rootvp*/
56#include <sys/proc.h> /* curproc*/
57#include <sys/vnode.h> /* NULLVP*/
58#include <sys/mount.h> /* struct mount*/
59#include <sys/malloc.h> /* M_MOUNT*/
40
60
41int (*mountroot) __P((void));
61/*
62 * GLOBALS
63 */
64int (*mountroot) __P((caddr_t));
42struct vnode *rootvnode;
65struct vnode *rootvnode;
66struct vfsops *mountrootvfsops;
43
67
68
69/*
70 * Common root mount code shared by all filesystems
71 */
72#define ROOTDIR "/"
73#define ROOTNAME "root_device"
74
75
76
77/*
78 * vfs_mountroot
79 *
80 * Common entry point for root mounts
81 *
82 * PARAMETERS:
83 * data pointer to the vfs_ops for the FS type mounting
84 *
85 * RETURNS: 0 Success
86 * !0 error number (errno.h)
87 *
88 * LOCK STATE:
89 * ENTRY
90 * <no locks held>
91 * EXIT
92 * <no locks held>
93 *
94 * NOTES:
95 * This code is currently supported only for use for
96 * the FFS file system type. This is a matter of
97 * fixing the other file systems, not this code!
98 */
99int
100vfs_mountroot( data)
101caddr_t *data; /* file system function table*/
102{
103 struct mount *mp;
104 u_int size;
105 int err = 0;
106 struct proc *p = curproc; /* XXX */
107 register struct fs *fs;
108 struct vfsops *mnt_op = (struct vfsops *)data;
109
110 /*
111 * New root mount structure
112 */
113 mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK);
114 bzero((char *)mp, (u_long)sizeof(struct mount));
115 mp->mnt_op = mnt_op;
116 mp->mnt_flag = MNT_ROOTFS;
117 mp->mnt_vnodecovered = NULLVP;
118
119 /*
120 * Lock mount point
121 */
122 if( ( err = vfs_lock(mp)) != 0)
123 goto error_1;
124
125 /* Save "last mounted on" info for mount point (NULL pad)*/
126 copystr( ROOTDIR, /* mount point*/
127 mp->mnt_stat.f_mntonname, /* save area*/
128 MNAMELEN - 1, /* max size*/
129 &size); /* real size*/
130 bzero( mp->mnt_stat.f_mntonname + size, MNAMELEN - size);
131
132 /* Save "mounted from" info for mount point (NULL pad)*/
133 copystr( ROOTNAME, /* device name*/
134 mp->mnt_stat.f_mntfromname, /* save area*/
135 MNAMELEN - 1, /* max size*/
136 &size); /* real size*/
137 bzero( mp->mnt_stat.f_mntfromname + size, MNAMELEN - size);
138
139 /*
140 * Attempt the mount
141 */
142 err = VFS_MOUNT( mp, NULL, NULL, NULL, p);
143 if( err)
144 goto error_2;
145
146 /* Add fs to list of mounted file systems*/
147 CIRCLEQ_INSERT_TAIL( &mountlist, mp, mnt_list);
148
149 /* Unlock mount point*/
150 vfs_unlock(mp);
151
152 /* root mount, update system time from FS specific data*/
153 inittodr( mp->mnt_time);
154
155 goto success;
156
157
158error_2: /* mount error*/
159
160 /* unlock before failing*/
161 vfs_unlock( mp);
162
163error_1: /* lock error*/
164
165 /* free mount struct before failing*/
166 free( mp, M_MOUNT);
167
168success:
169 return( err);
170}
171
172
173/*
174 * EOF -- This file has not been truncated.
175 */