bin/105721: Misleading error message from e.g. "df -l -t ufs"
Fabian Ruch
Fabian.Ruch at gmx.de
Tue Nov 28 07:52:08 PST 2006
The following reply was made to PR bin/105721; it has been noted by GNATS.
From: Fabian Ruch <Fabian.Ruch at gmx.de>
To: bug-followup at FreeBSD.org, john at jnielsen.net
Cc:
Subject: Re: bin/105721: Misleading error message from e.g. "df -l -t ufs"
Date: Tue, 28 Nov 2006 16:46:59 +0100
A short time ago I contacted the submitter John Nielsen. Now he
suggested that I send a similar mail as followup. This is my first look
at a problem report as you probably can see when looking at my "fix"
(works out, but maybe doesn't please you). Please give me feedback and
tell me what to do better next time.
When there are filesystems not mounted locally df should report an error
if the '-l' and '-t' arguments are specified at the same time. But the
correct error ("-l and -t are mutually exclusive.") is only mentioned if
you specify the '-t' argument before the '-l' one. Otherwise df thinks
'-t' is specified twice ("only one -t option may be specified").
Another problem can be discussed. Shall df break if the '-l' argument is
specified but it doesn't effect anything? df behaves in the same
situation in different ways depending on the order the arguments appear.
For example if '-l' specified first df ignores this and goes on. In
contrast df breaks if '-l' is specified after '-t' ("-l and -t are
mutually exclusive."). This should be displayed in both cases or in none
of both.
Now there is more than one way to solve the problem. We could declare
another flag variable (to tell df that '-l' is specified). Another way
is to check whether '-l' effects df's work.
The added Fix does declare another flag variable (no great work, I
know). df will break at to points. The first breakpoint is when the '-t'
argument is specified twice and '-l' isn't specified at this time. The
second breakpoint is when '-t' and '-l' are specified at the same time.
Regards,
Fabian
--
--- df.c Mon Jan 10 09:39:21 2005
+++ df.c Sun Nov 26 17:59:04 2006
@@ -93,7 +93,7 @@
return (a > b ? a : b);
}
-static int aflag = 0, cflag, hflag, iflag, nflag;
+static int aflag = 0, lflag = 0, cflag, hflag, iflag, nflag;
static struct ufs_args mdev;
int
@@ -147,8 +147,9 @@
hflag = 0;
break;
case 'l':
- if (vfslist != NULL)
+ if (!lflag && vfslist != NULL)
errx(1, "-l and -t are mutually
exclusive.");
+ lflag = 1;
vfslist = makevfslist(makenetvfslist());
break;
case 'm':
@@ -159,7 +160,9 @@
nflag = 1;
break;
case 't':
- if (vfslist != NULL)
+ if (lflag)
+ errx(1, "-l and -t are mutually
exclusive.");
+ else if (vfslist != NULL)
errx(1, "only one -t option may be
specified");
fstype = optarg;
vfslist = makevfslist(optarg);
More information about the freebsd-bugs
mailing list