diff options
Diffstat (limited to 'bin')
-rw-r--r-- | bin/mt/mt.1 | 23 | ||||
-rw-r--r-- | bin/mt/mt.c | 30 |
2 files changed, 35 insertions, 18 deletions
diff --git a/bin/mt/mt.1 b/bin/mt/mt.1 index 424818bb18b..0e3ab697381 100644 --- a/bin/mt/mt.1 +++ b/bin/mt/mt.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mt.1,v 1.22 2005/04/26 16:23:48 jmc Exp $ +.\" $OpenBSD: mt.1,v 1.23 2005/05/01 18:56:36 deraadt Exp $ .\" $NetBSD: mt.1,v 1.8 1996/05/21 10:23:55 mrg Exp $ .\" .\" Copyright (c) 1981, 1990, 1993 @@ -36,6 +36,7 @@ .Sh NAME .Nm mt , .Nm eject +.Op Fl t .Nd magnetic tape and removable media manipulating program .Sh SYNOPSIS .Nm mt @@ -43,6 +44,7 @@ .Ar command .Op Ar count .Nm eject +.Op Fl t .Ar device .Sh DESCRIPTION The @@ -78,16 +80,23 @@ may also be used to eject other types of removable media. The options for .Nm are as follows: -.Bl -tag -width "-f deviceXX" +.Bl -tag -width Ds .It Fl f Ar device Operate on the .Ar device specified. -If the -.Fl f -flag is passed to -.Nm eject , -it is silently ignored. +.El +.Pp +.Pp +The options for +.Nm eject +are as follows: +.Bl -tag -width Ds +.It Fl t +Insert the device instead of ejecting. +For the +.Xr cd 4 +driver, this request that the tray be closed. .El .Pp The available commands are listed below. diff --git a/bin/mt/mt.c b/bin/mt/mt.c index c517d8c8de5..16b1bd49c84 100644 --- a/bin/mt/mt.c +++ b/bin/mt/mt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mt.c,v 1.24 2005/04/26 16:23:48 jmc Exp $ */ +/* $OpenBSD: mt.c,v 1.25 2005/05/01 18:56:36 deraadt Exp $ */ /* $NetBSD: mt.c,v 1.14.2.1 1996/05/27 15:12:11 mrg Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)mt.c 8.2 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: mt.c,v 1.24 2005/04/26 16:23:48 jmc Exp $"; +static char rcsid[] = "$OpenBSD: mt.c,v 1.25 2005/05/01 18:56:36 deraadt Exp $"; #endif #endif /* not lint */ @@ -83,14 +83,15 @@ struct commands { { "fsf", MTFSF, 1, 1 }, { "fsr", MTFSR, 1, 1 }, { "offline", MTOFFL, 1, 1 }, +#define COM_EJECT 9 /* element in the above array */ { "rewind", MTREW, 1, 1 }, { "rewoffl", MTOFFL, 1, 1 }, { "status", MTNOP, 1, 1 }, { "retension", MTRETEN, 1, 1 }, +#define COM_RETEN 13 /* element in the above array */ { "weof", MTWEOF, 0, 1 }, { NULL } }; -#define COM_EJECT 9 /* element in the above array */ void printreg(char *, u_int, char *); void status(struct mtget *); @@ -107,8 +108,8 @@ main(int argc, char *argv[]) struct commands *comp; struct mtget mt_status; struct mtop mt_com; - int ch, len, mtfd, flags; - char *p, *tape, *realtape; + int ch, len, mtfd, flags, insert = 0; + char *p, *tape, *realtape, *opts; if ((progname = strrchr(argv[0], '/'))) progname++; @@ -116,15 +117,20 @@ main(int argc, char *argv[]) progname = argv[0]; if (strcmp(progname, "eject") == 0) { + opts = "t"; eject = 1; tape = NULL; } else { + opts = "f:"; if ((tape = getenv("TAPE")) == NULL) tape = _PATH_DEFTAPE; } - while ((ch = getopt(argc, argv, "f:")) != -1) { + while ((ch = getopt(argc, argv, opts)) != -1) { switch (ch) { + case 't': + insert = 1; + break; case 'f': tape = optarg; break; @@ -140,7 +146,6 @@ main(int argc, char *argv[]) tape = *argv++; argc--; } - if (argc != 0) usage(); } else if (argc < 1 || argc > 2) @@ -157,9 +162,12 @@ main(int argc, char *argv[]) exit(X_ABORT); } - if (eject) - comp = &com[COM_EJECT]; - else { + if (eject) { + if (insert) + comp = &com[COM_RETEN]; + else + comp = &com[COM_EJECT]; + } else { len = strlen(p = *argv++); for (comp = com;; comp++) { if (comp->c_name == NULL) @@ -298,7 +306,7 @@ void usage(void) { if (eject) - (void)fprintf(stderr, "usage: %s device\n", progname); + (void)fprintf(stderr, "usage: %s [-t] device\n", progname); else (void)fprintf(stderr, "usage: %s [-f device] command [count]\n", progname); |