diff options
author | landley <landley@driftwood> | 2006-10-30 11:18:30 -0500 |
---|---|---|
committer | landley <landley@driftwood> | 2006-10-30 11:18:30 -0500 |
commit | 52fb04274b3491fdfe91b2e5acc23dc3f3064a86 (patch) | |
tree | c8e7313aaea122d3de5fd8148874d8d1bee7144a /toys/df.c | |
parent | 64b2e23ff1f2c2b8eacf6da5ac9a58054c8245cf (diff) | |
download | toybox-52fb04274b3491fdfe91b2e5acc23dc3f3064a86.tar.gz |
Closer support for "pedantic" option for SUSv3. (Ok, it's %ld instead of the0.0.1
%d the spec says, but same output. And you can't actually select it until I
get menuconfig in. But hey...)
Diffstat (limited to 'toys/df.c')
-rw-r--r-- | toys/df.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -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 @@ static void show_mt(struct mtab_list *mt) 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) |