diff options
author | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-09 22:42:26 +0000 |
---|---|---|
committer | andersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-03-09 22:42:26 +0000 |
commit | aa3297f363d73414dcdd0f16e55b02774b9440ff (patch) | |
tree | 5dd252e744eb6d404101299347e5db947fea3f3a /df.c | |
parent | 649f970ce6fe741800a34112f26989d8a3e8a0a9 (diff) | |
download | busybox-w32-aa3297f363d73414dcdd0f16e55b02774b9440ff.tar.gz busybox-w32-aa3297f363d73414dcdd0f16e55b02774b9440ff.tar.bz2 busybox-w32-aa3297f363d73414dcdd0f16e55b02774b9440ff.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
git-svn-id: svn://busybox.net/trunk/busybox@2032 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'df.c')
-rw-r--r-- | df.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -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 | } |