Turn mountlist into a CIRCLEQ, and handle setting and checking of MNT_ROOTFS
differently.
This commit is contained in:
parent
355685bb12
commit
af0c359450
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: init_main.c,v 1.73 1995/01/12 05:22:18 cgd Exp $ */
|
||||
/* $NetBSD: init_main.c,v 1.74 1995/01/18 06:14:43 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1982, 1986, 1989, 1991, 1992, 1993
|
||||
|
@ -263,10 +263,11 @@ main(framep)
|
|||
/* Mount the root file system. */
|
||||
if ((*mountroot)())
|
||||
panic("cannot mount root");
|
||||
mountlist.tqh_first->mnt_op->vfs_refcount++;
|
||||
mountlist.cqh_first->mnt_flag |= MNT_ROOTFS;
|
||||
mountlist.cqh_first->mnt_op->vfs_refcount++;
|
||||
|
||||
/* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */
|
||||
if (VFS_ROOT(mountlist.tqh_first, &rootvnode))
|
||||
if (VFS_ROOT(mountlist.cqh_first, &rootvnode))
|
||||
panic("cannot find root vnode");
|
||||
fdp->fd_fd.fd_cdir = rootvnode;
|
||||
VREF(fdp->fd_fd.fd_cdir);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: vfs_syscalls.c,v 1.46 1994/12/15 19:46:08 mycroft Exp $ */
|
||||
/* $NetBSD: vfs_syscalls.c,v 1.47 1995/01/18 06:14:45 mycroft Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989, 1993
|
||||
|
@ -242,7 +242,7 @@ update:
|
|||
*/
|
||||
cache_purge(vp);
|
||||
if (!error) {
|
||||
TAILQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
CIRCLEQ_INSERT_TAIL(&mountlist, mp, mnt_list);
|
||||
checkdirs(vp);
|
||||
VOP_UNLOCK(vp);
|
||||
vfs_unlock(mp);
|
||||
|
@ -332,6 +332,14 @@ unmount(p, uap, retval)
|
|||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't allow unmounting the root file system.
|
||||
*/
|
||||
if (mp->mnt_flag & MNT_ROOTFS) {
|
||||
vput(vp);
|
||||
return (EINVAL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Must be the root of the filesystem
|
||||
*/
|
||||
|
@ -372,9 +380,11 @@ dounmount(mp, flags, p)
|
|||
if (error) {
|
||||
vfs_unlock(mp);
|
||||
} else {
|
||||
vrele(coveredvp);
|
||||
TAILQ_REMOVE(&mountlist, mp, mnt_list);
|
||||
mp->mnt_vnodecovered->v_mountedhere = (struct mount *)0;
|
||||
CIRCLEQ_REMOVE(&mountlist, mp, mnt_list);
|
||||
if (coveredvp != NULLVP) {
|
||||
vrele(coveredvp);
|
||||
coveredvp->v_mountedhere = (struct mount *)0;
|
||||
}
|
||||
mp->mnt_op->vfs_refcount--;
|
||||
vfs_unlock(mp);
|
||||
if (mp->mnt_vnodelist.lh_first != NULL)
|
||||
|
@ -401,12 +411,12 @@ sync(p, uap, retval)
|
|||
register struct mount *mp, *nmp;
|
||||
int asyncflag;
|
||||
|
||||
for (mp = mountlist.tqh_first; mp != NULL; mp = nmp) {
|
||||
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
|
||||
/*
|
||||
* Get the next pointer in case we hang on vfs_busy
|
||||
* while we are being unmounted.
|
||||
*/
|
||||
nmp = mp->mnt_list.tqe_next;
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
/*
|
||||
* The lock check below is to avoid races with mount
|
||||
* and unmount.
|
||||
|
@ -422,7 +432,7 @@ sync(p, uap, retval)
|
|||
* Get the next pointer again, as the next filesystem
|
||||
* might have been unmounted while we were sync'ing.
|
||||
*/
|
||||
nmp = mp->mnt_list.tqe_next;
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
vfs_unbusy(mp);
|
||||
}
|
||||
}
|
||||
|
@ -535,8 +545,9 @@ getfsstat(p, uap, retval)
|
|||
|
||||
maxcount = SCARG(uap, bufsize) / sizeof(struct statfs);
|
||||
sfsp = (caddr_t)SCARG(uap, buf);
|
||||
for (count = 0, mp = mountlist.tqh_first; mp != NULL; mp = nmp) {
|
||||
nmp = mp->mnt_list.tqe_next;
|
||||
for (count = 0,
|
||||
mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
|
||||
nmp = mp->mnt_list.cqe_next;
|
||||
if (sfsp && count < maxcount &&
|
||||
((mp->mnt_flag & MNT_MLOCK) == 0)) {
|
||||
sp = &mp->mnt_stat;
|
||||
|
|
Loading…
Reference in New Issue