[comp.unix.i386] wangtek retensioning problems

tim@comcon.UUCP (Tim Brown) (02/01/90)

Ok, I give up!  Does anyone know how to write a tape command to retension
, rewind and erase etc for a wangtek tape drive running under ISC2.0.2?
I have written some ioctl calls but I am obviously missing something on
thsi one.  I can't figure out which include file to use, the wtioctl.h
file is about four lines long and those calls don't seem to work.  Can
someone help?  I really need this, I have several tapes that won't work
at all.

Thanks.

Tim Brown                           |
Computer Connection                 |
(attmail or uunet)!comcon!tim       |

rli@buster.irby.com (Buster Irby) (02/03/90)

>tim@comcon.UUCP (Tim Brown) writes:

>Ok, I give up!  Does anyone know how to write a tape command to retension
>, rewind and erase etc for a wangtek tape drive running under ISC2.0.2?
>I have written some ioctl calls but I am obviously missing something on
>thsi one.  I can't figure out which include file to use, the wtioctl.h
>file is about four lines long and those calls don't seem to work.  Can
>someone help?  I really need this, I have several tapes that won't work
>at all.

I wondered why ISC didn't include such a utility with 386/ix when 
I first installed it on my machine.  I finally got tired of waiting
and built my own.  BTW, I have only tried this on 386/ix 2.0.2 with
the wt(7) tape drivers installed, so be forewarned, it may not 
work on anything else!

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	ctape.1
#	ctape.c
# This archive created: Sat Feb  3 00:10:50 1990
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'ctape.1'
then
	echo shar: "will not over-write existing file 'ctape.1'"
else
cat << \SHAR_EOF > 'ctape.1'
.PU
.TH ctape 1 local
.SH NAME
ctape \- cartridge tape utility program
.SH SYNOPSIS
.ll +8
.B ctape
[
.B \-erq
] [
.B device
]
.ll -8
.SH DESCRIPTION
Ctape allows the user to execute cartridge tape commands from
the command line.  Three options are available, 
.B \-e 
causes the tape to be erased, and
.B \-r
retensions the tape, and
.B \-q
selects the quiet mode (no diagnostics).
If neither the -e or the -r option is specified, 
the tape will be retensioned.  If a <device> is named
on the command line, that device will be used, otherwise
/dev/tape will be used.
.PP
If the erase option is specified, there is a 5 second
pause before the command is executed to provide the
user time to change his(her) mind.
.br
.SH "FILES"
/dev/tape
.br
/dev/ntape
.SH "SEE ALSO"
mt(7), wt(7)
.SH "DIAGNOSTICS"
Usage: ctape [ -erq ] [ <device> ]
.br
Unable to open device \'<device>\'
.br
Erasing tape
.br
Retensioning cartridge
.br
device error, <errno>
.br
.SH "BUGS"
None found, yet.
.SH "CAVEAT"
This is a very hardware specific utility, which is only
known to work with the Wangtek tape driver supplied
with 386/ix 2.0.2.  
.SH "AUTHOR"
Buster Irby 
.br
rli@buster.irby.com
SHAR_EOF
fi
if test -f 'ctape.c'
then
	echo shar: "will not over-write existing file 'ctape.c'"
else
cat << \SHAR_EOF > 'ctape.c'
/*=============================================================================
                  ctape.c - cartridge tape utility program

                            rli@buster.irby.com

     This program is copyright (c) 1990, Buster Irby, and as such, you
     are hereby granted the right  to  alter, break, change, disclose,
     distribute,  erase,  fix, modify, publish, reproduce, use, or not
     as you see fit.  No rights reserved.

=============================================================================*/
#include  <stdio.h>
#include  <ctype.h>
#include  <fcntl.h>
#include  <sys/wtioctl.h>

     extern int  errno;       
     extern char *optarg;
     extern int  optind;

#define   TRUE      1
#define   FALSE     0

/*-----------------------------------------------------------------------------
     Name:     ctape - cartridge tape erase/retension utility program
     Syntax:   ctape -er [device]
               -e        erase tape
               -r        retension tape (default)
               [device]  is an optional raw tape device name,
                         the default tape device is /dev/tape.
-----------------------------------------------------------------------------*/
main( argc, argv )
int  argc;
char **argv;
{
     char *p_tape;
     char *pname;
     int  c;   
     int  c_tape;
     int  f_quiet;
     int  tape_cmd;

     tape_cmd = RETENS;                           /* Default command         */
     pname = argv[0];                             /* Program name            */
     f_quiet = FALSE;
     while(( c = getopt( argc, argv, "erq" )) != -1  )
     {
          switch( c )                             /* Parse command options   */
          {
               case 'e':
                    tape_cmd = ERASE;
                    break;
               case 'r':
                    tape_cmd = RETENS;
                    break;
               case 'q':
                    f_quiet = TRUE;
                    break;
               default:
                    usage( pname );
                    break;
          }
     }
     if( optind < argc )                          /* Parse tape device       */
          p_tape = argv[ optind ];
     else 
          p_tape = "/dev/tape";
     if(( c_tape = open( p_tape, O_RDWR )) == -1 )
     {
          fprintf( stderr, "%s: Unable to open device '%s'\n", pname, p_tape );
          exit( 1 );
     }
     if( !f_quiet )                               /* Display diagnostics     */
     {
          switch( tape_cmd )
          {
               case ERASE:    
                    printf( "Erasing %s\n", p_tape );
                    break;
               case RETENS:
                    printf( "Retensioning %s\n", p_tape );
                    break;
          }    
     }
     if( tape_cmd == ERASE )
          sleep( 5 );                             /* CAUTION: Saftey valve   */
     if( ioctl( c_tape, WTQICMD, tape_cmd ) == -1 )
     {
          fprintf( stderr, "%s: %s device error, %d\n", pname, p_tape, errno );
          exit( 1 );
     }
     exit( 0 );
}

usage( pname )
char *pname;
{
     fprintf( stderr, "%s: [ -erq ] [ device ]\n", pname );
     exit( 1 );
}
SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
Buster Irby  buster!rli

gemini@geminix.UUCP (Uwe Doering) (02/05/90)

tim@comcon.UUCP (Tim Brown) writes:

>Ok, I give up!  Does anyone know how to write a tape command to retension
>, rewind and erase etc for a wangtek tape drive running under ISC2.0.2?
>I have written some ioctl calls but I am obviously missing something on
>thsi one.  I can't figure out which include file to use, the wtioctl.h
>file is about four lines long and those calls don't seem to work.  Can
>someone help?  I really need this, I have several tapes that won't work
>at all.

I've had the same problem recently. Rewinding should work automatically
before and after the tape is actually used (at least I think so).

For erasing and retensioning tapes I wrote two simple programs that should
do the trick. I've tested them with the Wangtek 150 MB streamer model.
I've named them `wterase' and `wtretens'. Here they are:

------------------------- cut here -------------------------
/* Erase command for Wangtek streamer driver (386/ix 2.0.2) */

#include <stdio.h>
#include <fcntl.h>
#include <sys/wtioctl.h>

main()
{
	int fildes;

	if ((fildes = open("/dev/tape", O_WRONLY | O_NDELAY)) == -1)
	{
		perror("wterase: can't open /dev/tape");
		exit(2);
	}

	if (ioctl(fildes, WTQICMD, ERASE) == -1)
	{
		perror("wterase: error on ioctl call");
		exit(2);
	}

	if (close(fildes) == -1)
	{
		perror("wterase: can't close /dev/tape");
		exit(2);
	}

	exit(0);
}
------------------------- cut here -------------------------
/* Retension command for Wangtek streamer driver (386/ix 2.0.2) */

#include <stdio.h>
#include <fcntl.h>
#include <sys/wtioctl.h>

main()
{
	int fildes;

	if ((fildes = open("/dev/tape", O_RDONLY)) == -1)
	{
		perror("wtretens: can't open /dev/tape");
		exit(2);
	}

	if (ioctl(fildes, WTQICMD, RETENS) == -1)
	{
		perror("wtretens: error on ioctl call");
		exit(2);
	}

	if (close(fildes) == -1)
	{
		perror("wtretens: can't close /dev/tape");
		exit(2);
	}

	exit(0);
}
------------------------- cut here -------------------------
-- 
Uwe Doering   |  Domain   : gemini@netmbx.UUCP
Berlin        |---------------------------------------------------------------
West Germany  |  Bangpath : ...!uunet!unido!tmpmbx!netmbx!gemini

wsinpdb@eutws1.win.tue.nl (Paul de Bra) (02/07/90)

In article <OMLCD2@geminix.UUCP> gemini@netmbx.UUCP writes:
>tim@comcon.UUCP (Tim Brown) writes:
>
>>Ok, I give up!  Does anyone know how to write a tape command to retension
>>, rewind and erase etc for a wangtek tape drive running under ISC2.0.2?
>...
>For erasing and retensioning tapes I wrote two simple programs that should
>do the trick. I've tested them with the Wangtek 150 MB streamer model.
>I've named them `wterase' and `wtretens'. Here they are:
>...

Amazing how much duplication of effort we see for such a simple problem.

The real and simple solution is to use the tapecntl(1) command:

tapecntl [ -etrw ] [ -p arg ]

where e=erase, t=retension, r=reset device, w=rewind tape and p[n]=
position tape to n-th end-of-file mark.

This command is in AT&T sVr3.2 on which all others are based.
If your vendor did not supply this program you should complain.
The program exists and is documented in the manual.
Of course it assumes the presence of a Wangtek drive (as that's the one
AT&T sells). I have also succesfully used it with an Everex controller
instead of the Wangtek controller AT&T sells.

Maybe this should go into the list of frequently asked questions?

Paul.
(debra@research.att.com)

tneff@bfmny0.UU.NET (Tom Neff) (02/08/90)

In article <1467@eutrc3.urc.tue.nl> wsinpdb@eutws1.win.tue.nl (Paul de Bra) writes:
>Amazing how much duplication of effort we see for such a simple problem.
>The real and simple solution is to use the tapecntl(1) command:
>	tapecntl [ -etrw ] [ -p arg ]

Yes it is amazing how much duplication! but the above is part of the
problem, not part of the solution.

It has been pointed out recently and at length that tapecntl(1) is not
part of many non-AT&T distributions.  All sorts of replacement programs
have been posted, I have saved several of them and more are appearing as
the question is re- and re-asked and -answered.

AT&T customers (I'm one), please remember that AT&T *themselves* do
value adding on the standard distribution before end user resale, just
as other vendors like Interactive do.  There are things we have that
others don't, and vice versa.

(I await with delight the first time someone answers an ISC user's query
with a contemptuous, "Just use FACE you idiot!"  :-) )

tim@comcon.UUCP (Tim Brown) (02/09/90)

I am the original poster, and I *did* read the original discussion about
tapecntl.  It didn't do me any good then nor now as tapecntl *did not* come
with ISC2.0.2.  The help I received from my post worked, thanks very
much. 


Tim Brown                           |
Computer Connection                 |
(attmail or uunet)!comcon!tim       |

gemini@geminix.UUCP (Uwe Doering) (02/10/90)

wsinpdb@eutws1.win.tue.nl (Paul de Bra) writes:

>In article <OMLCD2@geminix.UUCP> gemini@netmbx.UUCP writes:
>>tim@comcon.UUCP (Tim Brown) writes:
>>
>>>Ok, I give up!  Does anyone know how to write a tape command to retension
>>>, rewind and erase etc for a wangtek tape drive running under ISC2.0.2?
>>...
>>For erasing and retensioning tapes I wrote two simple programs that should
>>do the trick. I've tested them with the Wangtek 150 MB streamer model.
>>I've named them `wterase' and `wtretens'. Here they are:
>>...

>Amazing how much duplication of effort we see for such a simple problem.

>The real and simple solution is to use the tapecntl(1) command:
> ...
>This command is in AT&T sVr3.2 on which all others are based.

I couldn't find it in ISC 386/ix 2.0.2. I searched the whole directory
tree with find(1). Nothing.

>If your vendor did not supply this program you should complain.

OK, but this doesn't help me right now. And you should know that it
doesn't matter so much what brand the streamer itself is, but what
device driver you have in your UNIX. This is the one the tapecntl(1)
command has to cope with. And I'm quite sure that the ISC wt driver
won't understand the tapecntl(1) ioctl-calls. This should be the
reason why this utility isn't shipped with 386/ix.

After all, writing device drivers is the main task the UNIX vendors
do, and as long as there is no standard how things should be done
every vendor will invent its own driver interface to the application
programs.

But of course this doesn't explain why ISC doesn't ship its own utility
for the wt streamer. Maybe I've looked at the wrong places. If someone
(hello ISC) knows better please tell us.

     Uwe
-- 
Uwe Doering   |  Domain   : gemini@netmbx.UUCP
Berlin        |---------------------------------------------------------------
West Germany  |  Bangpath : ...!uunet!unido!tmpmbx!netmbx!gemini

keithe@tekgvs.LABS.TEK.COM (Keith Ericson) (02/12/90)

In article <1467@eutrc3.urc.tue.nl> wsinpdb@eutws1.win.tue.nl (Paul de Bra) writes:
<In article <OMLCD2@geminix.UUCP> gemini@netmbx.UUCP writes:
<>tim@comcon.UUCP (Tim Brown) writes:
<>
<>...
<>For erasing and retensioning tapes I wrote two simple programs that should
<>do the trick. I've tested them with the Wangtek 150 MB streamer model.
<>I've named them `wterase' and `wtretens'. Here they are:
<>...
<
<Amazing how much duplication of effort we see for such a simple problem.
<
<The real and simple solution is to use the tapecntl(1) command:
<
<tapecntl [ -etrw ] [ -p arg ]
<
<where e=erase, t=retension, r=reset device, w=rewind tape and p[n]=
<position tape to n-th end-of-file mark.
<

OK: thanks for the erasing and retensions substitutes for the
tapecntl functions.  Now, can someone contribute a "move to n-th
end-of-file mark program," a clone of tapecntl -p <num>, please?

Thank you.

keith (why is tapecntl buried in /usr/lib/tape, anyway?) ericson