summaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-09 22:42:26 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-09 22:42:26 +0000
commitd92168486bd9008b2ecd33a6b3b569b54cbe1da0 (patch)
tree5dd252e744eb6d404101299347e5db947fea3f3a /coreutils
parent4aaf89f49f729d196c6f056e625efcdb5bde737d (diff)
downloadbusybox-w32-d92168486bd9008b2ecd33a6b3b569b54cbe1da0.tar.gz
busybox-w32-d92168486bd9008b2ecd33a6b3b569b54cbe1da0.tar.bz2
busybox-w32-d92168486bd9008b2ecd33a6b3b569b54cbe1da0.zip
Fixed df.c so that nfs volumes will display properly (fixing bug #1113).
Problem was 512/1024 = 0 if you use longs, so I cast KILOBYTE to a double, then cast the result back to an int after the math is done, letting C's type promotion do its magic for the rest. -Erik
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/df.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index 776fceb28..21a1dbb31 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -74,18 +74,22 @@ static int do_df(char *device, const char *mount_point)
74 base = 0; 74 base = 0;
75 } 75 }
76 printf("%-20s %9s ", device, 76 printf("%-20s %9s ", device,
77 make_human_readable_str(s.f_blocks * (s.f_bsize/KILOBYTE), base)); 77 make_human_readable_str((unsigned long)(s.f_blocks *
78 (s.f_bsize/(double)KILOBYTE)), base));
78 printf("%9s ", 79 printf("%9s ",
79 make_human_readable_str((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base)); 80 make_human_readable_str((unsigned long)(
81 (s.f_blocks - s.f_bfree) *
82 (s.f_bsize/(double)KILOBYTE)), base));
80 printf("%9s %3ld%% %s\n", 83 printf("%9s %3ld%% %s\n",
81 make_human_readable_str(s.f_bavail * (s.f_bsize/KILOBYTE), base), 84 make_human_readable_str((unsigned long)(s.f_bavail *
85 (s.f_bsize/(double)KILOBYTE)), base),
82 blocks_percent_used, mount_point); 86 blocks_percent_used, mount_point);
83#else 87#else
84 printf("%-20s %9ld %9ld %9ld %3ld%% %s\n", 88 printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
85 device, 89 device,
86 (long) (s.f_blocks * (s.f_bsize / KILOBYTE)), 90 (long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
87 (long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)), 91 (long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
88 (long) (s.f_bavail * (s.f_bsize / KILOBYTE)), 92 (long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
89 blocks_percent_used, mount_point); 93 blocks_percent_used, mount_point);
90#endif 94#endif
91 } 95 }