From owner-freebsd-bugs@FreeBSD.ORG Tue Nov 28 15:52:08 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5507716A40F for ; Tue, 28 Nov 2006 15:52:08 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 005D443D76 for ; Tue, 28 Nov 2006 15:50:34 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kASFoSxH085229 for ; Tue, 28 Nov 2006 15:50:28 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kASFoSAq085228; Tue, 28 Nov 2006 15:50:28 GMT (envelope-from gnats) Date: Tue, 28 Nov 2006 15:50:28 GMT Message-Id: <200611281550.kASFoSAq085228@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Fabian Ruch Cc: Subject: Re: bin/105721: Misleading error message from e.g. "df -l -t ufs" X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Fabian Ruch List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Nov 2006 15:52:08 -0000 The following reply was made to PR bin/105721; it has been noted by GNATS. From: Fabian Ruch To: bug-followup@FreeBSD.org, john@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);