summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Kohlstedde <christian@kohlsted.de>2015-02-18 23:43:25 +0100
committerChristian Kohlstedde <christian@kohlsted.de>2015-02-18 23:43:25 +0100
commit85bb373095d296a90a7a1e8741229dc4dcb9acc8 (patch)
tree41cde895aaab8e66533e4394abe2edfae45e18d1 /src
parentf7b25a15dd913dc7a40e3db957d216792c2fb694 (diff)
Adding optional configuration option to "print_disk_info".
Diffstat (limited to 'src')
-rw-r--r--src/print_disk_info.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/print_disk_info.c b/src/print_disk_info.c
index 609f6d3..4ed2f22 100644
--- a/src/print_disk_info.c
+++ b/src/print_disk_info.c
@@ -108,7 +108,7 @@ static bool below_threshold(struct statvfs buf, const char *prefix_type, const c
* human readable manner.
*
*/
-void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const char *format, const char *prefix_type, const char *threshold_type, const double low_threshold) {
+void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const char *format, const char *format_not_mounted, const char *prefix_type, const char *threshold_type, const double low_threshold) {
const char *walk;
char *outwalk = buffer;
bool colorful_output = false;
@@ -126,22 +126,22 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
if (statvfs(path, &buf) == -1)
return;
- FILE *mntentfile = setmntent("/etc/mtab", "r");
- struct mntent *m;
- bool found = false;
+ if (format_not_mounted != NULL) {
+ FILE *mntentfile = setmntent("/etc/mtab", "r");
+ struct mntent *m;
+ bool found = false;
- while (NULL != (m = getmntent(mntentfile))) {
- if (strcmp(m->mnt_dir, path) == 0) {
- found = true;
- break;
+ while (NULL != (m = getmntent(mntentfile))) {
+ if (strcmp(m->mnt_dir, path) == 0) {
+ found = true;
+ break;
+ }
}
- }
- endmntent(mntentfile);
+ endmntent(mntentfile);
- if (!found) {
- *buffer = '\0';
- OUTPUT_FULL_TEXT(buffer);
- return;
+ if (!found) {
+ format = format_not_mounted;
+ }
}
#endif