예제 #1
0
파일: mt.c 프로젝트: goroutines/rumprun
int
mtcommand(dev_t dev, int cmd, int cnt)
{
	struct mt_softc *sc;
	struct buf *bp;
	int error = 0;

	sc = device_lookup_private(&mt_cd, MTUNIT(dev));
	bp = &sc->sc_bufstore;

	if (bp->b_cflags & BC_BUSY)
		return (EBUSY);

	bp->b_cmd = cmd;
	bp->b_dev = dev;
	bp->b_objlock = &buffer_lock;
	do {
		bp->b_cflags = BC_BUSY;
		bp->b_flags = B_CMD;
		bp->b_oflags = 0;
		mtstrategy(bp);
		biowait(bp);
		if (bp->b_error != 0) {
			error = (int) (unsigned) bp->b_error;
			break;
		}
	} while (--cnt > 0);
#if 0
	bp->b_cflags = 0 /*&= ~BC_BUSY*/;
#else
	bp->b_cflags &= ~BC_BUSY;
#endif
	return (error);
}
예제 #2
0
파일: mt.c 프로젝트: lacombar/netbsd-alc
static int
mtcommand(dev_t dev, int cmd, int cnt)
{
	struct mt_softc *sc = device_lookup_private(&mt_cd,UNIT(dev));
	struct buf *bp = &sc->sc_bufstore;
	int error = 0;

#if 1
	if (bp->b_cflags & BC_BUSY)
		return EBUSY;
#endif
	bp->b_cmd = cmd;
	bp->b_dev = dev;
	do {
		bp->b_cflags = BC_BUSY;
		bp->b_flags = B_CMD;
		mtstrategy(bp);
		biowait(bp);
		if (bp->b_error != 0) {
			error = bp->b_error;
			break;
		}
	} while (--cnt > 0);
#if 0
	bp->b_flags = 0 /*&= ~BC_BUSY*/;
#else
	bp->b_flags &= ~BC_BUSY;
#endif
	return error;
}