From pst@base.jnx.com  Tue Aug 27 18:10:48 1996
Received: from red.jnx.com (ppp-206-170-2-23.sntc01.pacbell.net [206.170.2.23])
          by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id SAA12745
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Aug 1996 18:10:46 -0700 (PDT)
Received: from base.jnx.com (base.jnx.com [208.197.169.238]) by red.jnx.com (8.7.5/8.7.3) with ESMTP id SAA11565; Tue, 27 Aug 1996 18:10:43 -0700 (PDT)
Received: (from pst@localhost) by base.jnx.com (8.7.5/8.7.3) id SAA10352; Tue, 27 Aug 1996 18:10:39 -0700 (PDT)
Message-Id: <199608280110.SAA10352@base.jnx.com>
Date: Tue, 27 Aug 1996 18:10:39 -0700 (PDT)
From: pusateri@jnx.com
To: FreeBSD-gnats-submit@freebsd.org
Cc: pst@jnx.com
Subject: SCSI tapes don't unload properly (bogus PREVENT_MEDIA_REMOVAL)
X-Send-Pr-Version: 3.2

>Number:         1545
>Category:       kern
>Synopsis:       SCSI tapes don't unload properly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 27 18:20:01 PDT 1996
>Closed-Date:    Tue Aug 27 18:21:46 PDT 1996
>Last-Modified:  Tue Aug 27 18:22:20 PDT 1996
>Originator:     Tom Pusateri
>Release:        FreeBSD 2.2-CURRENT i386
>Organization:
Juniper Networks
>Environment:

-current as of 27 Aug 1996.

>Description:

When I would do a "mt offline" command or use the /dev/erst* devices,
the tape would unload but not eject as I expected. Looking at the
HP documentation, it says that if a PREVENT_MEDIA_REMOVAL command
has been issued, then this will happen. After looking at the kernel,
it looks like st.c does issue this command and erroneously reverses
it after sending the UNLOAD command.

>How-To-Repeat:

See description.

>Fix:
	
*** st.c.orig	Mon Apr  1 23:54:26 1996
--- st.c	Mon Aug 26 17:32:06 1996
***************
*** 496,501 ****
--- 496,504 ----
  
  	if ((st->flags & (ST_WRITTEN | ST_FM_WRITTEN)) == ST_WRITTEN)
  		st_write_filemarks(unit, 1, 0);
+ 
+ 	scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
+ 
  	switch (mode & 0x3) {
  	case 0:
  	case 3:		/* for now */
***************
*** 510,516 ****
  		st_unmount(unit, EJECT);
  		break;
  	}
- 	scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
  
  	sc_link->flags &= ~SDEV_OPEN;
  	st->flags &= ~ST_OPEN;
--- 513,518 ----
***************
*** 1111,1116 ****
--- 1113,1119 ----
  						  flags);
  				break;
  			case MTOFFL:	/* rewind and put the drive offline */
+ 				scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
  				st_unmount(unit, EJECT);
  				break;
  			case MTNOP:	/* no operation, sets status only */
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: pst 
State-Changed-When: Tue Aug 27 18:21:46 PDT 1996 
State-Changed-Why:  
Duplicate bug. 
>Unformatted:
