X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/80fc20d1d69b14f36ad9bb64d8af38481cbf1ff5..b0401b13bb78bacde9d10b00766830cbeb2c90f6:/components/disk.c?ds=sidebyside diff --git a/components/disk.c b/components/disk.c index f4031ea..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,8 +14,7 @@ disk_free(const char *mnt) return NULL; } - return bprintf("%f", - (float)fs.f_frsize * (float)fs.f_bavail / 1024 / 1024 / 1024); + return fmt_human(fs.f_frsize * fs.f_bavail, 1024); } const char * @@ -44,8 +41,7 @@ disk_total(const char *mnt) return NULL; } - return bprintf("%f", - (float)fs.f_frsize * (float)fs.f_blocks / 1024 / 1024 / 1024); + return fmt_human(fs.f_frsize * fs.f_blocks, 1024); } const char * @@ -58,7 +54,5 @@ disk_used(const char *mnt) return NULL; } - return bprintf("%f", - (float)fs.f_frsize * ((float)fs.f_blocks - - (float)fs.f_bfree) / 1024 / 1024 / 1024); + return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024); }