Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 May 1996 10:30:03 -0700 (PDT)
From:      Lars Fredriksen <fredriks@mcs.com>
To:        freebsd-bugs
Subject:   Re: kern/1245: scsi tape driver write-protect and eject handling is broken
Message-ID:  <199605251730.KAA05048@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/1245; it has been noted by GNATS.

From: Lars Fredriksen <fredriks@mcs.com>
To: FreeBSD-gnats-submit@FreeBSD.org
Cc:  Subject: Re: kern/1245: scsi tape driver write-protect and eject handling is broken
Date: Sat, 25 May 1996 12:29:59 -0500 (CDT)

 Hi, 
 	Here are the context diffs. J"oerg was nice enough to point out
 that I hadn't submitted context diffs. If someone is willing to review
 these changes (Peter?), then I can submit them if that eases the load
 on people.
 
 Lars
 
 
 Index: scsiconf.h
 ===================================================================
 RCS file: /home/ncvs/src/sys/scsi/scsiconf.h,v
 retrieving revision 1.41
 diff -c -r1.41 scsiconf.h
 *** scsiconf.h	1996/03/31 03:19:09	1.41
 --- scsiconf.h	1996/03/31 11:00:34
 ***************
 *** 231,237 ****
   struct st_mode {
   /*  4*/	u_int32_t blksiz;
   /*  6*/	u_int16_t quirks;		/* same definitions as in XXX */
 ! /*  7*/	char    density;
   /*  8*/	char    spare[1];
   };
   
 --- 231,237 ----
   struct st_mode {
   /*  4*/	u_int32_t blksiz;
   /*  6*/	u_int16_t quirks;		/* same definitions as in XXX */
 ! /*  7*/	u_int8_t  density;
   /*  8*/	char    spare[1];
   };
   
 ***************
 *** 547,552 ****
 --- 547,556 ----
   #define QIC_1320	0x12
   #define DDS		0x13
   #define DAT_1		0x13
 + #define EXB_8200	0x14
 + #define EXB_8500	0x15
 + #define EXB_8200C	0x8c
 + #define EXB_8500C	0x90
   #define	QIC_3080	0x29
   
   
 
 Index: st.c
 ===================================================================
 RCS file: /home/ncvs/src/sys/scsi/st.c,v
 retrieving revision 1.68
 diff -c -r1.68 st.c
 *** st.c	1996/04/02 04:54:26	1.68
 --- st.c	1996/05/24 15:31:39
 ***************
 *** 68,75 ****
   
   #define IS_CTLMODE(DEV) (MODE(DEV) == CTLMODE)
   
 ! #define SCSI_2_MAX_DENSITY_CODE	0x17	/* maximum density code specified
   					 * in SCSI II spec. */
   
   static errval	st_space __P((u_int32_t unit, int32_t number, u_int32_t what, u_int32_t flags));
   static errval	st_rewind __P((u_int32_t unit, boolean immed, u_int32_t flags));
 --- 68,79 ----
   
   #define IS_CTLMODE(DEV) (MODE(DEV) == CTLMODE)
   
 ! #ifdef	EXB_8500C
 ! #	define SCSI_2_MAX_DENSITY_CODE	EXB_8500C	
 ! #else
 ! #	define SCSI_2_MAX_DENSITY_CODE	0x17	/* maximum density code specified
   					 * in SCSI II spec. */
 + #endif
   
   static errval	st_space __P((u_int32_t unit, int32_t number, u_int32_t what, u_int32_t flags));
   static errval	st_rewind __P((u_int32_t unit, boolean immed, u_int32_t flags));
 ***************
 *** 496,501 ****
 --- 500,512 ----
   
   	if ((st->flags & (ST_WRITTEN | ST_FM_WRITTEN)) == ST_WRITTEN)
   		st_write_filemarks(unit, 1, 0);
 + 
 + 		/* 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);
 + 
   	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;
 --- 521,526 ----
 ***************
 *** 1111,1116 ****
 --- 1121,1129 ----
   						  flags);
   				break;
   			case MTOFFL:	/* rewind and put the drive offline */
 + 					/* Some devices will not eject unless*/
 + 					/* the device gets released first */
 + 				scsi_prevent(sc_link, PR_ALLOW, SCSI_SILENT);
   				st_unmount(unit, EJECT);
   				break;
   			case MTNOP:	/* no operation, sets status only */
 ***************
 *** 1145,1152 ****
   					errcode = EINVAL;
   				} else {
   					st->density = number;
   				}
 - 				goto try_new_value;
   
   			case MTCOMP:	/* enable default compression */
   				errcode = st_comp(unit,number);
 --- 1158,1165 ----
   					errcode = EINVAL;
   				} else {
   					st->density = number;
 + 					goto try_new_value;
   				}
   
   			case MTCOMP:	/* enable default compression */
   				errcode = st_comp(unit,number);
 ***************
 *** 1814,1822 ****
   			info = xs->datalen;
   		}
   	}
 ! 	if ((sense->error_code & SSD_ERRCODE) != 0x70) {
   		return SCSIRET_CONTINUE;/* let the generic code handle it */
   	}
   	if(sense->ext.extended.flags & (SSD_EOM|SSD_FILEMARK|SSD_ILI)) {
   		if (st->flags & ST_FIXEDBLOCKS) {
   			xs->resid = info * st->blksiz;
 --- 1827,1841 ----
   			info = xs->datalen;
   		}
   	}
 ! 	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 */
   		return SCSIRET_CONTINUE;/* let the generic code handle it */
   	}
 + 
 + 
   	if(sense->ext.extended.flags & (SSD_EOM|SSD_FILEMARK|SSD_ILI)) {
   		if (st->flags & ST_FIXEDBLOCKS) {
   			xs->resid = info * st->blksiz;
 ***************
 *** 1890,1896 ****
   		}
   		return 0;
   	}
 - 	key = sense->ext.extended.flags & SSD_KEY;
   
   	if (key == 0x8) {
   		xs->flags |= SCSI_EOF; /* some drives need this */
 --- 1909,1914 ----



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