summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen2001-03-09 22:42:26 +0000
committerEric Andersen2001-03-09 22:42:26 +0000
commitd92168486bd9008b2ecd33a6b3b569b54cbe1da0 (patch)
tree5dd252e744eb6d404101299347e5db947fea3f3a
parent4aaf89f49f729d196c6f056e625efcdb5bde737d (diff)
downloadbusybox-d92168486bd9008b2ecd33a6b3b569b54cbe1da0.zip
busybox-d92168486bd9008b2ecd33a6b3b569b54cbe1da0.tar.gz
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
-rw-r--r--coreutils/df.c16
-rw-r--r--df.c16
2 files changed, 20 insertions, 12 deletions
diff --git a/coreutils/df.c b/coreutils/df.c
index 776fceb..21a1dbb 100644
--- a/coreutils/df.c
+++ b/coreutils/df.c
@@ -74,18 +74,22 @@ static int do_df(char *device, const char *mount_point)
base = 0;
}
printf("%-20s %9s ", device,
- make_human_readable_str(s.f_blocks * (s.f_bsize/KILOBYTE), base));
+ make_human_readable_str((unsigned long)(s.f_blocks *
+ (s.f_bsize/(double)KILOBYTE)), base));
printf("%9s ",
- make_human_readable_str((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base));
+ make_human_readable_str((unsigned long)(
+ (s.f_blocks - s.f_bfree) *
+ (s.f_bsize/(double)KILOBYTE)), base));
printf("%9s %3ld%% %s\n",
- make_human_readable_str(s.f_bavail * (s.f_bsize/KILOBYTE), base),
+ make_human_readable_str((unsigned long)(s.f_bavail *
+ (s.f_bsize/(double)KILOBYTE)), base),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
- (long) (s.f_blocks * (s.f_bsize / KILOBYTE)),
- (long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)),
- (long) (s.f_bavail * (s.f_bsize / KILOBYTE)),
+ (long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
+ (long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
+ (long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
blocks_percent_used, mount_point);
#endif
}
diff --git a/df.c b/df.c
index 776fceb..21a1dbb 100644
--- a/df.c
+++ b/df.c
@@ -74,18 +74,22 @@ static int do_df(char *device, const char *mount_point)
base = 0;
}
printf("%-20s %9s ", device,
- make_human_readable_str(s.f_blocks * (s.f_bsize/KILOBYTE), base));
+ make_human_readable_str((unsigned long)(s.f_blocks *
+ (s.f_bsize/(double)KILOBYTE)), base));
printf("%9s ",
- make_human_readable_str((s.f_blocks - s.f_bfree) * (s.f_bsize/KILOBYTE), base));
+ make_human_readable_str((unsigned long)(
+ (s.f_blocks - s.f_bfree) *
+ (s.f_bsize/(double)KILOBYTE)), base));
printf("%9s %3ld%% %s\n",
- make_human_readable_str(s.f_bavail * (s.f_bsize/KILOBYTE), base),
+ make_human_readable_str((unsigned long)(s.f_bavail *
+ (s.f_bsize/(double)KILOBYTE)), base),
blocks_percent_used, mount_point);
#else
printf("%-20s %9ld %9ld %9ld %3ld%% %s\n",
device,
- (long) (s.f_blocks * (s.f_bsize / KILOBYTE)),
- (long) ((s.f_blocks - s.f_bfree) * (s.f_bsize / KILOBYTE)),
- (long) (s.f_bavail * (s.f_bsize / KILOBYTE)),
+ (long) (s.f_blocks * (s.f_bsize / (double)KILOBYTE)),
+ (long) ((s.f_blocks - s.f_bfree)*(s.f_bsize/(double)KILOBYTE)),
+ (long) (s.f_bavail * (s.f_bsize / (double)KILOBYTE)),
blocks_percent_used, mount_point);
#endif
}