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.
Responsible Changed From-To: freebsd-bugs->mharo mharo was working on this type of thing
---------- 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.
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.
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
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.
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.
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.
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
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.
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 -P flagg added to df in -current