Mercurial > hg > toybox
changeset 9:8f8a8ac59c14 0.0.1
Closer support for "pedantic" option for SUSv3. (Ok, it's %ld instead of the
%d the spec says, but same output. And you can't actually select it until I
get menuconfig in. But hey...)
author | landley@driftwood |
---|---|
date | Mon, 30 Oct 2006 11:18:30 -0500 |
parents | 04f66da2bdbf |
children | 478a2faf9119 |
files | toys/df.c |
diffstat | 1 files changed, 9 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/df.c Mon Oct 30 10:01:19 2006 -0500 +++ b/toys/df.c Mon Oct 30 11:18:30 2006 -0500 @@ -13,7 +13,7 @@ static void show_mt(struct mtab_list *mt) { int len; - long size, used, avail; + long size, used, avail, percent; uint64_t block; // Return if it wasn't found (should never happen, but with /etc/mtab...) @@ -41,12 +41,18 @@ avail = (long)((block * (getuid() ? mt->statvfs.f_bavail : mt->statvfs.f_bfree)) / toy.df.units); + percent = 100-(long)((100*(uint64_t)avail)/size); // Figure out appropriate spacing len = 25 - strlen(mt->device); if (len < 1) len = 1; - printf("%s% *ld % 10ld % 9ld % 3ld%% %s\n",mt->device, len, - size, used, avail, 100-(long)((100*(uint64_t)avail)/size), mt->dir); + if (CFG_DF_PEDANTIC && (toys.optflags & 8)) { + printf("%s %ld %ld %ld %ld%% %s\n", mt->device, size, used, avail, + percent, mt->dir); + } else { + printf("%s% *ld % 10ld % 9ld % 3ld%% %s\n",mt->device, len, + size, used, avail, percent, mt->dir); + } } int df_main(void)