summaryrefslogtreecommitdiffstats
path: root/bin/df
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-08-12 07:26:52 +0000
committerdg <dg@FreeBSD.org>1994-08-12 07:26:52 +0000
commit679aa902928d20d002ff66fbba075b6fcae551c4 (patch)
treef15270f28e3087224497ec72aa3fc2152d2e35c2 /bin/df
parentcc490038a0f6ece1aa559fbd7f0f2ff39eecbf5a (diff)
downloadFreeBSD-src-679aa902928d20d002ff66fbba075b6fcae551c4.zip
FreeBSD-src-679aa902928d20d002ff66fbba075b6fcae551c4.tar.gz
Implemented the -k flag more properly...don't destroy the user's setting
of the BLOCKSIZE environment variable.
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 02e6ca9..24a5d26 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -107,7 +107,7 @@ void prtstat __P((struct statfs *, int));
void ufs_df __P((char *, int));
void usage __P((void));
-int iflag, nflag, tflag;
+int iflag, nflag, tflag, kflag;
struct ufs_args mdev;
int
@@ -121,13 +121,15 @@ main(argc, argv)
int ch, err, i, maxwidth, width;
char *mntpt;
+ iflag = nflag = tflag = kflag = 0;
+
while ((ch = getopt(argc, argv, "iknt:")) != EOF)
switch (ch) {
case 'i':
iflag = 1;
break;
case 'k':
- putenv("BLOCKSIZE=1024");
+ kflag = 1;
break;
case 'n':
nflag = 1;
@@ -305,11 +307,18 @@ prtstat(sfsp, maxwidth)
static int headerlen, timesthrough;
static char *header;
long used, availblks, inodes;
+ char *oldbsize = NULL;
if (maxwidth < 11)
maxwidth = 11;
if (++timesthrough == 1) {
+ if (kflag) {
+ oldbsize = getenv("BLOCKSIZE");
+ putenv("BLOCKSIZE=1k");
+ }
header = getbsize(&headerlen, &blocksize);
+ if (oldbsize)
+ putenv(oldbsize);
(void)printf("%-*.*s %s Used Avail Capacity",
maxwidth, maxwidth, "Filesystem", header);
if (iflag)
OpenPOWER on IntegriCloud