aboutsummaryrefslogtreecommitdiff
path: root/bin/df
diff options
context:
space:
mode:
authorChristian S.J. Peron <csjp@FreeBSD.org>2006-09-20 20:55:02 +0000
committerChristian S.J. Peron <csjp@FreeBSD.org>2006-09-20 20:55:02 +0000
commitdf464e4361fa956f84dd50251ce62e1deb3f9316 (patch)
tree9e4b9104d09feca3593bbdbdc9c1ebc5d7c0eb77 /bin/df
parentdec10b39fda88fc94d358b8415e7ab8a77538786 (diff)
downloadsrc-df464e4361fa956f84dd50251ce62e1deb3f9316.tar.gz
src-df464e4361fa956f84dd50251ce62e1deb3f9316.zip
Based on The Open Group Base Specifications Issue 6 IEEE Std 1003.1, our
current implementation of df(1) is does not properly format the output under certain conditions. Right now -kP and -Pk are not the same thing. Further, when we set the BLOCKSIZE environment variable, we use "1k" instead of "1024", making the header display incorrectly. To quote the specification: "When both the -k and -P options are specified, the following header line shall be written (in the POSIX locale): "Filesystem 1024-blocks Used Available Capacity Mounted on\n" - If -P has been specified, check to make sure that -k has not already been specified, if so, simply break instead of clobbering the previous blocksize - Use 1024 instead of 1k to make the header POSIX compliant Reported by: Andriy Gapon Discussed with: bde, ru MFC after: 1 week
Notes
Notes: svn path=/head/; revision=162483
Diffstat (limited to 'bin/df')
-rw-r--r--bin/df/df.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/df/df.c b/bin/df/df.c
index 850c02f6826d..e33b3e4430bd 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -93,7 +93,7 @@ imax(int a, int b)
return (a > b ? a : b);
}
-static int aflag = 0, cflag, hflag, iflag, nflag;
+static int aflag = 0, cflag, hflag, iflag, kflag, nflag;
static struct ufs_args mdev;
int
@@ -123,6 +123,14 @@ main(int argc, char *argv[])
case 'b':
/* FALLTHROUGH */
case 'P':
+ /*
+ * POSIX specifically discusses the the behavior of
+ * both -k and -P. It states that the blocksize should
+ * be set to 1024. Thus, if this occurs, simply break
+ * rather than clobbering the old blocksize.
+ */
+ if (kflag)
+ break;
putenv("BLOCKSIZE=512");
hflag = 0;
break;
@@ -143,7 +151,8 @@ main(int argc, char *argv[])
iflag = 1;
break;
case 'k':
- putenv("BLOCKSIZE=1k");
+ kflag++;
+ putenv("BLOCKSIZE=1024");
hflag = 0;
break;
case 'l':