wangtek retensioning problems

Buster Irby rli at buster.irby.com
Sat Feb 3 17:28:41 AEST 1990


>tim at 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 at 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 at 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



More information about the Comp.unix.i386 mailing list