Return to BSD News archive
Path: sserve!newshost.anu.edu.au!harbinger.cc.monash.edu.au!msuinfo!agate!howland.reston.ans.net!swiss.ans.net!news.dfn.de!Germany.EU.net!EU.net!uunet!easix!knobel.gun.de!knobel.gun.de!andreas From: andreas@knobel.gun.de (Andreas Klemm) Newsgroups: comp.os.386bsd.misc Subject: Re: patch for "mt" status command for SCSI tapes Date: 30 Sep 1994 18:07:21 GMT Organization: home, 41469 Neuss, Germany Lines: 334 Distribution: comp Message-ID: <36hk4p$8u0@knobel.gun.de> References: <KSTAILEY.94Sep19192058@leidecker.std.com> <CwGM8y.H65@tfs.com> <PHILS.94Sep24222153@satori.tv.tek.com> NNTP-Posting-Host: knobel.gun.de X-Newsreader: TIN [version 1.2 PL2] Phil Staub (phils@satori.tv.tek.com) wrote: : In article <CwGM8y.H65@tfs.com> julian@tfs.com (Julian Elischer) writes: : > why would one want to use the 'mt' command for scsi tapes? : > : > it doesn't do anyhting that the 'st command doesn't (they're related) : > and the 'st' command returns REAL INFORMATION.. : Last time I checked, st doesn't support 'erase' and 'retension' : commands that mt does. I haven't looked very closely to see if there : might be others. I sent fixes for this to Julian Elischer and to the freebsd mailing list. First Julian seemed to be not reachable, then he send me a mail to my companies address, where he asked me to re-mail the stuff. Then again I got no feedback and deceided to put that stuff into the freebsd-scsi mailing list. Then again I got no response. After asking for response, somebody from freefall told me to put it onto the ftp server, where patches reside, so theres a good chance for the stuff to be put into 2.0. After that JK Hubbard asked me to fiddle the stuff in into 2.0, since the diffs aren't suitable for the new scsi stuff. I replied, I need the sources. Then he wanted to send me the stuff on DAT. Therefore I deceided to wait for his cartridge (although I had two other offers at about the same time). But the cartridge didn't come ... I think Jordan has so much to do, that he wasn't able to do all in time. I'll include the stuff at the end of this posting, do everybody can fiddle the stuff in into 1.1.5.1, if he is interested in. After 2.0 comes I'll install it and - if my diffs aren't included - I'll try it again for Release 2.1. Hope the rcsdiffs are ok, it was the first time for me to use this tool (RCS) for generating diffs. Have fun Andreas /// =================================================================== RCS file: /usr/include/sys/RCS/mtio.h,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 11:25:21 --- 1.2 1994/08/28 15:24:52 *************** *** 31,37 **** * SUCH DAMAGE. * * from: @(#)mtio.h 7.6 (Berkeley) 2/5/91 ! * $Id: mtio.h,v 1.1 1994/08/28 11:25:21 root Exp $ */ #ifndef _SYS_MTIO_H_ --- 31,37 ---- * SUCH DAMAGE. * * from: @(#)mtio.h 7.6 (Berkeley) 2/5/91 ! * $Id: mtio.h,v 1.2 1994/08/28 15:24:52 root Exp $ */ #ifndef _SYS_MTIO_H_ *************** *** 72,77 **** --- 72,78 ---- /* and range from 0 to 0x17. Sets the value for the openned mode only */ #define MTSETDNSTY 11 + #define MTERASE 12 /* erase tape, andreas@knobel.gun.de (AKL) */ #endif /* structure for MTIOCGET - mag tape get status command */ =================================================================== RCS file: /sys/sys/RCS/mtio.h,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 12:40:08 --- 1.2 1994/08/28 15:25:39 *************** *** 31,37 **** * SUCH DAMAGE. * * from: @(#)mtio.h 7.6 (Berkeley) 2/5/91 ! * $Id: mtio.h,v 1.1 1994/08/28 12:40:08 root Exp $ */ #ifndef _SYS_MTIO_H_ --- 31,37 ---- * SUCH DAMAGE. * * from: @(#)mtio.h 7.6 (Berkeley) 2/5/91 ! * $Id: mtio.h,v 1.2 1994/08/28 15:25:39 root Exp $ */ #ifndef _SYS_MTIO_H_ *************** *** 72,77 **** --- 72,78 ---- /* and range from 0 to 0x17. Sets the value for the openned mode only */ #define MTSETDNSTY 11 + #define MTERASE 12 /* erase tape, andreas@knobel.gun.de (AKL) */ #endif /* structure for MTIOCGET - mag tape get status command */ =================================================================== RCS file: /sys/scsi/RCS/scsi_tape.h,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 11:42:21 --- 1.2 1994/08/28 15:26:53 *************** *** 21,27 **** /* * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * ! * $Id: scsi_tape.h,v 1.1 1994/08/28 11:42:21 root Exp $ */ #ifndef SCSI_SCSI_TAPE_H #define SCSI_SCSI_TAPE_H 1 --- 21,27 ---- /* * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * ! * $Id: scsi_tape.h,v 1.2 1994/08/28 15:26:53 root Exp $ */ #ifndef SCSI_SCSI_TAPE_H #define SCSI_SCSI_TAPE_H 1 *************** *** 72,77 **** --- 72,91 ---- u_char control; } rewind; + struct scsi_erase /* AKL */ + { + u_char op_code; + u_char byte2; + #define SE_LONG 0x01 /* + * AKL: Use LONG ERASE, since Archive Viper + * 2525 does't allow short erase and possibly + * most of the other tapes, too. + */ + #define SE_IMMED 0x02 + u_char unused[3]; + u_char control; + } erase; + struct scsi_load { u_char op_code; *************** *** 104,109 **** --- 118,124 ---- #define WRITE_COMMAND_TAPE 0x0a #define WRITE_FILEMARKS 0x10 #define SPACE 0x11 + #define ERASE 0x19 /* AKL */ #define LOAD_UNLOAD 0x1b /* same as above */ =================================================================== RCS file: /sys/scsi/RCS/st.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 11:40:40 --- 1.2 1994/08/28 15:26:53 *************** *** 21,33 **** * 16 Feb 93 Julian Elischer ADDED for SCSI system * 1.15 is the last version to support MACH and OSF/1 */ ! /* $Revision: 1.1 $ */ /* * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 * ! * $Id: st.c,v 1.1 1994/08/28 11:40:40 root Exp $ */ /* --- 21,33 ---- * 16 Feb 93 Julian Elischer ADDED for SCSI system * 1.15 is the last version to support MACH and OSF/1 */ ! /* $Revision: 1.2 $ */ /* * Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992 * major changes by Julian Elischer (julian@jules.dialix.oz.au) May 1993 * ! * $Id: st.c,v 1.2 1994/08/28 15:26:53 root Exp $ */ /* *************** *** 160,165 **** --- 160,166 ---- errval st_space __P((u_int32 unit, int32 number, u_int32 what, u_int32 flags)); errval st_rewind __P((u_int32 unit, boolean immed, u_int32 flags)); + errval st_erase __P((u_int32 unit, boolean immed, u_int32 flags)); /* AKL */ errval st_mode_sense __P((u_int32 unit, u_int32 flags)); errval st_decide_mode __P((u_int32 unit, boolean first_read)); errval st_rd_blk_lim __P((u_int32 unit, u_int32 flags)); *************** *** 1176,1182 **** errcode = st_space(unit, number, SP_BLKS, flags); break; case MTREW: /* rewind */ ! errcode = st_rewind(unit, FALSE, flags); break; case MTOFFL: /* rewind and put the drive offline */ st_unmount(unit, EJECT); --- 1177,1186 ---- errcode = st_space(unit, number, SP_BLKS, flags); break; case MTREW: /* rewind */ ! errcode = st_rewind(unit, TRUE, flags); ! break; ! case MTERASE: /* rewind first, then erase - AKL */ ! errcode = st_erase(unit, TRUE, flags); break; case MTOFFL: /* rewind and put the drive offline */ st_unmount(unit, EJECT); *************** *** 1733,1738 **** --- 1737,1784 ---- bzero(&scsi_cmd, sizeof(scsi_cmd)); scsi_cmd.op_code = REWIND; scsi_cmd.byte2 = immed ? SR_IMMED : 0; + return (scsi_scsi_cmd(st->sc_link, + (struct scsi_generic *) &scsi_cmd, + sizeof(scsi_cmd), + 0, + 0, + ST_RETRIES, + immed ? 5000 : 300000, /* 5 sec or 5 min */ + NULL, + flags)); + } + + /* + * Erase the device - AKL + */ + errval + st_erase(unit, immed, flags) + u_int32 unit, flags; + boolean immed; + { + struct scsi_erase scsi_cmd; + struct st_data *st = st_data[unit]; + errval error; + int32 nmarks; + + error = st_chkeod(unit, FALSE, &nmarks, flags); + if (error != ESUCCESS) + return (error); + /* + * AKL: Archive Viper 2525 Technical 5.7 (ERASE 19h): + * The cartridge tape must be positioned at BOT when the + * Erase command is issued or the command is rejected. + * So we rewind the tape first and exit with an error, + * if the tape can't be rewinded for some reason. + */ + error = st_rewind(unit, FALSE, SCSI_SILENT); + if (error != ESUCCESS) + return (error); + st->flags &= ~ST_PER_ACTION; + bzero(&scsi_cmd, sizeof(scsi_cmd)); + scsi_cmd.op_code = ERASE; + scsi_cmd.byte2 = SE_LONG; /* LONG erase */ + scsi_cmd.byte2 += immed ? SE_IMMED : 0; /* immed bit is here the 2nd! */ return (scsi_scsi_cmd(st->sc_link, (struct scsi_generic *) &scsi_cmd, sizeof(scsi_cmd), =================================================================== RCS file: /usr/src/sbin/st/RCS/st.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 11:04:05 --- 1.2 1994/08/28 15:28:42 *************** *** 71,76 **** --- 71,77 ---- { "status", MTNOP, 1 }, { "blocksize", MTSETBSIZ, 0 }, { "density", MTSETDNSTY, 0 }, + { "erase", MTERASE, 0 }, { 0 } }; =================================================================== RCS file: /usr/src/sbin/st/RCS/st.1,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** 1.1 1994/08/28 12:47:30 --- 1.2 1994/08/28 15:28:42 *************** *** 94,99 **** --- 94,102 ---- .It Cm rewind Rewind the tape (Count is ignored). + .It Cm erase + Erase the tape + (Count is ignored). .It Cm offline , rewoffl Rewind the tape and place the tape unit off-line (possibly eject) (Count is ignored). *************** *** 242,246 **** --- 245,251 ---- The .Nm st command appeared in 386BSD 0.1. + .Pp + Erase command added by Andreas Klemm <andreas@knobel.gun.de>, 08/28/94. .\" mt.1: mtio(4) missing -- andreas@knobel.gun.de /\/\___ Wiechers & Partner Datentechnik GmbH Andreas Klemm ___/\/\/ - Support Unix - akl@wup.de -