summaryrefslogtreecommitdiffstats
path: root/usr.bin/mt
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-04-17 21:55:11 +0000
committerjoerg <joerg@FreeBSD.org>1995-04-17 21:55:11 +0000
commite35369434b2ed49ded9bce42e7f02313117b4dba (patch)
treef9cbb614ebacdd8ddbc994ca983fead4851047df /usr.bin/mt
parentc21d11ed433776afcd9241a0536a8cf0ae0d2f36 (diff)
downloadFreeBSD-src-e35369434b2ed49ded9bce42e7f02313117b4dba.zip
FreeBSD-src-e35369434b2ed49ded9bce42e7f02313117b4dba.tar.gz
Round #1 of my st(1) -> mt(1) merge. All the commands should be
covered now, and i've attempted to give textual representations instead of magic numbers. The st(4) driver still misses some pieces; i'm going to implement the EOM functionality RSN. Any takers for the MTCOMP command? Seems to have never been implemented.
Diffstat (limited to 'usr.bin/mt')
-rw-r--r--usr.bin/mt/mt.185
-rw-r--r--usr.bin/mt/mt.c137
2 files changed, 216 insertions, 6 deletions
diff --git a/usr.bin/mt/mt.1 b/usr.bin/mt/mt.1
index 8da5b2d..4b63509 100644
--- a/usr.bin/mt/mt.1
+++ b/usr.bin/mt/mt.1
@@ -91,6 +91,17 @@ Erase the tape
(Count is ignored).
.It Cm status
Print status information about the tape unit.
+.It Cm blocksize
+Set the block size for the tape unit. Zero means variable-length
+blocks.
+.It Cm density
+Set the density for the tape unit. For the density codes, see below.
+.It Cm eom
+Forward space to end of recorded medium
+(Count is ignored).
+.It Cm comp
+Set compression mode.
+(Not yet implemented.)
.El
.Pp
If a tape name is not specified, and the environment variable
@@ -98,11 +109,68 @@ If a tape name is not specified, and the environment variable
does not exist;
.Nm mt
uses the device
-.Pa /dev/rmt12 .
+.Pa /dev/nrst0 .
.Pp
.Nm Mt
returns a 0 exit status when the operation(s) were successful,
1 if the command was unrecognized, and 2 if an operation failed.
+.Pp
+The different density codes are as follows:
+.Pp
+.Dl 0x0 default for device
+.Dl 0xE reserved for ECMA
+.Bd -literal -offset indent
+Value Tracks Density(bpi) Code Type Reference Note
+0x1 9 800 NRZI R X3.22-1983 2
+0x2 9 1600 PE R X3.39-1986 2
+0x3 9 6250 GCR R X3.54-1986 2
+0x5 4/9 8000 GCR C X3.136-1986 1
+0x6 9 3200 PE R X3.157-1987 2
+0x7 4 6400 IMFM C X3.116-1986 1
+0x8 4 8000 GCR CS X3.158-1986 1
+0x9 18 37871 GCR C X3B5/87-099 2
+0xA 22 6667 MFM C X3B5/86-199 1
+0xB 4 1600 PE C X3.56-1986 1
+0xC 24 12690 GCR C HI-TC1 1,5
+0xD 24 25380 GCR C HI-TC2 1,5
+0xF 15 10000 GCR C QIC-120 1,5
+0x10 18 10000 GCR C QIC-150 1,5
+0x11 26 16000 GCR C QIC-320(525?) 1,5
+0x12 30 51667 RLL C QIC-1350 1,5
+0x13 1 61000 DDS CS X3B5/88-185A 4
+0x14 1 43245 RLL CS X3.202-1991 4
+0x15 1 45434 RLL CS ECMA TC17 4
+0x16 48 10000 MFM C X3.193-1990 1
+0x17 48 42500 MFM C X3B5/91-174 1
+.Ed
+
+where Code means:
+.Bd -literal -offset indent
+NRZI Non Return to Zero, change on ones
+GCR Group Code Recording
+PE Phase Encoded
+IMFM Inverted Modified Frequency Modulation
+MFM Modified Frequency Modulation
+DDS Dat Data Storage
+RLL Run Length Encoding
+.Ed
+
+where Type means:
+.Bd -literal -offset indent
+R Reel-to-Reel
+C Cartridge
+CS cassette
+.Ed
+
+where Notes means:
+.Bd -literal -offset indent
+1 Serial Recorded
+2 Parallel Recorded
+3 Old format know as QIC-11
+4 Helical Scan
+5 Not ANSI standard, rather industry standard.
+.Ed
+
.Sh ENVIRONMENT
If the following environment variable exists, it is utilized by
.Nm mt .
@@ -116,12 +184,16 @@ argument
.Ar tapename
is not given.
.Sh FILES
-.Bl -tag -width /dev/rmt* -compact
-.It Pa /dev/rmt*
+.Bl -tag -width /dev/rwt* -compact
+.It Pa /dev/rwt*
Raw magnetic tape interface
+.It Pa /dev/*st[0-9]*
+SCSI magnetic tape interface
.El
.Sh SEE ALSO
.\".Xr mtio 4 ,
+.Xr st 4 ,
+.\".Xr wt 4 ,
.Xr dd 1 ,
.Xr ioctl 2 ,
.Xr environ 7
@@ -131,5 +203,10 @@ The
command appeared in
.Bx 4.3 .
.Pp
-Erase function added by Andreas Klemm <andreas@knobel.gun.de> 10/94.
+Extensions regarding the
+.Xr st 4
+driver appeared in 386BSD 0.1, and have been merged into the
+.Nm
+command in FreeBSD 2.1.
.\" mt.1: mtio(4) missing
+.\" mt.1: wt(4) missing
diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
index f535e8b..bd2adcd 100644
--- a/usr.bin/mt/mt.c
+++ b/usr.bin/mt/mt.c
@@ -55,10 +55,20 @@ static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93";
#include <ctype.h>
#include <string.h>
+/* the appropriate sections of <sys/mtio.h> are also #ifdef'd for FreeBSD */
+#if defined(__FreeBSD__)
+/* c_flags */
+#define NEED_2ARGS 0x01
+#define ZERO_ALLOWED 0X02
+#endif /* defined(__FreeBSD__) */
+
struct commands {
char *c_name;
int c_code;
int c_ronly;
+#if defined(__FreeBSD__)
+ int c_flags;
+#endif /* defined(__FreeBSD__) */
} com[] = {
{ "bsf", MTBSF, 1 },
{ "bsr", MTBSR, 1 },
@@ -70,7 +80,13 @@ struct commands {
{ "rewoffl", MTOFFL, 1 },
{ "status", MTNOP, 1 },
{ "weof", MTWEOF, 0 },
- { "erase", MTERASE, 0 }, /* Andreas Klemm <andreas@knobel.gun.de */
+#if defined(__FreeBSD__)
+ { "erase", MTERASE, 0 },
+ { "blocksize", MTSETBSIZ, 0, NEED_2ARGS|ZERO_ALLOWED },
+ { "density", MTSETDNSTY, 0, NEED_2ARGS|ZERO_ALLOWED },
+ { "eom", MTEOD, 1 },
+ { "comp", MTCOMP, 0, NEED_2ARGS|ZERO_ALLOWED },
+#endif /* defined(__FreeBSD__) */
{ NULL }
};
@@ -78,6 +94,9 @@ void err __P((const char *, ...));
void printreg __P((char *, u_int, char *));
void status __P((struct mtget *));
void usage __P((void));
+#if defined (__FreeBSD__)
+void st_status (struct mtget *);
+#endif /* defined (__FreeBSD__) */
int
main(argc, argv)
@@ -116,13 +135,28 @@ main(argc, argv)
if (strncmp(p, comp->c_name, len) == 0)
break;
}
+#if defined(__FreeBSD__)
+ if((comp->c_flags & NEED_2ARGS) && argc != 2)
+ usage();
+#endif /* defined(__FreeBSD__) */
if ((mtfd = open(tape, comp->c_ronly ? O_RDONLY : O_RDWR)) < 0)
err("%s: %s", tape, strerror(errno));
if (comp->c_code != MTNOP) {
mt_com.mt_op = comp->c_code;
if (*argv) {
+#if defined (__FreeBSD__)
+ /* allow for hex numbers; useful for density */
+ mt_com.mt_count = strtol(*argv, &p, 0);
+#else
mt_com.mt_count = strtol(*argv, &p, 10);
- if (mt_com.mt_count <= 0 || *p)
+#endif /* defined(__FreeBSD__) */
+ if (mt_com.mt_count <=
+#if defined (__FreeBSD__)
+ ((comp->c_flags & ZERO_ALLOWED)? -1: 0)
+#else
+ 0
+#endif /* defined (__FreeBSD__) */
+ || *p)
err("%s: illegal count", *argv);
}
else
@@ -177,6 +211,19 @@ struct tape_desc {
#ifdef tahoe
{ MT_ISCY, "cipher", CYS_BITS, CYCW_BITS },
#endif
+#if defined (__FreeBSD__)
+ /*
+ * XXX This is terrific. The st driver reports the tape drive
+ * as 0x7 (MT_ISAR - Sun/Archive compatible); the wt driver
+ * either reports MT_ISVIPER1 for an Archive tape, or 0x11
+ * (MT_ISMFOUR) for other tapes.
+ * XXX for the wt driver, rely on it behaving like a "standard"
+ * magtape driver.
+ */
+ { MT_ISAR, "SCSI tape drive", 0, 0 },
+ { MT_ISVIPER1, "Archive Viper", 0, 0 },
+ { MT_ISMFOUR, "Wangtek", 0, 0 },
+#endif /* defined (__FreeBSD__) */
{ 0 }
};
@@ -198,10 +245,18 @@ status(bp)
if (mt->t_type == bp->mt_type)
break;
}
+#if defined (__FreeBSD__)
+ if(mt->t_type == MT_ISAR)
+ st_status(bp);
+ else {
+#endif /* defined (__FreeBSD__) */
(void)printf("%s tape drive, residual=%d\n", mt->t_name, bp->mt_resid);
printreg("ds", bp->mt_dsreg, mt->t_dsbits);
printreg("\ner", bp->mt_erreg, mt->t_erbits);
(void)putchar('\n');
+#if defined (__FreeBSD__)
+ }
+#endif /* defined (__FreeBSD__) */
}
/*
@@ -273,3 +328,81 @@ err(fmt, va_alist)
exit(1);
/* NOTREACHED */
}
+
+#if defined (__FreeBSD__)
+
+struct densities {
+ int dens;
+ const char *name;
+} dens [] = {
+ { 0x1, "X3.22-1983 " },
+ { 0x2, "X3.39-1986 " },
+ { 0x3, "X3.54-1986 " },
+ { 0x5, "X3.136-1986 " },
+ { 0x6, "X3.157-1987 " },
+ { 0x7, "X3.116-1986 " },
+ { 0x8, "X3.158-1986 " },
+ { 0x9, "X3B5/87-099 " },
+ { 0xA, "X3B5/86-199 " },
+ { 0xB, "X3.56-1986 " },
+ { 0xC, "HI-TC1 " },
+ { 0xD, "HI-TC2 " },
+ { 0xF, "QIC-120 " },
+ { 0x10, "QIC-150 " },
+ { 0x11, "QIC-320 " },
+ { 0x12, "QIC-1350 " },
+ { 0x13, "X3B5/88-185A" },
+ { 0x14, "X3.202-1991 " },
+ { 0x15, "ECMA TC17 " },
+ { 0x16, "X3.193-1990 " },
+ { 0x17, "X3B5/91-174 " },
+ { 0, 0 }
+};
+
+const char *
+getdens(int d)
+{
+ static char buf[20];
+ struct densities *sd;
+
+ for (sd = dens; sd->dens; sd++)
+ if (sd->dens == d)
+ break;
+ if (sd->dens == 0) {
+ sprintf(buf, "0x%02x ", d);
+ return buf;
+ }
+ else
+ return sd->name;
+}
+
+const char *
+getblksiz(int bs)
+{
+ static char buf[25];
+ if (bs == 0)
+ return "variable";
+ else {
+ sprintf(buf, "= %d bytes", bs);
+ return buf;
+ }
+}
+
+
+void
+st_status(struct mtget *bp)
+{
+ printf("Present Mode: Density = %s Blocksize %s\n",
+ getdens(bp->mt_density), getblksiz(bp->mt_blksiz));
+ printf("---------available modes---------\n");
+ printf("Mode 0: Density = %s Blocksize %s\n",
+ getdens(bp->mt_density0), getblksiz(bp->mt_blksiz0));
+ printf("Mode 1: Density = %s Blocksize %s\n",
+ getdens(bp->mt_density1), getblksiz(bp->mt_blksiz1));
+ printf("Mode 2: Density = %s Blocksize %s\n",
+ getdens(bp->mt_density2), getblksiz(bp->mt_blksiz2));
+ printf("Mode 3: Density = %s Blocksize %s\n",
+ getdens(bp->mt_density3), getblksiz(bp->mt_blksiz3));
+}
+
+#endif /* defined (__FreeBSD__) */
OpenPOWER on IntegriCloud