summaryrefslogtreecommitdiffstats
path: root/usr.bin/mt
diff options
context:
space:
mode:
authorjoerg <joerg@FreeBSD.org>1995-07-16 10:16:26 +0000
committerjoerg <joerg@FreeBSD.org>1995-07-16 10:16:26 +0000
commit237dca12dea4f56dd7ca60b754f97eafbd8c8ced (patch)
treeaec28d08e99345a2ee52ba881d0408324c11ebe4 /usr.bin/mt
parent81e1e32f6c0662907cdbde6c1f5269cf8217838c (diff)
downloadFreeBSD-src-237dca12dea4f56dd7ca60b754f97eafbd8c8ced.zip
FreeBSD-src-237dca12dea4f56dd7ca60b754f97eafbd8c8ced.tar.gz
Remove the dangerous "eof" command that used to be an alias for "weof"
but usually got confused with "eom". It didn't ring the warning bell saying: "You are probably going to mark your whole tape as deleted right now." A warning message pointing to "weof" and "eom" is issued instead.
Diffstat (limited to 'usr.bin/mt')
-rw-r--r--usr.bin/mt/mt.12
-rw-r--r--usr.bin/mt/mt.c24
2 files changed, 24 insertions, 2 deletions
diff --git a/usr.bin/mt/mt.1 b/usr.bin/mt/mt.1
index 3eea41b..d27c168 100644
--- a/usr.bin/mt/mt.1
+++ b/usr.bin/mt/mt.1
@@ -60,7 +60,7 @@ The available commands are listed below. Only as many
characters as are required to uniquely identify a command
need be specified.
.Bl -tag -width "eof, weof"
-.It Cm eof , weof
+.It Cm weof
Write
.Ar count
end-of-file marks at the current position on the tape.
diff --git a/usr.bin/mt/mt.c b/usr.bin/mt/mt.c
index a40ef90..2aab88b 100644
--- a/usr.bin/mt/mt.c
+++ b/usr.bin/mt/mt.c
@@ -61,6 +61,7 @@ static char sccsid[] = "@(#)mt.c 8.1 (Berkeley) 6/6/93";
#define NEED_2ARGS 0x01
#define ZERO_ALLOWED 0x02
#define IS_DENSITY 0x04
+#define DISABLE_THIS 0x08
#endif /* defined(__FreeBSD__) */
struct commands {
@@ -73,7 +74,13 @@ struct commands {
} com[] = {
{ "bsf", MTBSF, 1 },
{ "bsr", MTBSR, 1 },
- { "eof", MTWEOF, 0 },
+#if defined(__FreeBSD__)
+ /* XXX FreeBSD considered "eof" dangerous, since it's being
+ confused with "eom" (and is an alias for "weof" anyway) */
+ { "eof", MTWEOF, 0, DISABLE_THIS },
+#else
+ { "eof", MTWEOF, 0 },
+#endif
{ "fsf", MTFSF, 1 },
{ "fsr", MTFSR, 1 },
{ "offline", MTOFFL, 1 },
@@ -99,6 +106,7 @@ void usage __P((void));
void st_status (struct mtget *);
int stringtodens (const char *s);
const char *denstostring (int d);
+void warn_eof __P((void));
#endif /* defined (__FreeBSD__) */
int
@@ -141,6 +149,9 @@ main(argc, argv)
#if defined(__FreeBSD__)
if((comp->c_flags & NEED_2ARGS) && argc != 2)
usage();
+ if(comp->c_flags & DISABLE_THIS) {
+ warn_eof();
+ }
#endif /* defined(__FreeBSD__) */
if ((mtfd = open(tape, comp->c_ronly ? O_RDONLY : O_RDWR)) < 0)
err("%s: %s", tape, strerror(errno));
@@ -433,4 +444,15 @@ st_status(struct mtget *bp)
denstostring(bp->mt_density3), getblksiz(bp->mt_blksiz3));
}
+void
+warn_eof(void)
+{
+ fprintf(stderr,
+ "The \"eof\" command has been disabled.\n"
+ "Use \"weof\" if you really want to write end-of-file marks,\n"
+ "or \"eom\" if you rather want to skip to the end of "
+ "recorded medium.\n");
+ exit(1);
+}
+
#endif /* defined (__FreeBSD__) */
OpenPOWER on IntegriCloud