From: Stelian Pop Date: Sat, 26 May 2001 11:11:16 +0000 (+0000) Subject: Implement the Sun extended rmt protocol. X-Git-Tag: release_0_4b23~15 X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=commitdiff_plain;h=5a7167e93a7975616f2f3fb4bc48b3fbd8080672 Implement the Sun extended rmt protocol. --- diff --git a/CHANGES b/CHANGES index c062bca..6282580 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,4 @@ -$Id: CHANGES,v 1.115 2001/05/26 11:04:46 stelian Exp $ +$Id: CHANGES,v 1.116 2001/05/26 11:11:16 stelian Exp $ Changes between versions 0.4b22 and 0.4b23 (released ????????????) ================================================================== @@ -6,6 +6,9 @@ Changes between versions 0.4b22 and 0.4b23 (released ????????????) 1. Fixed a buffer overflow in restore/tape.c. Patch provided by Marcus Meissner (Caldera International Security Dept.). +2. Implement the Sun rmt extended protocol. Patch submitted + by Ian Gordon . + Changes between versions 0.4b21 and 0.4b22 (released May 12, 2001) ================================================================== diff --git a/THANKS b/THANKS index 02c17e7..f5fc5bc 100644 --- a/THANKS +++ b/THANKS @@ -1,4 +1,4 @@ -$Id: THANKS,v 1.44 2001/04/10 12:46:53 stelian Exp $ +$Id: THANKS,v 1.45 2001/05/26 11:11:16 stelian Exp $ Dump and restore were written by the people of the CSRG at the University of California, Berkeley. @@ -37,6 +37,7 @@ Jason Fearon jasonf@netrider.org.au Jeremy Fitzhardinge jeremy@goop.org Eirik Fuller eirik@netcom.com Uwe Gohlke uwe@ugsoft.de +Ian Gordon iangordon@users.sourceforge.net Andreas Hasenack andreas@conectiva.com.br Christian Haul haul@informatik.tu-darmstadt.de Jean-Paul van der Jagt jeanpaul@dutepp0.et.tudelft.nl diff --git a/rmt/rmt.c b/rmt/rmt.c index e23d0a3..bde137d 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.14 2001/04/27 15:22:47 stelian Exp $"; + "$Id: rmt.c,v 1.15 2001/05/26 11:11:16 stelian Exp $"; #endif /* not linux */ /* @@ -78,6 +78,30 @@ FILE *debug; #define DEBUG1(f,a) if (debug) fprintf(debug, f, a) #define DEBUG2(f,a1,a2) if (debug) fprintf(debug, f, a1, a2) +/* + * Support for Sun's extended RMT protocol + */ +#define RMTI_VERSION -1 +#define RMT_VERSION 1 + +/* Extended 'i' commands */ +#define RMTI_CACHE 0 +#define RMTI_NOCACHE 1 +#define RMTI_RETEN 2 +#define RMTI_ERASE 3 +#define RMTI_EOM 4 +#define RMTI_NBSF 5 + +/* Extended 's' comands */ +#define MTS_TYPE 'T' +#define MTS_DSREG 'D' +#define MTS_ERREG 'E' +#define MTS_RESID 'R' +#define MTS_FILENO 'F' +#define MTS_BLKNO 'B' +#define MTS_FLAGS 'f' +#define MTS_BF 'b' + char *checkbuf __P((char *, int)); void error __P((int)); void getstring __P((char *)); @@ -175,7 +199,10 @@ top: getstring(op); getstring(count); DEBUG2("rmtd: I %s %s\n", op, count); - { struct mtop mtop; + if (atoi(op) == RMTI_VERSION) { + rval = RMT_VERSION; + } else { + struct mtop mtop; mtop.mt_op = atoi(op); mtop.mt_count = atoi(count); if (ioctl(tape, MTIOCTOP, (char *)&mtop) < 0) @@ -184,6 +211,56 @@ top: } goto respond; + case 'i': + { struct mtop mtop; + + getstring (op); + getstring (count); + DEBUG2 ("rmtd: i %s %s\n", op, count); + switch (atoi(op)) { +#ifdef MTCACHE + case RMTI_CACHE: + mtop.mt_op = MTCACHE; + break; +#endif +#ifdef MTNOCACHE + case RMTI_NOCACHE: + mtop.mt_op = MTNOCACHE; + break; +#endif +#ifdef MTRETEN + case RMTI_RETEN: + mtop.mt_op = MTRETEN; + break; +#endif +#ifdef MTERASE + case RMTI_ERASE: + mtop.mt_op = MTERASE; + break; +#endif +#ifdef MTEOM + case RMTI_EOM: + mtop.mt_op = MTEOM; + break; +#endif +#ifdef MTNBSF + case RMTI_NBSF: + mtop.mt_op = MTNBSF; + break; +#endif + default: + errno = EINVAL; + goto ioerror; + } + mtop.mt_count = atoi (count); + if (ioctl (tape, MTIOCTOP, (char *) &mtop) < 0) + goto ioerror; + + rval = mtop.mt_count; + + goto respond; + } + case 'S': /* status */ DEBUG("rmtd: S\n"); { struct mtget mtget; @@ -196,6 +273,49 @@ top: goto top; } + case 's': + { char s; + struct mtget mtget; + + if (read (0, &s, 1) != 1) + goto top; + + if (ioctl (tape, MTIOCGET, (char *) &mtget) < 0) + goto ioerror; + + switch (s) { + case MTS_TYPE: + rval = mtget.mt_type; + break; + case MTS_DSREG: + rval = mtget.mt_dsreg; + break; + case MTS_ERREG: + rval = mtget.mt_erreg; + break; + case MTS_RESID: + rval = mtget.mt_resid; + break; + case MTS_FILENO: + rval = mtget.mt_fileno; + break; + case MTS_BLKNO: + rval = mtget.mt_blkno; + break; + case MTS_FLAGS: + rval = mtget.mt_gstat; + break; + case MTS_BF: + rval = 0; + break; + default: + errno = EINVAL; + goto ioerror; + } + + goto respond; + } + case 'V': /* version */ getstring(op); DEBUG1("rmtd: V %s\n", op);