]> git.sur5r.net Git - i3/i3status/blobdiff - src/print_disk_info.c
debian: add libcap2-bin as dependency (for setcap(8))
[i3/i3status] / src / print_disk_info.c
index 7ad27a477c5d3f791c1fd1c5e272e5c01c30ac25..b9ec84b3f6c00f0d24b587c0534f679d534fcd37 100644 (file)
@@ -20,7 +20,7 @@
  */
 static void print_bytes_human(uint64_t bytes) {
         if (bytes > TERABYTE)
-                printf("%f TB", (double)bytes / TERABYTE);
+                printf("%.02f TB", (double)bytes / TERABYTE);
         else if (bytes > GIGABYTE)
                 printf("%.01f GB", (double)bytes / GIGABYTE);
         else if (bytes > MEGABYTE)
@@ -51,18 +51,23 @@ void print_disk_info(const char *path, const char *format) {
                 }
 
                 if (BEGINS_WITH(walk+1, "free")) {
-                        print_bytes_human(buf.f_bsize * buf.f_bfree);
+                        print_bytes_human((uint64_t)buf.f_bsize * (uint64_t)buf.f_bfree);
                         walk += strlen("free");
                 }
 
                 if (BEGINS_WITH(walk+1, "used")) {
-                        print_bytes_human(buf.f_bsize * (buf.f_blocks - buf.f_bfree));
+                        print_bytes_human((uint64_t)buf.f_bsize * ((uint64_t)buf.f_blocks - (uint64_t)buf.f_bfree));
                         walk += strlen("used");
                 }
 
                 if (BEGINS_WITH(walk+1, "total")) {
-                        print_bytes_human(buf.f_bsize * buf.f_blocks);
+                        print_bytes_human((uint64_t)buf.f_bsize * (uint64_t)buf.f_blocks);
                         walk += strlen("total");
                 }
+
+                if (BEGINS_WITH(walk+1, "avail")) {
+                        print_bytes_human((uint64_t)buf.f_bsize * (uint64_t)buf.f_bavail);
+                        walk += strlen("avail");
+                }
         }
 }