Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 May 1996 10:43:35 -0500 (CDT)
From:      fredriks@mcs.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/1245: scsi tape driver write-protect and eject handling is broken
Message-ID:  <199605241543.KAA18414@fredriks.pr.mcs.net>
Resent-Message-ID: <199605241550.IAA21594@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         1245
>Category:       kern
>Synopsis:       scsi tape driver write-protet and eject handling is broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 24 08:50:01 PDT 1996
>Last-Modified:
>Originator:     & Fredriksen
>Organization:
Flaaklypa Hackers
>Release:        FreeBSD 2.2-CURRENT i386
>Environment:

	FreeBSD 2.2-CURRENT as of 5/23/96 (sup & compile)

>Description:
	Tape device driver does not eject, nor report write-protect properly.
	
	ecject: 
		The problem with eject is that there are devices out there,
		that will not eject if the device has been reserved. The
		current st.c reserves the device upon open and releases it
		upon close. However the release happens after the unload,
		so the eject will not occur. Also if you issue a 
			mt -f /dev/rstx offline
		command that will not eject either, since no release happens.

		The fix included below, fixes both of these problems.

	write-protect detection:
		The scsi tape driver registers its own error handling 
		routine that gets called when the device returns an
		error. This routine checks for the Filemark, End of Medium
		and Illegal Length Indicator bits to be set, and if they
		are and there are bytes left to be written to tape you
		get an EIO back. This routine needs to check for sense-key
		of 0x7 (Data Protect) first. The Exabyte 8500 sets the
		EOM bit (which is probably a bug on their part). Checking
		for sense-key of 0x7 should by-pass these kinds of bugs
		and accurately detect write-protected medium on all drives.

	density codes:
		Added density code for the Exabyte 8200, 8200C, 8500 and 8500C.
		These where patches that Eric J. Haug (ejh@eas.slu.edu)
		posted on current for the Exabyte 8505. 

>How-To-Repeat:
>Fix:


Index: scsiconf.h
===================================================================
RCS file: /home/ncvs/src/sys/scsi/scsiconf.h,v
retrieving revision 1.41
diff -r1.41 scsiconf.h
234c234
< /*  7*/	char    density;
---
> /*  7*/	u_int8_t  density;
549a550,553
> #define EXB_8200	0x14
> #define EXB_8500	0x15
> #define EXB_8200C	0x8c
> #define EXB_8500C	0x90
Index: st.c
===================================================================
RCS file: /home/ncvs/src/sys/scsi/st.c,v
retrieving revision 1.68
diff -r1.68 st.c
71c71,74
< #define SCSI_2_MAX_DENSITY_CODE	0x17	/* maximum density code specified
---
> #ifdef	EXB_8500C
> #	define SCSI_2_MAX_DENSITY_CODE	EXB_8500C	
> #else
> #	define SCSI_2_MAX_DENSITY_CODE	0x17	/* maximum density code specified
72a76
> #endif
498a503,509
> 
> 		/* has to happen before the unload, otherwise media will
> 		 * not be ejected when the EJECT flag is given.
> 		 */
> 
> 	scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
> 
513d523
< 	scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
1113a1124,1126
> 					/* Some devices will not eject unless*/
> 					/* the device gets released first */
> 				scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
1147a1161
> 					goto try_new_value;
1149d1162
< 				goto try_new_value;
1817c1830,1834
< 	if ((sense->error_code & SSD_ERRCODE) != 0x70) {
---
> 	key = sense->ext.extended.flags & SSD_KEY;
> 
> 	if ((sense->error_code & SSD_ERRCODE) != 0x70 || key == 0x7) {
> 					/* we want the generic code to hadle */
> 					/* write protect too */
1819a1837,1838
> 
> 
1893d1911
< 	key = sense->ext.extended.flags & SSD_KEY;
>Audit-Trail:
>Unformatted:
>Repeat-By:
	With an Exabyte 8500 tape drive:

	mt -f /dev/rst2 offline
		should eject the tape, but doesn't

	tar -tvf /dev/erst2
		should eject the tape upon close, but doesn't
	tar -cvf /dev/rstx and have a write protected cartridge in the
	device. You will get EIO instead of EACCESS.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605241543.KAA18414>