version 1.155, 2002/05/05 15:16:31 |
version 1.155.2.2, 2002/08/29 05:22:55 |
Line 99 __KERNEL_RCSID(0, "$NetBSD$"); |
|
Line 99 __KERNEL_RCSID(0, "$NetBSD$"); |
|
#define ST_MOUNT_DELAY 0 |
#define ST_MOUNT_DELAY 0 |
#endif |
#endif |
|
|
|
dev_type_open(stopen); |
|
dev_type_close(stclose); |
|
dev_type_read(stread); |
|
dev_type_write(stwrite); |
|
dev_type_ioctl(stioctl); |
|
dev_type_strategy(ststrategy); |
|
dev_type_dump(stdump); |
|
|
|
const struct bdevsw st_bdevsw = { |
|
stopen, stclose, ststrategy, stioctl, stdump, nosize, D_TAPE |
|
}; |
|
|
|
const struct cdevsw st_cdevsw = { |
|
stopen, stclose, stread, stwrite, stioctl, |
|
nostop, notty, nopoll, nommap, D_TAPE |
|
}; |
|
|
/* |
/* |
* Define various devices that we know mis-behave in some way, |
* Define various devices that we know mis-behave in some way, |
* and note how they are bad, so we can correct for them |
* and note how they are bad, so we can correct for them |
Line 351 stattach(parent, st, aux) |
|
Line 368 stattach(parent, st, aux) |
|
st->flags = ST_INIT_FLAGS; |
st->flags = ST_INIT_FLAGS; |
|
|
/* |
/* |
|
* Set up the buf queue for this device |
|
*/ |
|
bufq_alloc(&st->buf_queue, BUFQ_FCFS); |
|
|
|
/* |
* Check if the drive is a known criminal and take |
* Check if the drive is a known criminal and take |
* Any steps needed to bring it into line |
* Any steps needed to bring it into line |
*/ |
*/ |
Line 375 stattach(parent, st, aux) |
|
Line 397 stattach(parent, st, aux) |
|
(st->flags & ST_READONLY) ? "protected" : "enabled"); |
(st->flags & ST_READONLY) ? "protected" : "enabled"); |
} |
} |
|
|
/* |
|
* Set up the buf queue for this device |
|
*/ |
|
BUFQ_INIT(&st->buf_queue); |
|
|
|
#if NRND > 0 |
#if NRND > 0 |
rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname, |
rnd_attach_source(&st->rnd_source, st->sc_dev.dv_xname, |
RND_TYPE_TAPE, 0); |
RND_TYPE_TAPE, 0); |
Line 417 stdetach(self, flags) |
|
Line 434 stdetach(self, flags) |
|
int s, bmaj, cmaj, mn; |
int s, bmaj, cmaj, mn; |
|
|
/* locate the major number */ |
/* locate the major number */ |
for (bmaj = 0; bmaj <= nblkdev; bmaj++) |
bmaj = bdevsw_lookup_major(&st_bdevsw); |
if (bdevsw[bmaj].d_open == stopen) |
cmaj = cdevsw_lookup_major(&st_cdevsw); |
break; |
|
for (cmaj = 0; cmaj <= nchrdev; cmaj++) |
|
if (cdevsw[cmaj].d_open == stopen) |
|
break; |
|
|
|
s = splbio(); |
s = splbio(); |
|
|
/* Kill off any queued buffers. */ |
/* Kill off any queued buffers. */ |
while ((bp = BUFQ_FIRST(&st->buf_queue)) != NULL) { |
while ((bp = BUFQ_GET(&st->buf_queue)) != NULL) { |
BUFQ_REMOVE(&st->buf_queue, bp); |
|
bp->b_error = EIO; |
bp->b_error = EIO; |
bp->b_flags |= B_ERROR; |
bp->b_flags |= B_ERROR; |
bp->b_resid = bp->b_bcount; |
bp->b_resid = bp->b_bcount; |
biodone(bp); |
biodone(bp); |
} |
} |
|
|
|
bufq_free(&st->buf_queue); |
|
|
/* Kill off any pending commands. */ |
/* Kill off any pending commands. */ |
scsipi_kill_pending(st->sc_periph); |
scsipi_kill_pending(st->sc_periph); |
|
|
|
|
* at the end (a bit silly because we only have on user.. |
* at the end (a bit silly because we only have on user.. |
* (but it could fork())) |
* (but it could fork())) |
*/ |
*/ |
BUFQ_INSERT_TAIL(&st->buf_queue, bp); |
BUFQ_PUT(&st->buf_queue, bp); |
|
|
/* |
/* |
* Tell the device to get going on the transfer if it's |
* Tell the device to get going on the transfer if it's |
Line 1175 ststart(periph) |
|
Line 1189 ststart(periph) |
|
return; |
return; |
} |
} |
|
|
if ((bp = BUFQ_FIRST(&st->buf_queue)) == NULL) |
if ((bp = BUFQ_GET(&st->buf_queue)) == NULL) |
return; |
return; |
BUFQ_REMOVE(&st->buf_queue, bp); |
|
|
|
/* |
/* |
* If the device has been unmounted by the user |
* If the device has been unmounted by the user |