Who has implemented EOT support

Barry Shein bzs at bu-cs.bu.edu
Tue May 13 10:21:42 AEST 1986


I did the following to the 'mt' command to support a 'mt leot',
I haven't looked at it in a couple of years but the operators
here use it a lot (we append dumps to tapes for logical disks.)

Feel free, context diff follows.

	-Barry Shein, Boston University
-----
*** mt.c	Mon May 12 20:03:49 1986
--- mt.c.orig	Mon May 12 20:06:13 1986
***************
*** 2,7
  /*
   * mt --
   *   magnetic tape manipulation program
   */
  #include <stdio.h>
  #include <ctype.h>

--- 2,10 -----
  /*
   * mt --
   *   magnetic tape manipulation program
+  *
+  *	NOTE: BZS - version with 'leot' (find logical end of tape)
+  *	in /usr/src/local/mt.c
   */
  #include <stdio.h>
  #include <ctype.h>
***************
*** 11,17
  
  #define	equal(s1,s2)	(strcmp(s1, s2) == 0)
  
- #define MTLEOT	MTNOP+1		/* BZS psuedo-op	*/
  struct commands {
  	char *c_name;
  	int c_code;

--- 14,19 -----
  
  #define	equal(s1,s2)	(strcmp(s1, s2) == 0)
  
  struct commands {
  	char *c_name;
  	int c_code;
***************
*** 27,33
  	{ "offline",	MTOFFL,	1 },
  	{ "rewoffl",	MTOFFL,	1 },
  	{ "status",	MTNOP,	1 },
- 	{ "leot",	MTLEOT,	1 },	/* BZS */
  	{ 0 }
  };
  

--- 29,34 -----
  	{ "offline",	MTOFFL,	1 },
  	{ "rewoffl",	MTOFFL,	1 },
  	{ "status",	MTNOP,	1 },
  	{ 0 }
  };
  
***************
*** 66,81
  		perror(tape);
  		exit(1);
  	}
! 	if(comp->c_code == MTLEOT)	/* BZS	*/
! 	{
! 		if(mtleot(mtfd))
! 		{
! 			perror("leot") ;
! 			exit(2) ;
! 		}
! 		else exit(0) ;
! 	}
! 	else if (comp->c_code != MTNOP) {
  		mt_com.mt_op = comp->c_code;
  		mt_com.mt_count = (argc > 2 ? atoi(argv[2]) : 1);
  		if (mt_com.mt_count < 0) {

--- 67,73 -----
  		perror(tape);
  		exit(1);
  	}
! 	if (comp->c_code != MTNOP) {
  		mt_com.mt_op = comp->c_code;
  		mt_com.mt_count = (argc > 2 ? atoi(argv[2]) : 1);
  		if (mt_com.mt_count < 0) {
***************
*** 183,211
  					;
  		}
  		putchar('>');
- 	}
- }
- /*
-  *	BZS - find the logical end of tape and position between the
-  *	two tape marks
-  */
- mtleot(fd) int fd ;
- {
- 	struct mtop mt ;
- 	char buf[BUFSIZ] ;
- 	int i = 0 ;
- 
- 	mt.mt_count = 1 ;
- 	mt.mt_op = MTFSF ;
- 	for(;;i++)
- 	{
- 		if(ioctl(fd,MTIOCTOP,&mt) == -1) return(-1) ;
- 		if(read(mtfd,buf,BUFSIZ) == 0)
- 		{
- 			mt.mt_op = MTBSF ;
- 			ioctl(fd,MTIOCTOP,&mt) ;
- 			printf("%d files skipped\n",++i) ;
- 			return(0) ;
- 		}
  	}
  }

--- 175,179 -----
  					;
  		}
  		putchar('>');
  	}
  }



More information about the Comp.unix.wizards mailing list