aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgereon2012-08-30 19:32:33 +0200
committerMichael Stapelberg2012-08-31 14:07:46 +0200
commit50ad0334f648d74c0093bf95270e5f60859888ae (patch)
treefa55338b0dda9a006fd9d703dbcb6a29cb736436 /src
parentEat unnecessary space from the battery format str. (diff)
adding percentage format string for disk info module
explicit cast to double, changed format string to percentage
Diffstat (limited to 'src')
-rw-r--r--src/print_disk_info.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/print_disk_info.c b/src/print_disk_info.c
index 8bc8b41..a3124a1 100644
--- a/src/print_disk_info.c
+++ b/src/print_disk_info.c
@@ -86,6 +86,11 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
outwalk += print_bytes_human(outwalk, (uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail);
walk += strlen("avail");
}
+
+ if (BEGINS_WITH(walk+1, "percentage")) {
+ outwalk += sprintf(outwalk, "%.01f%%", 100.0 - 100.0 * (double)buf.f_bavail / (double)buf.f_blocks);
+ walk += strlen("percentage");
+ }
}
*outwalk = '\0';