From mwm@phone.net Sat Sep  4 13:43:00 1999
Return-Path: <mwm@phone.net>
Received: from guru.phone.net (guru.phone.net [209.157.82.120])
	by hub.freebsd.org (Postfix) with SMTP id 5DAF314C4F
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  4 Sep 1999 13:42:55 -0700 (PDT)
	(envelope-from mwm@phone.net)
Received: (qmail 18533 invoked by uid 100); 4 Sep 1999 20:42:54 -0000
Message-Id: <19990904204254.18532.qmail@guru.phone.net>
Date: 4 Sep 1999 20:42:54 -0000
From: mwm@phone.net
Reply-To: mwm@phone.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: df is missing a Posix flag
X-Send-Pr-Version: 3.2

>Number:         13579
>Category:       bin
>Synopsis:       df is missing a Posix flag
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mharo
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Sep  4 13:50:00 PDT 1999
>Closed-Date:    Tue Dec 14 19:41:07 PST 1999
>Last-Modified:  Tue Dec 14 19:44:26 PST 1999
>Originator:     Mike Meyer
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
Missionaria Phonibalonica
>Environment:

	older 3.2-stable system, but probably not fixed in -current

>Description:

	The Posix df has a "P" flag that forces Posix-compliant output.
	Since the output of df is already properly formatted, the only 
	change required is that it set the block size to the Posix default
	of 512 bytes.

>How-To-Repeat:

	Run the command "df -P", and notice that you get an error message.

>Fix:
	
Here's the patch to df.c

*** df.c-orig	Sat Sep  4 13:37:52 1999
--- df.c	Sat Sep  4 13:38:45 1999
***************
*** 88,100 ****
  	char *mntpt, *mntpath, **vfslist;
  
  	vfslist = NULL;
! 	while ((ch = getopt(argc, argv, "iknt:")) != -1)
  		switch (ch) {
  		case 'i':
  			iflag = 1;
  			break;
  		case 'k':
  			putenv("BLOCKSIZE=1k");
  			break;
  		case 'n':
  			nflag = 1;
--- 88,103 ----
  	char *mntpt, *mntpath, **vfslist;
  
  	vfslist = NULL;
! 	while ((ch = getopt(argc, argv, "iknPt:")) != -1)
  		switch (ch) {
  		case 'i':
  			iflag = 1;
  			break;
  		case 'k':
  			putenv("BLOCKSIZE=1k");
+ 			break;
+ 		case 'P':
+ 			putenv("BLOCKSIZE=512");
  			break;
  		case 'n':
  			nflag = 1;



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mharo  
Responsible-Changed-By: cpiazza 
Responsible-Changed-When: Sat Sep 4 13:58:09 PDT 1999 
Responsible-Changed-Why:  
mharo was working on this type of thing 

From: Steve Price <sprice@hiwaay.net>
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/13579: df is missing a Posix flag (fwd)
Date: Sun, 5 Sep 1999 10:03:46 -0500 (CDT)

 ---------- Forwarded message ----------
 Date: Sat, 4 Sep 1999 18:40:05 -0700 (PDT)
 From: Mike Meyer <mwm@phone.net>
 To: gnats-admin@FreeBSD.org, freebsd-bugs@FreeBSD.org
 Subject: Re: bin/13579: df is missing a Posix flag
 
 I forgot the diffs for the man page.
 
 	<mike
 
 *** df.1-orig	Sat Sep  4 13:47:52 1999
 --- df.1	Sat Sep  4 13:48:54 1999
 ***************
 *** 40,46 ****
   .Nd display free disk space
   .Sh SYNOPSIS
   .Nm df
 ! .Op Fl ikn
   .Op Fl t Ar type
   .Op Ar file | Ar filesystem ...
   .Sh DESCRIPTION
 --- 40,46 ----
   .Nd display free disk space
   .Sh SYNOPSIS
   .Nm df
 ! .Op Fl iknP
   .Op Fl t Ar type
   .Op Ar file | Ar filesystem ...
   .Sh DESCRIPTION
 ***************
 *** 75,80 ****
 --- 75,85 ----
   .Nm
   will not request new statistics from the filesystems, but will respond
   with the possibly stale statistics that were previously obtained.
 + .It Fl P
 + Use the POSIX default of 512-byte blocks rather than the default.
 + Note that this overrides the
 + .Ev BLOCKSIZE
 + specification from the environment.  
   .It Fl t
   Only print out statistics for filesystems of the specified types.
   More than one type may be specified in a comma separated list.
 
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: mwm@phone.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Mon, 06 Sep 1999 11:35:39 +0200

 On 04 Sep 1999 20:42:54 GMT, mwm@phone.net wrote:
 
 > 	The Posix df has a "P" flag that forces Posix-compliant output.
 
 Are you sure the P flag does nothing more than set the blocksize? My
 take on the specification is that the P flag should turn off iflag. I'm
 pretty sure that the P flag should _not_ override the k flag.
 
 Ciao,
 Sheldon.
 

From: Mike Meyer <mwm@phone.net>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Mon, 6 Sep 1999 14:03:43 -0700 (PDT)

 On Mon, 6 Sep 1999, Sheldon Hearn wrote:
 :->On 04 Sep 1999 20:42:54 GMT, mwm@phone.net wrote:
 :->
 :->> 	The Posix df has a "P" flag that forces Posix-compliant output.
 :->
 :->Are you sure the P flag does nothing more than set the blocksize? My
 :->take on the specification is that the P flag should turn off iflag. I'm
 :->pretty sure that the P flag should _not_ override the k flag.
 
 Oops. I didn't look carefully at flag interactions. You're right, P
 should not override k; that's explicit in the spec. Since there is no
 Posix i flag, behavior in combination with P can be whatever we
 want. Personally, I'd go with the spec saying that the output is
 unspecified if you use the t flag, and have the P flag *not* turn off
 the i flag.
 
 Do you want a separate PR for du? It needs an 'r' flag that does
 nothing.
 
 	<mike
 
 
 
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Mike Meyer <mwm@phone.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Tue, 07 Sep 1999 07:33:04 +0200

 On Mon, 06 Sep 1999 14:03:43 MST, Mike Meyer wrote:
 
 > Since there is no
 > Posix i flag, behavior in combination with P can be whatever we
 > want.
 
 I don't think so.  I think you want to be _very_ careful here.  The new
 flag should either do the expected job or shouldn't be added.  Also
 remember that the issue of adding flags to utilities "unnecessarily" is
 a flame war at the moment.  We want to be damn sure we get it right. :-)
 
 Basically, the purpose of the -P flag is to ensure that output is
 useable in a pipeline (e.g. to sed or awk). For that reason, I think
 that the -P option should turn -i off, but specifying -i after -P should
 turn it back on. So:
 
 	df -iP
 		POSIX mode on, inode mode off
 
 	df -iPi
 		POSIX mode on, inode mode on
 
 > Do you want a separate PR for du? It needs an 'r' flag that does
 > nothing.
 
 According to the Single UNIX Spec? It'd be good to know whether these
 are POSIX options as well.  POSIX seems to be more respected amongst the
 senior committers.
 
 Anyway, it deserves its own PR.
 
 Ciao,
 Sheldon.
 

From: Michael Haro <mharo@FreeBSD.ORG>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag
Date: Tue, 7 Sep 1999 07:05:34 -0700

 So something like, 
 
 switch 'P':
 	iflag = 0;
 	break;
 
 >  Basically, the purpose of the -P flag is to ensure that output is
 >  useable in a pipeline (e.g. to sed or awk). For that reason, I think
 
 Does this mean output should not go to stdout?
 
 I already have du -r in my local repoistory.  I guess I should commit
 that soon.
 
 Michael
 
 >  > Do you want a separate PR for du? It needs an 'r' flag that does
 >  > nothing.
 >  
 >  According to the Single UNIX Spec? It'd be good to know whether these
 >  are POSIX options as well.  POSIX seems to be more respected amongst the
 >  senior committers.
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: mharo@FreeBSD.ORG
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Tue, 07 Sep 1999 16:08:30 +0200

 On Tue, 07 Sep 1999 07:05:34 MST, Michael Haro wrote:
 
 > So something like, 
 > 
 > switch 'P':
 > 	iflag = 0;
 > 	break;
 
 Let's see a diff. :-)
 
 > >  Basically, the purpose of the -P flag is to ensure that output is
 > >  useable in a pipeline (e.g. to sed or awk). For that reason, I think
 > 
 > Does this mean output should not go to stdout?
 
 I don't know how you got from what I said to what you said. :-)
 
 No, it doesn't mean that output should not go to stdout. It means that
 you should be able to use the -P option to get predictable output. The
 output is always expected to go to stdout and the -P option shouldn't
 change that.
 
 > I already have du -r in my local repoistory.  I guess I should commit
 > that soon.
 
 Make sure you run it by someone.
 
 Ciao,
 Sheldon.
 

From: Mike Meyer <mwm@phone.net>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Tue, 7 Sep 1999 09:35:00 -0700 (PDT)

 On Tue, 7 Sep 1999, Sheldon Hearn wrote:
 :->On Mon, 06 Sep 1999 14:03:43 MST, Mike Meyer wrote:
 :->> Since there is no
 :->> Posix i flag, behavior in combination with P can be whatever we
 :->> want.
 :->I don't think so.  I think you want to be _very_ careful here.  The new
 :->flag should either do the expected job or shouldn't be added.  Also
 :->remember that the issue of adding flags to utilities "unnecessarily" is
 :->a flame war at the moment.  We want to be damn sure we get it right. :-)
 
 Well, the goal is to make it possible to write portable scripts that
 work everywhere. Such scripts can't use -i, so "right" is open to
 question.
 
 :->Basically, the purpose of the -P flag is to ensure that output is
 :->useable in a pipeline (e.g. to sed or awk). For that reason, I think
 :->that the -P option should turn -i off, but specifying -i after -P should
 :->turn it back on. So:
 :->	df -iP
 :->		POSIX mode on, inode mode off
 :->
 :->	df -iPi
 :->		POSIX mode on, inode mode on
 
 Well, that certainly works, but is harder to document. But you should
 specify what:
 
 	df -Pi
 
 does. (Posix on, inode on).
 
 :->> Do you want a separate PR for du? It needs an 'r' flag that does
 :->> nothing.
 :->According to the Single UNIX Spec? It'd be good to know whether these
 :->are POSIX options as well.  POSIX seems to be more respected amongst the
 :->senior committers.
 
 Sigh. I asked someone who should know where I could find a copy of the
 Unix spec online, and got pointed to the Singe Unix spec. Do you know
 where I can find what I asked for, as opposed to what I got? I'll
 gladly go check. In fact, the PR may be wrong in toto because of this.
 
 	Thanks,
 	<mike
 
 

From: Sheldon Hearn <sheldonh@uunet.co.za>
To: Mike Meyer <mwm@phone.net>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Wed, 08 Sep 1999 17:50:50 +0200

 On Tue, 07 Sep 1999 09:35:00 MST, Mike Meyer wrote:
 
 > Sigh. I asked someone who should know where I could find a copy of the
 > Unix spec online, and got pointed to the Singe Unix spec.
 
 "The Unix spec"? What's that? :-)
 
 If you mean POSIX (Portable Operating System Interface), you have to pay
 for both books.  They're available as PDF documents, but you pay for
 those as well.
 
 I should have copies in a few weeks. :-)
 
 Ciao,
 Sheldon.
 

From: Mike Meyer <mwm@phone.net>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/13579: df is missing a Posix flag 
Date: Wed, 8 Sep 1999 13:23:34 -0700 (PDT)

 On Wed, 8 Sep 1999, Sheldon Hearn wrote:
 :->On Tue, 07 Sep 1999 09:35:00 MST, Mike Meyer wrote:
 :->> Sigh. I asked someone who should know where I could find a copy of the
 :->> Unix spec online, and got pointed to the Singe Unix spec.
 :->"The Unix spec"? What's that? :-)
 
 Actually, that's "The Single Unix spec", and it can be found at <URL:
 http://www.opengroup.org/onlinepubs/7908799/toc.htm >.
 
 :->If you mean POSIX (Portable Operating System Interface), you have to pay
 :->for both books.  They're available as PDF documents, but you pay for
 :->those as well.
 
 To bad.
 	
 	<mike
 
 
State-Changed-From-To: open->closed 
State-Changed-By: mharo 
State-Changed-When: Tue Dec 14 19:41:07 PST 1999 
State-Changed-Why:  
-P flagg added to df in -current 
>Unformatted:
