]> git.sur5r.net Git - i3/i3status/commitdiff
Modify print_disk_info. Now there is no output if the path is no mountpoint.
authorChristian Kohlstedde <christian@kohlsted.de>
Wed, 18 Feb 2015 15:53:24 +0000 (16:53 +0100)
committerChristian Kohlstedde <christian@kohlsted.de>
Wed, 18 Feb 2015 15:53:24 +0000 (16:53 +0100)
src/print_disk_info.c

index 167121045cebcced788d7b8d810bccffdc53bf14..a9fcba379aad0e9770551bc9653b4bbf6deb09cd 100644 (file)
@@ -3,7 +3,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
+#include <mntent.h>
 #include <stdint.h>
+#include <sys/stat.h>
 #include <sys/statvfs.h>
 #include <sys/types.h>
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (__OpenBSD__) || defined(__DragonFly__)
@@ -125,6 +127,24 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
                 return;
 #endif
 
+        FILE *mntentfile = setmntent("/etc/mtab", "r");
+        struct mntent *m;
+        bool found = false;
+
+        while ((m = getmntent(mntentfile))) {
+                if (strcmp(m->mnt_dir, path) == 0) {
+                        found = true;
+                        break;
+                }
+        }
+        endmntent(mntentfile);
+
+        if(!found) {
+                *outwalk = '\0';
+                OUTPUT_FULL_TEXT(buffer);
+                return;
+        }
+
         if (low_threshold > 0 && below_threshold(buf, prefix_type, threshold_type, low_threshold)) {
                 START_COLOR("color_bad");
                 colorful_output = true;