aboutsummaryrefslogtreecommitdiff
path: root/toys/df.c
diff options
context:
space:
mode:
authorlandley <landley@driftwood>2006-10-30 11:18:30 -0500
committerlandley <landley@driftwood>2006-10-30 11:18:30 -0500
commit52fb04274b3491fdfe91b2e5acc23dc3f3064a86 (patch)
treec8e7313aaea122d3de5fd8148874d8d1bee7144a /toys/df.c
parent64b2e23ff1f2c2b8eacf6da5ac9a58054c8245cf (diff)
downloadtoybox-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.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/toys/df.c b/toys/df.c
index efe57b65..cbebd157 100644
--- a/toys/df.c
+++ b/toys/df.c
@@ -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)