X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/b3e56066ed5349c6fd0afe1ac7cf5035e16a8a2f..51ff7ce2b99147a1a77ed243093865fc884e571a:/components/disk.c

diff --git a/components/disk.c b/components/disk.c
index 00deea2..15a221b 100644
--- a/components/disk.c
+++ b/components/disk.c
@@ -1,31 +1,29 @@
 /* See LICENSE file for copyright and license details. */
-#include <errno.h>
 #include <stdio.h>
-#include <string.h>
 #include <sys/statvfs.h>
 
 #include "../util.h"
 
 const char *
-disk_free(const char *mnt)
+disk_free(const char *path)
 {
 	struct statvfs fs;
 
-	if (statvfs(mnt, &fs) < 0) {
-		warn("statvfs '%s':", mnt);
+	if (statvfs(path, &fs) < 0) {
+		warn("statvfs '%s':", path);
 		return NULL;
 	}
 
-	return fmt_scaled(fs.f_frsize * fs.f_bavail);
+	return fmt_human(fs.f_frsize * fs.f_bavail, 1024);
 }
 
 const char *
-disk_perc(const char *mnt)
+disk_perc(const char *path)
 {
 	struct statvfs fs;
 
-	if (statvfs(mnt, &fs) < 0) {
-		warn("statvfs '%s':", mnt);
+	if (statvfs(path, &fs) < 0) {
+		warn("statvfs '%s':", path);
 		return NULL;
 	}
 
@@ -34,27 +32,27 @@ disk_perc(const char *mnt)
 }
 
 const char *
-disk_total(const char *mnt)
+disk_total(const char *path)
 {
 	struct statvfs fs;
 
-	if (statvfs(mnt, &fs) < 0) {
-		warn("statvfs '%s':", mnt);
+	if (statvfs(path, &fs) < 0) {
+		warn("statvfs '%s':", path);
 		return NULL;
 	}
 
-	return fmt_scaled(fs.f_frsize * fs.f_blocks);
+	return fmt_human(fs.f_frsize * fs.f_blocks, 1024);
 }
 
 const char *
-disk_used(const char *mnt)
+disk_used(const char *path)
 {
 	struct statvfs fs;
 
-	if (statvfs(mnt, &fs) < 0) {
-		warn("statvfs '%s':", mnt);
+	if (statvfs(path, &fs) < 0) {
+		warn("statvfs '%s':", path);
 		return NULL;
 	}
 
-	return fmt_scaled(fs.f_frsize * (fs.f_blocks - fs.f_bfree));
+	return fmt_human(fs.f_frsize * (fs.f_blocks - fs.f_bfree), 1024);
 }