X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/46c4540dd2f6181e77b0800a4e007d78d0162487..32e0a2bfcc7def9128fb7f385b603f2c5fe34e4d:/components/disk.c?ds=sidebyside diff --git a/components/disk.c b/components/disk.c index 998ad47..9d2284e 100644 --- a/components/disk.c +++ b/components/disk.c @@ -1,7 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#include #include -#include #include #include "../util.h" @@ -16,7 +14,7 @@ disk_free(const char *mnt) return NULL; } - return fmt_human_2(fs.f_frsize * fs.f_bavail, "B"); + return fmt_human(fs.f_frsize * fs.f_bavail, 1024); } const char * @@ -29,7 +27,7 @@ disk_perc(const char *mnt) return NULL; } - return bprintf("%d%%", (int)(100 * + return bprintf("%d", (int)(100 * (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks)))); } @@ -43,7 +41,7 @@ disk_total(const char *mnt) return NULL; } - return fmt_human_2(fs.f_frsize * fs.f_blocks, "B"); + return fmt_human(fs.f_frsize * fs.f_blocks, 1024); } const char * @@ -56,5 +54,5 @@ disk_used(const char *mnt) return NULL; } - return fmt_human_2(fs.f_frsize * (fs.f_blocks - fs.f_bfree), "B"); + return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024); }