Make sure the mountpoint is marked busy before doing operations on it.

This fixes a panic that freefall suffered last night.

Obtained partially from 4.4-lite2, but minus the new bug that it introduced
This commit is contained in:
David Greenman 1996-01-16 13:07:14 +00:00
parent 5ce1b6a98e
commit c128d2157b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=13463
2 changed files with 28 additions and 8 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.44 1995/12/17 21:23:22 phk Exp $
* $Id: vfs_syscalls.c,v 1.45 1996/01/05 17:46:14 wollman Exp $
*/
/*
@ -486,7 +486,10 @@ getfsstat(p, uap, retval)
sfsp = (caddr_t)uap->buf;
count = 0;
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
nmp = mp->mnt_list.cqe_next;
if (vfs_busy(mp)) {
nmp = mp->mnt_list.cqe_next;
continue;
}
if (sfsp && count < maxcount &&
((mp->mnt_flag & MNT_MLOCK) == 0)) {
sp = &mp->mnt_stat;
@ -496,15 +499,22 @@ getfsstat(p, uap, retval)
*/
if (((uap->flags & MNT_NOWAIT) == 0 ||
(uap->flags & MNT_WAIT)) &&
(error = VFS_STATFS(mp, sp, p)))
(error = VFS_STATFS(mp, sp, p))) {
nmp = mp->mnt_list.cqe_next;
vfs_unbusy(mp);
continue;
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
error = copyout((caddr_t)sp, sfsp, sizeof(*sp));
if (error)
if (error) {
vfs_unbusy(mp);
return (error);
}
sfsp += sizeof(*sp);
}
count++;
nmp = mp->mnt_list.cqe_next;
vfs_unbusy(mp);
}
if (sfsp && count > maxcount)
*retval = maxcount;

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
* $Id: vfs_syscalls.c,v 1.44 1995/12/17 21:23:22 phk Exp $
* $Id: vfs_syscalls.c,v 1.45 1996/01/05 17:46:14 wollman Exp $
*/
/*
@ -486,7 +486,10 @@ getfsstat(p, uap, retval)
sfsp = (caddr_t)uap->buf;
count = 0;
for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) {
nmp = mp->mnt_list.cqe_next;
if (vfs_busy(mp)) {
nmp = mp->mnt_list.cqe_next;
continue;
}
if (sfsp && count < maxcount &&
((mp->mnt_flag & MNT_MLOCK) == 0)) {
sp = &mp->mnt_stat;
@ -496,15 +499,22 @@ getfsstat(p, uap, retval)
*/
if (((uap->flags & MNT_NOWAIT) == 0 ||
(uap->flags & MNT_WAIT)) &&
(error = VFS_STATFS(mp, sp, p)))
(error = VFS_STATFS(mp, sp, p))) {
nmp = mp->mnt_list.cqe_next;
vfs_unbusy(mp);
continue;
}
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
error = copyout((caddr_t)sp, sfsp, sizeof(*sp));
if (error)
if (error) {
vfs_unbusy(mp);
return (error);
}
sfsp += sizeof(*sp);
}
count++;
nmp = mp->mnt_list.cqe_next;
vfs_unbusy(mp);
}
if (sfsp && count > maxcount)
*retval = maxcount;