Bug 13579 - df is missing a Posix flag
Summary: df is missing a Posix flag
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 3.2-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: Michael Haro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-09-04 21:50 UTC by mwm
Modified: 1999-12-15 03:44 UTC (History)
0 users

See Also:


Attachments
file.diff (689 bytes, patch)
1999-09-04 21:50 UTC, mwm
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mwm 1999-09-04 21:50:00 UTC
	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.

Fix: Here's the patch to df.c
How-To-Repeat: 
	Run the command "df -P", and notice that you get an error message.
Comment 1 cpiazza freebsd_committer freebsd_triage 1999-09-04 21:58:09 UTC
Responsible Changed
From-To: freebsd-bugs->mharo

mharo was working on this type of thing 

Comment 2 sprice 1999-09-05 16:03:46 UTC
---------- 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.
Comment 3 Sheldon Hearn 1999-09-06 10:35:39 UTC
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.
Comment 4 mwm 1999-09-06 22:03:43 UTC
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
Comment 5 Sheldon Hearn 1999-09-07 06:33:04 UTC
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.
Comment 6 Michael Haro freebsd_committer freebsd_triage 1999-09-07 15:05:34 UTC
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.
Comment 7 Sheldon Hearn 1999-09-07 15:08:30 UTC
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.
Comment 8 mwm 1999-09-07 17:35:00 UTC
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
Comment 9 Sheldon Hearn 1999-09-08 16:50:50 UTC
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.
Comment 10 mwm 1999-09-08 21:23:34 UTC
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
Comment 11 Michael Haro freebsd_committer freebsd_triage 1999-12-15 03:41:07 UTC
State Changed
From-To: open->closed

-P flagg added to df in -current