X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/6123f482e39d9488df03898a0aadca3bdaf8673f..8c8326f793549dcc685f0e4ec3e29f1f3790d6d8:/components/disk.c diff --git a/components/disk.c b/components/disk.c index 8112981..f4031ea 100644 --- a/components/disk.c +++ b/components/disk.c @@ -12,12 +12,12 @@ disk_free(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); + warn("statvfs '%s':", mnt); return NULL; } return bprintf("%f", - (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024); + (float)fs.f_frsize * (float)fs.f_bavail / 1024 / 1024 / 1024); } const char * @@ -26,12 +26,12 @@ disk_perc(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); + warn("statvfs '%s':", mnt); return NULL; } return bprintf("%d", (int)(100 * - (1.0f - ((float)fs.f_bfree / (float)fs.f_blocks)))); + (1.0f - ((float)fs.f_bavail / (float)fs.f_blocks)))); } const char * @@ -40,12 +40,12 @@ disk_total(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); + warn("statvfs '%s':", mnt); return NULL; } return bprintf("%f", - (float)fs.f_bsize * (float)fs.f_blocks / 1024 / 1024 / 1024); + (float)fs.f_frsize * (float)fs.f_blocks / 1024 / 1024 / 1024); } const char * @@ -54,11 +54,11 @@ disk_used(const char *mnt) struct statvfs fs; if (statvfs(mnt, &fs) < 0) { - fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno)); + warn("statvfs '%s':", mnt); return NULL; } return bprintf("%f", - (float)fs.f_bsize * ((float)fs.f_blocks - + (float)fs.f_frsize * ((float)fs.f_blocks - (float)fs.f_bfree) / 1024 / 1024 / 1024); }