From: Christian Kohlstedde Date: Wed, 18 Feb 2015 15:53:24 +0000 (+0100) Subject: Modify print_disk_info. Now there is no output if the path is no mountpoint. X-Git-Tag: 2.9~5^2~4 X-Git-Url: https://git.sur5r.net/?p=i3%2Fi3status;a=commitdiff_plain;h=e70ea4247fd9eefcdd3f80fdc8a045257d196fcb Modify print_disk_info. Now there is no output if the path is no mountpoint. --- diff --git a/src/print_disk_info.c b/src/print_disk_info.c index 1671210..a9fcba3 100644 --- a/src/print_disk_info.c +++ b/src/print_disk_info.c @@ -3,7 +3,9 @@ #include #include #include +#include #include +#include #include #include #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;