X-Git-Url: https://git.xinqibao.xyz/slstatus.git/blobdiff_plain/96f3a8a54eeb3b2294ed953dad8b15349f3e2703..fbbe300f4d52ab014fb09050deea7746b1d02a82:/components/disk.c?ds=inline

diff --git a/components/disk.c b/components/disk.c
index 3d8140e..2ce260b 100644
--- a/components/disk.c
+++ b/components/disk.c
@@ -1,5 +1,7 @@
 /* See LICENSE file for copyright and license details. */
+#include <errno.h>
 #include <stdio.h>
+#include <string.h>
 #include <sys/statvfs.h>
 
 #include "../util.h"
@@ -10,11 +12,12 @@ disk_free(const char *mnt)
 	struct statvfs fs;
 
 	if (statvfs(mnt, &fs) < 0) {
-		fprintf(stderr, "Failed to get filesystem info");
+		fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno));
 		return NULL;
 	}
 
-	return bprintf("%f", (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
+	return bprintf("%f",
+	               (float)fs.f_bsize * (float)fs.f_bfree / 1024 / 1024 / 1024);
 }
 
 const char *
@@ -24,7 +27,7 @@ disk_perc(const char *mnt)
 	struct statvfs fs;
 
 	if (statvfs(mnt, &fs) < 0) {
-		fprintf(stderr, "Failed to get filesystem info");
+		fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno));
 		return NULL;
 	}
 
@@ -39,11 +42,12 @@ disk_total(const char *mnt)
 	struct statvfs fs;
 
 	if (statvfs(mnt, &fs) < 0) {
-		fprintf(stderr, "Failed to get filesystem info");
+		fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno));
 		return NULL;
 	}
 
-	return bprintf("%f", (float)fs.f_bsize * (float)fs.f_blocks / 1024 / 1024 / 1024);
+	return bprintf("%f",
+	               (float)fs.f_bsize * (float)fs.f_blocks / 1024 / 1024 / 1024);
 }
 
 const char *
@@ -52,9 +56,11 @@ disk_used(const char *mnt)
 	struct statvfs fs;
 
 	if (statvfs(mnt, &fs) < 0) {
-		fprintf(stderr, "Failed to get filesystem info");
+		fprintf(stderr, "statvfs '%s': %s\n", mnt, strerror(errno));
 		return NULL;
 	}
 
-	return bprintf("%f", (float)fs.f_bsize * ((float)fs.f_blocks - (float)fs.f_bfree) / 1024 / 1024 / 1024);
+	return bprintf("%f",
+	               (float)fs.f_bsize * ((float)fs.f_blocks -
+	               (float)fs.f_bfree) / 1024 / 1024 / 1024);
 }