Fixed device number checking in bdevvp():

- dev != NODEV was checked for, but 0 was returned on failure.  This was
  fixed in Lite2 (except the return code was still slightly wrong (ENODEV
  instead of ENXIO)) but the changes were not merged.  This case probably
  doesn't actually occur under FreeBSD.
- major(dev) was not checked to have a valid non-NULL bdevsw entry.  This
  caused panics when the driver for the root device didn't exist.

Fixed minor misformattings in bdevvp().  Rev.1.14 consisted mainly of
gratuitous reformattings that seem to have caused many Lite2 merge
errors.

PR:			8417
This commit is contained in:
bde 1998-10-25 16:11:49 +00:00
parent 0230a7360f
commit b17bde009a
2 changed files with 20 additions and 12 deletions

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.165 1998/10/13 08:24:41 dg Exp $
* $Id: vfs_subr.c,v 1.166 1998/10/14 15:05:52 dt Exp $
*/
/*
@ -46,6 +46,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/malloc.h>
@ -1126,16 +1127,19 @@ bdevvp(dev, vpp)
struct vnode *nvp;
int error;
if (dev == NODEV)
return (0);
error = getnewvnode(VT_NON, (struct mount *) 0, spec_vnodeop_p, &nvp);
if (dev == NODEV || major(dev) >= nblkdev ||
bdevsw[major(dev)] == NULL) {
*vpp = NULLVP;
return (ENXIO);
}
error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp);
if (error) {
*vpp = 0;
*vpp = NULLVP;
return (error);
}
vp = nvp;
vp->v_type = VBLK;
if ((nvp = checkalias(vp, dev, (struct mount *) 0))) {
if ((nvp = checkalias(vp, dev, (struct mount *)0)) != NULL) {
vput(vp);
vp = nvp;
}

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_subr.c 8.31 (Berkeley) 5/26/95
* $Id: vfs_subr.c,v 1.165 1998/10/13 08:24:41 dg Exp $
* $Id: vfs_subr.c,v 1.166 1998/10/14 15:05:52 dt Exp $
*/
/*
@ -46,6 +46,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/malloc.h>
@ -1126,16 +1127,19 @@ bdevvp(dev, vpp)
struct vnode *nvp;
int error;
if (dev == NODEV)
return (0);
error = getnewvnode(VT_NON, (struct mount *) 0, spec_vnodeop_p, &nvp);
if (dev == NODEV || major(dev) >= nblkdev ||
bdevsw[major(dev)] == NULL) {
*vpp = NULLVP;
return (ENXIO);
}
error = getnewvnode(VT_NON, (struct mount *)0, spec_vnodeop_p, &nvp);
if (error) {
*vpp = 0;
*vpp = NULLVP;
return (error);
}
vp = nvp;
vp->v_type = VBLK;
if ((nvp = checkalias(vp, dev, (struct mount *) 0))) {
if ((nvp = checkalias(vp, dev, (struct mount *)0)) != NULL) {
vput(vp);
vp = nvp;
}