summaryrefslogtreecommitdiff
path: root/bin/df
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-12-31 05:00:05 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-12-31 05:00:05 +0000
commit4046505f6f1cca29648a21c9d2d8f41c13113913 (patch)
treed12819a244a5dc033872551562cdb5ebc08f4611 /bin/df
parent7cf2027e71b89435f73f7208880e42af3968c01b (diff)
In prtstat() use u_int32_t and int32_t, not long and cast
sfsp->f_bsize to be signed when using the fsbtoblk() macro so we get signed divide, not unsigned divide. Fixes a bug in df when the filesystem has < 0 blocks available to the user. Guess I should have just made f_bsize signed when struct statfs was changed.
Diffstat (limited to 'bin/df')
-rw-r--r--bin/df/df.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/bin/df/df.c b/bin/df/df.c
index bbc150251bc..4f6e39dc99d 100644
--- a/bin/df/df.c
+++ b/bin/df/df.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: df.c,v 1.24 1999/05/31 17:34:39 millert Exp $ */
+/* $OpenBSD: df.c,v 1.25 1999/12/31 05:00:04 millert Exp $ */
/* $NetBSD: df.c,v 1.21.2.1 1995/11/01 00:06:11 jtc Exp $ */
/*
@@ -49,7 +49,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: df.c,v 1.24 1999/05/31 17:34:39 millert Exp $";
+static char rcsid[] = "$OpenBSD: df.c,v 1.25 1999/12/31 05:00:04 millert Exp $";
#endif
#endif /* not lint */
@@ -370,7 +370,8 @@ prtstat(sfsp, maxwidth, headerlen, blocksize)
int maxwidth, headerlen;
long blocksize;
{
- long used, availblks, inodes;
+ u_int32_t used, inodes;
+ int32_t availblks;
(void)printf("%-*.*s", maxwidth, maxwidth, sfsp->f_mntfromname);
used = sfsp->f_blocks - sfsp->f_bfree;
@@ -378,10 +379,10 @@ prtstat(sfsp, maxwidth, headerlen, blocksize)
if (hflag)
prthuman(sfsp, used);
else
- (void)printf(" %*ld %8ld %8ld", headerlen,
+ (void)printf(" %*u %8u %8d", headerlen,
fsbtoblk(sfsp->f_blocks, sfsp->f_bsize, blocksize),
fsbtoblk(used, sfsp->f_bsize, blocksize),
- fsbtoblk(sfsp->f_bavail, sfsp->f_bsize, blocksize));
+ fsbtoblk(sfsp->f_bavail, (int)sfsp->f_bsize, blocksize));
(void)printf(" %5.0f%%",
availblks == 0 ? 100.0 : (double)used / (double)availblks * 100.0);
if (iflag) {