Date: Sat, 13 Jan 1996 19:08:48 -0800 From: "Justin T. Gibbs" <gibbs@freefall.freebsd.org> To: freebsd-scsi Subject: Calling st_unmount for nrst* devices Message-ID: <199601140308.TAA07484@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
I don't like the fact that after closing the nrst* devices, we
don't reenable the eject button. In fact, although I haven't
tracked down exactly why, even if you rewind the tape via an "mt
rewind" after doing some operations on the nrst* devices, the drive
is still locked. I think these patches fix the problem, but I'll
have to do some more testing tomorrow to make sure. Perhaps some
of you would be interested in testing these as well?
--
Justin T. Gibbs
===========================================
FreeBSD: Turning PCs into workstations
===========================================
Index: st.c
===================================================================
RCS file: /usr/cvs/src/sys/scsi/st.c,v
retrieving revision 1.57
diff -c -r1.57 st.c
*** st.c 1996/01/08 12:25:06 1.57
--- st.c 1996/01/13 22:06:16
***************
*** 89,102 ****
static int32 st_chkeod __P((u_int32 unit, boolean position, int32 *nmarks,
u_int32 flags));
static void ststart(u_int32 unit, u_int32 flags);
! static void st_unmount __P((int unit, boolean eject));
static errval st_mount_tape __P((dev_t dev, u_int32 flags));
static void st_loadquirks __P((struct scsi_link *sc_link));
static errval st_interpret_sense __P((struct scsi_xfer *xs));
#define ESUCCESS 0
! #define NOEJECT 0
! #define EJECT 1
struct scsi_data {
/*--------------------present operating parameters, flags etc.----------------*/
--- 89,105 ----
static int32 st_chkeod __P((u_int32 unit, boolean position, int32 *nmarks,
u_int32 flags));
static void ststart(u_int32 unit, u_int32 flags);
! static void st_unmount __P((int unit, u_int32 flags));
static errval st_mount_tape __P((dev_t dev, u_int32 flags));
static void st_loadquirks __P((struct scsi_link *sc_link));
static errval st_interpret_sense __P((struct scsi_xfer *xs));
#define ESUCCESS 0
!
! /* SCSI tape umount flags */
! #define NOOPS 0 /* Don't do anything to the tape */
! /* REWIND is a tape opcode (0x01), so we just use that */
! #define EJECT 2 /* Implies a rewind too */
struct scsi_data {
/*--------------------present operating parameters, flags etc.----------------*/
***************
*** 491,497 ****
*/
if ( (errno = scsi_test_unit_ready(sc_link, 0)) ) {
uprintf("st%d: not ready\n", unit);
! st_unmount(unit, NOEJECT);
return (errno);
}
/*
--- 494,500 ----
*/
if ( (errno = scsi_test_unit_ready(sc_link, 0)) ) {
uprintf("st%d: not ready\n", unit);
! st_unmount(unit, REWIND);
return (errno);
}
/*
***************
*** 501,507 ****
*/
if ((st->last_dsty != dsty)
|| (!(sc_link->flags & SDEV_MEDIA_LOADED))) {
! st_unmount(unit, NOEJECT);
}
/*
* If we are not mounted, then we should start a new
--- 504,510 ----
*/
if ((st->last_dsty != dsty)
|| (!(sc_link->flags & SDEV_MEDIA_LOADED))) {
! st_unmount(unit, REWIND);
}
/*
* If we are not mounted, then we should start a new
***************
*** 545,556 ****
switch (mode & 0x3) {
case 0:
case 3: /* for now */
! st_unmount(unit, NOEJECT);
break;
! case 1: /*leave mounted unless media seems to have been removed */
! if (!(sc_link->flags & SDEV_MEDIA_LOADED)) {
! st_unmount(unit, NOEJECT);
! }
break;
case 2:
st_unmount(unit, EJECT);
--- 548,557 ----
switch (mode & 0x3) {
case 0:
case 3: /* for now */
! st_unmount(unit, REWIND);
break;
! case 1:
! st_unmount(unit, NOOPS);
break;
case 2:
st_unmount(unit, EJECT);
***************
*** 672,678 ****
* operations require another mount operation
*/
void
! st_unmount(int unit, boolean eject)
{
struct scsi_link *sc_link = SCSI_LINK(&st_switch, unit);
struct scsi_data *st = sc_link->sd;
--- 673,679 ----
* operations require another mount operation
*/
void
! st_unmount(int unit, u_int32 flags)
{
struct scsi_link *sc_link = SCSI_LINK(&st_switch, unit);
struct scsi_data *st = sc_link->sd;
***************
*** 682,690 ****
return;
SC_DEBUG(sc_link, SDEV_DB1, ("unmounting\n"));
st_chkeod(unit, FALSE, &nmarks, SCSI_SILENT);
! st_rewind(unit, FALSE, SCSI_SILENT);
scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
! if (eject) {
st_load(unit, LD_UNLOAD, SCSI_SILENT);
}
st->flags &= ~(ST_MOUNTED | ST_NEW_MOUNT);
--- 683,693 ----
return;
SC_DEBUG(sc_link, SDEV_DB1, ("unmounting\n"));
st_chkeod(unit, FALSE, &nmarks, SCSI_SILENT);
!
! if (flags & (REWIND|EJECT) )
! st_rewind(unit, FALSE, SCSI_SILENT);
scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
! if (flags & EJECT) {
st_load(unit, LD_UNLOAD, SCSI_SILENT);
}
st->flags &= ~(ST_MOUNTED | ST_NEW_MOUNT);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199601140308.TAA07484>
