I noticed that stdetach() doesn't quite do the right thing. The consequences should only be relevant if you have more than one st(4) device and detach one while using it or another st(4).
I'd appreciate a quick test that this doesn't break st(4) in any obvious ways. If you're a particularly savvy user with access to two or more detachable tape drives, I can provide some more specific tests for you to run. Thanks. Index: st.c =================================================================== RCS file: /cvs/src/sys/scsi/st.c,v retrieving revision 1.116 diff -u -p st.c --- st.c 24 Dec 2010 02:45:33 -0000 1.116 +++ st.c 17 Mar 2011 23:37:18 -0000 @@ -369,22 +369,14 @@ stdetach(struct device *self, int flags) bufq_drain(&st->sc_bufq); /* Locate the lowest minor number to be detached. */ - mn = STUNIT(self->dv_unit); + mn = self->dv_unit << 4; for (bmaj = 0; bmaj < nblkdev; bmaj++) - if (bdevsw[bmaj].d_open == stopen) { - vdevgone(bmaj, mn, mn + 0, VBLK); - vdevgone(bmaj, mn, mn + 1, VBLK); - vdevgone(bmaj, mn, mn + 2, VBLK); - vdevgone(bmaj, mn, mn + 3, VBLK); - } + if (bdevsw[bmaj].d_open == stopen) + vdevgone(bmaj, mn, mn + 15, VBLK); for (cmaj = 0; cmaj < nchrdev; cmaj++) if (cdevsw[cmaj].d_open == stopen) { - vdevgone(cmaj, mn, mn + 0, VCHR); - vdevgone(cmaj, mn, mn + 1, VCHR); - vdevgone(cmaj, mn, mn + 2, VCHR); - vdevgone(cmaj, mn, mn + 3, VCHR); - } + vdevgone(cmaj, mn, mn + 15, VCHR); bufq_destroy(&st->sc_bufq);