Subject: standards/11208: POSIX.2: df -P isn't implemented
To: None <gnats-bugs@gnats.netbsd.org>
From: Ben Harris <bjh21@netbsd.org>
List: netbsd-bugs
Date: 10/12/2000 16:21:10
>Number: 11208
>Category: standards
>Synopsis: POSIX.2: df -P isn't implemented
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: standards-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 12 16:21:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Ben Harris
>Release: 2000-02-07
>Organization:
>Environment:
NetBSD cromarty 1.4X NetBSD 1.4X (CROMARTY) #9: Wed May 3 23:49:51 BST 2000
bjh21@cromarty:/usr/src/sys/arch/macppc/compile/CROMARTY macppc
>Description:
As mentioned in PR#2893, POSIX.2 specifies that df must accept a
"-P" argument to produce "portable" output. This output is almost
identical to NetBSD's current output except for the precise wording of the
header line. NetBSD's current "df" doesn't accept -P.
>How-To-Repeat:
cromarty:~$ df -P
df: illegal option -- P
usage: df [-ikln] [-t type] [file | file_system ...]
>Fix:
This is a first approximation to a fix:
Index: df.c
===================================================================
RCS file: /cvsroot/basesrc/bin/df/df.c,v
retrieving revision 1.34
diff -u -r1.34 df.c
--- df.c 2000/06/26 21:16:16 1.34
+++ df.c 2000/10/12 23:15:46
@@ -79,7 +79,7 @@
long regetmntinfo __P((struct statfs **, long));
void usage __P((void));
-int aflag, iflag, kflag, lflag, nflag;
+int aflag, iflag, kflag, lflag, nflag, Pflag;
char **typelist = NULL;
struct ufs_args mdev;
@@ -94,7 +94,7 @@
int ch, i, maxwidth, width;
char *mntpt;
- while ((ch = getopt(argc, argv, "aiklnt:")) != -1)
+ while ((ch = getopt(argc, argv, "aiklnPt:")) != -1)
switch (ch) {
case 'a':
aflag = 1;
@@ -111,6 +111,9 @@
case 'n':
nflag = 1;
break;
+ case 'P':
+ Pflag = 1;
+ break;
case 't':
if (typelist != NULL)
errx(1, "only one -t option may be
specified.");
@@ -345,12 +348,13 @@
if (++timesthrough == 1) {
if (kflag) {
blocksize = 1024;
- header = "1K-blocks";
+ header = Pflag ? "1024-blocks" : "1K-blocks";
headerlen = strlen(header);
} else
header = getbsize(&headerlen, &blocksize);
- (void)printf("%-*.*s %s Used Avail Capacity",
- maxwidth, maxwidth, "Filesystem", header);
+ (void)printf("%-*.*s %s Used %8s Capacity",
+ maxwidth, maxwidth, "Filesystem", header,
+ Pflag ? "Available" : "Avail");
if (iflag)
(void)printf(" iused ifree %%iused");
(void)printf(" Mounted on\n");
@@ -459,7 +463,7 @@
extern char *__progname;
(void)fprintf(stderr,
- "Usage: %s [-aikln] [-t type] [file | file_system ...]\n",
+ "Usage: %s [-aiklnP] [-t type] [file | file_system ...]\n",
__progname);
exit(1);
/* NOTREACHED */
--
Ben Harris <bjh21@netbsd.org>
Portmaster, NetBSD/arm26 <URL:http://www.netbsd.org/Ports/arm26/>
>Release-Note:
>Audit-Trail:
>Unformatted: