From e64f402ff1de1681ea7a4ca183bcd3d15768b093 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sat, 31 May 2003 18:56:58 +0000 Subject: [PATCH] Hang softc from dev_t --- sys/i386/isa/wt.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sys/i386/isa/wt.c b/sys/i386/isa/wt.c index e29664d30a2..f994a7ef47c 100644 --- a/sys/i386/isa/wt.c +++ b/sys/i386/isa/wt.c @@ -249,6 +249,7 @@ static int wtattach (struct isa_device *id) { wtinfo_t *t = wttab + id->id_unit; + dev_t dev; id->id_ointr = wtintr; if (t->type == ARCHIVE) { @@ -260,7 +261,9 @@ wtattach (struct isa_device *id) t->dens = -1; /* unknown density */ isa_dmainit(t->chan, 1024); - make_dev(&wt_cdevsw, id->id_unit, 0, 0, 0600, "rwt%d", id->id_unit); + dev = make_dev(&wt_cdevsw, id->id_unit, + UID_ROOT, GID_WHEEL, 0600, "rwt%d", id->id_unit); + dev->si_drv1 = t; return (1); } @@ -279,10 +282,15 @@ static int wtopen (dev_t dev, int flag, int fmt, struct thread *td) { int u = minor (dev) & WT_UNIT; - wtinfo_t *t = wttab + u; + wtinfo_t *t; int error; - if (u >= NWT || t->type == UNKNOWN) + if (u >= NWT) + return (ENXIO); + + t = dev->si_drv1; + + if (t->type == UNKNOWN) return (ENXIO); /* Check that device is not in use */ @@ -361,7 +369,9 @@ static int wtclose (dev_t dev, int flags, int fmt, struct thread *td) { int u = minor (dev) & WT_UNIT; - wtinfo_t *t = wttab + u; + wtinfo_t *t; + + t = dev->si_drv1; if (u >= NWT || t->type == UNKNOWN) return (ENXIO); @@ -410,9 +420,10 @@ static int wtioctl (dev_t dev, u_long cmd, caddr_t arg, int flags, struct thread *td) { int u = minor (dev) & WT_UNIT; - wtinfo_t *t = wttab + u; + wtinfo_t *t; int error, count, op; + t = dev->si_drv1; if (u >= NWT || t->type == UNKNOWN) return (ENXIO); @@ -508,9 +519,10 @@ static void wtstrategy (struct bio *bp) { int u = minor (bp->bio_dev) & WT_UNIT; - wtinfo_t *t = wttab + u; + wtinfo_t *t; int s; + t = bp->bio_dev->si_drv1; bp->bio_resid = bp->bio_bcount; if (u >= NWT || t->type == UNKNOWN) { bp->bio_error = ENXIO;