From 237dca12dea4f56dd7ca60b754f97eafbd8c8ced Mon Sep 17 00:00:00 2001 From: joerg Date: Sun, 16 Jul 1995 10:16:26 +0000 Subject: 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. --- usr.bin/mt/mt.1 | 2 +- usr.bin/mt/mt.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'usr.bin/mt') 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__) */ -- cgit v1.1