aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/vn/vn.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>1999-08-23 09:35:12 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>1999-08-23 09:35:12 +0000
commitb3ddbd9504256949a9213dbc7ea66a50b0219442 (patch)
tree13e5a52dc5c1a09610c1d521661519489b467acb /sys/dev/vn/vn.c
parent5349eb69a5109f50b4caab186fe27f5cd6bcadb2 (diff)
downloadsrc-b3ddbd9504256949a9213dbc7ea66a50b0219442.tar.gz
src-b3ddbd9504256949a9213dbc7ea66a50b0219442.zip
Fix the breakage caused by hanging softc off dev_t. This is only
a workaround.
Notes
Notes: svn path=/head/; revision=50207
Diffstat (limited to 'sys/dev/vn/vn.c')
-rw-r--r--sys/dev/vn/vn.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c
index 382d4b154723..7d1459a876f4 100644
--- a/sys/dev/vn/vn.c
+++ b/sys/dev/vn/vn.c
@@ -38,7 +38,7 @@
* from: Utah Hdr: vn.c 1.13 94/04/02
*
* from: @(#)vn.c 8.6 (Berkeley) 4/1/94
- * $Id: vn.c,v 1.83 1999/08/08 22:01:50 phk Exp $
+ * $Id: vn.c,v 1.84 1999/08/14 11:40:38 phk Exp $
*/
/*
@@ -134,6 +134,7 @@ static struct cdevsw vn_cdevsw = {
free((caddr_t)(bp), M_DEVBUF)
struct vn_softc {
+ int sc_unit;
int sc_flags; /* flags */
int sc_size; /* size of vn, sc_secsize scale */
int sc_secsize; /* sector size */
@@ -173,23 +174,46 @@ vnclose(dev_t dev, int flags, int mode, struct proc *p)
return (0);
}
-static int
-vnopen(dev_t dev, int flags, int mode, struct proc *p)
+static struct vn_softc *
+vnfindvn(dev_t dev)
{
- int unit = dkunit(dev);
+ int unit;
struct vn_softc *vn;
+ unit = dkunit(dev);
vn = dev->si_drv1;
if (!vn) {
+ SLIST_FOREACH(vn, &vn_list, sc_list) {
+ if (vn->sc_unit == unit) {
+ dev->si_drv1 = vn;
+ break;
+ }
+ }
+ }
+ if (!vn) {
vn = malloc(sizeof *vn, M_DEVBUF, M_WAITOK);
if (!vn)
- return (ENOMEM);
+ return (NULL);
bzero(vn, sizeof *vn);
+ vn->sc_unit = unit;
dev->si_drv1 = vn;
make_dev(&vn_cdevsw, 0,
UID_ROOT, GID_OPERATOR, 0640, "vn%d", unit);
SLIST_INSERT_HEAD(&vn_list, vn, sc_list);
}
+ return (vn);
+}
+
+static int
+vnopen(dev_t dev, int flags, int mode, struct proc *p)
+{
+ int unit;
+ struct vn_softc *vn;
+
+ unit = dkunit(dev);
+ vn = dev->si_drv1;
+ if (!vn)
+ vn = vnfindvn(dev);
IFOPT(vn, VN_FOLLOW)
printf("vnopen(0x%lx, 0x%x, 0x%x, %p)\n",
@@ -236,14 +260,19 @@ vnopen(dev_t dev, int flags, int mode, struct proc *p)
static void
vnstrategy(struct buf *bp)
{
- int unit = dkunit(bp->b_dev);
- struct vn_softc *vn = bp->b_dev->si_drv1;
+ int unit;
+ struct vn_softc *vn;
int error;
int isvplocked = 0;
long sz;
struct uio auio;
struct iovec aiov;
+ unit = dkunit(bp->b_dev);
+ vn = bp->b_dev->si_drv1;
+ if (!vn)
+ vn = vnfindvn(bp->b_dev);
+
IFOPT(vn, VN_DEBUG)
printf("vnstrategy(%p): unit %d\n", bp, unit);