tapectrl / ctape | Is there a scsi tape control for ISC 2.2?

Todd Merriman todd at toolz.UUCP
Mon Feb 4 13:33:07 AEST 1991


randyt at asdnet (Randy Terbush) writes:
>I am running ISC 2.2 with an Adaptec 1542A controlling an
>Archive 2150s.  I am looking for a tape control program.

#ifdef VCSTR
 static char TAPECNTLC[]="@(#) tapecntl.c 1.3 91/01/17 08:52:22";  /*sccsid*/
#endif

#ifdef DOCUMENTATION
 ******************************* DOCZ Header *********************************
.MODULE				tapecntl
.LIBRARY 			toolz
.TYPE 				program
.SYSTEM				unix
.AUTHOR				Todd Merriman
.LANGUAGE			C
.APPLICATION		system
.DESCRIPTION		
	Control the tape device
.ARGUMENTS			
	tapecntl <option> <device>
		tapecntl -w 	rewind tape
		tapecntl -e 	erase tape
		tapecntl -r 	retension tape
		tapecntl -p		device parameters
.NARRATIVE			
	The TAPECNTL program sends commands to the tape device.
	The devcice parameters command will produce a display:
		If
			A long-term operation is in progress
		If
			Tape is at EOT
		If
			Tape is at EOF
		If
			Tape is read-only
		If
			Tape will rewind on close
		And
			The record size
.RETURNS 			
	nothing
.REVISION			1/1/91
	Added -p option
.ENDOC				END DOCUMENTATION
 *****************************************************************************
#endif	/* DOCUMENTATION */

#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/gentape.h>
#include "csub.h"

struct tc_parms Parms;
char	Globuff [512];

static char *Umsg [] =
{
	"tapecntl <option> <device>",
	"   tapecntl -w   rewind tape",
	"   tapecntl -e   erase tape",
	"   tapecntl -r   retension tape",
	"   tapecntl -p   device parameters",
	NULL
};

/*****************************************************************************
	Main entry
*****************************************************************************/
main(argc,argv)
	int argc;
	char *argv[];
{
	int	td,
			exitstat = 0;

	if (argc > 2)
	{
		if ((td = open(argv[2],O_RDONLY)) != EOF)
		{
			switch (argv[1][1])
			{
				case 'w':
					if (ioctl(td,TC_REWIND))
						fprintf(stderr,"rewind error\n");
					break;
				case 'e':
					if (ioctl(td,TC_ERASE))
						fprintf(stderr,"erase error\n");
					break;
				case 'r':
					if (ioctl(td,TC_RETENSION))
						fprintf(stderr,"retension error\n");
					break;
				case 'p':
					if (read(td,Globuff,512) != 512)
						fprintf(stderr,"Read failure!\7\n");
					else
					{
						if (ioctl(td,TC_GETPARMS,&Parms))
							fprintf(stderr,"Parameter read error!\7\n");
						else
						{
							if (Parms.tcp_flags & TCPF_LONGOP)
								puts("A long-term operation is in progress");
							if (Parms.tcp_flags & TCPF_ATEOT)
								puts("Tape is at EOT");
							if (Parms.tcp_flags & TCPF_ATEOF)
								puts("Tape is at EOF");
							if (Parms.tcp_flags & TCPF_RDONLY)
								puts("Tape is read-only");
							if (Parms.tcp_flags & TCPF_REWIND)
								puts("Tape will rewind on close");
							printf("Record size = %ld\n",(long)Parms.tcp_recsiz);
						}
					}
					break;
			}
			close(td);
		}
		else
		{
			fprintf(stderr,"tapecntl: Cannot open: %s!\7\n",argv[2]);
			if (errno == ENODEV)
				fprintf(stderr,"tapecntl: Error: Device not ready\r\n");
			else
			{
				sysmsg(errno,Globuff);
				fprintf(stderr,"tapecntl: Error %d: %s\r\n",
					errno,Globuff);
			}
		}
	}
	else
		uprompt(Umsg,1);

	exit(exitstat);
}	/* end of main */

/*****************************************************************************
	End tapecntl.c
*****************************************************************************/



More information about the Comp.unix.sysv386 mailing list