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.
This commit is contained in:
Joerg Wunsch 1995-07-16 10:16:26 +00:00
parent 97e156674d
commit a471a8c32e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9541
2 changed files with 24 additions and 2 deletions

View File

@ -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.

View File

@ -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__) */