1/*
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 22 unchanged lines hidden (view full) ---
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
39 * $Id: vfs_syscalls.c,v 1.5 1994/09/02 04:14:44 davidg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/filedesc.h>
46#include <sys/kernel.h>
47#include <sys/file.h>
--- 82 unchanged lines hidden (view full) ---
130
131 /*
132 * Allocate and initialize the file system.
133 */
134 mp = (struct mount *)malloc((u_long)sizeof(struct mount),
135 M_MOUNT, M_WAITOK);
136 bzero((char *)mp, (u_long)sizeof(struct mount));
137 mp->mnt_op = vfssw[uap->type];
138 if (error = vfs_lock(mp)) {
139 free((caddr_t)mp, M_MOUNT);
140 vput(vp);
141 return (error);
142 }
143 if (vp->v_mountedhere != NULL) {
144 vfs_unlock(mp);
145 free((caddr_t)mp, M_MOUNT);
146 vput(vp);
147 return (EBUSY);
148 }
149 vp->v_mountedhere = mp;
150 mp->mnt_vnodecovered = vp;
151update:
152 /*
153 * Set the mount level flags.
154 */
155 if (uap->flags & MNT_RDONLY)
156 mp->mnt_flag |= MNT_RDONLY;
157 else if (mp->mnt_flag & MNT_RDONLY)
158 mp->mnt_flag |= MNT_WANTRDWR;
--- 24 unchanged lines hidden (view full) ---
183 VOP_UNLOCK(vp);
184 vfs_unlock(mp);
185 error = VFS_START(mp, 0, p);
186 } else {
187 mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0;
188 vfs_unlock(mp);
189 free((caddr_t)mp, M_MOUNT);
190 vput(vp);
191 }
192 return (error);
193}
194
195/*
196 * Unmount a file system.
197 *
198 * Note: unmount takes a path to the vnode mounted on as argument,
--- 78 unchanged lines hidden (view full) ---
277 vfs_unbusy(mp);
278 if (error) {
279 vfs_unlock(mp);
280 } else {
281 vrele(coveredvp);
282 TAILQ_REMOVE(&mountlist, mp, mnt_list);
283 mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0;
284 vfs_unlock(mp);
285 if (mp->mnt_vnodelist.lh_first != NULL)
286 panic("unmount: dangling vnode");
287 free((caddr_t)mp, M_MOUNT);
288 }
289 return (error);
290}
291
292/*
--- 1905 unchanged lines hidden ---
2 * Copyright (c) 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 22 unchanged lines hidden (view full) ---
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
39 * $Id: vfs_syscalls.c,v 1.5 1994/09/02 04:14:44 davidg Exp $
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/namei.h>
45#include <sys/filedesc.h>
46#include <sys/kernel.h>
47#include <sys/file.h>
--- 82 unchanged lines hidden (view full) ---
130
131 /*
132 * Allocate and initialize the file system.
133 */
134 mp = (struct mount *)malloc((u_long)sizeof(struct mount),
135 M_MOUNT, M_WAITOK);
136 bzero((char *)mp, (u_long)sizeof(struct mount));
137 mp->mnt_op = vfssw[uap->type];
138 if (error = vfs_lock(mp)) {
139 free((caddr_t)mp, M_MOUNT);
140 vput(vp);
141 return (error);
142 }
143 if (vp->v_mountedhere != NULL) {
144 vfs_unlock(mp);
145 free((caddr_t)mp, M_MOUNT);
146 vput(vp);
147 return (EBUSY);
148 }
149 vp->v_mountedhere = mp;
150 mp->mnt_vnodecovered = vp;
151update:
152 /*
153 * Set the mount level flags.
154 */
155 if (uap->flags & MNT_RDONLY)
156 mp->mnt_flag |= MNT_RDONLY;
157 else if (mp->mnt_flag & MNT_RDONLY)
158 mp->mnt_flag |= MNT_WANTRDWR;
--- 24 unchanged lines hidden (view full) ---
183 VOP_UNLOCK(vp);
184 vfs_unlock(mp);
185 error = VFS_START(mp, 0, p);
186 } else {
187 mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0;
188 vfs_unlock(mp);
189 free((caddr_t)mp, M_MOUNT);
190 vput(vp);
191 }
192 return (error);
193}
194
195/*
196 * Unmount a file system.
197 *
198 * Note: unmount takes a path to the vnode mounted on as argument,
--- 78 unchanged lines hidden (view full) ---
277 vfs_unbusy(mp);
278 if (error) {
279 vfs_unlock(mp);
280 } else {
281 vrele(coveredvp);
282 TAILQ_REMOVE(&mountlist, mp, mnt_list);
283 mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0;
284 vfs_unlock(mp);
285 if (mp->mnt_vnodelist.lh_first != NULL)
286 panic("unmount: dangling vnode");
287 free((caddr_t)mp, M_MOUNT);
288 }
289 return (error);
290}
291
292/*
--- 1905 unchanged lines hidden ---