mirror of
https://github.com/sheumann/hush.git
synced 2024-12-21 23:29:34 +00:00
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
This commit is contained in:
parent
4aaf89f49f
commit
d92168486b
@ -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
|
||||
}
|
||||
|
16
df.c
16
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user