Merge pull request #35 from Airblader/feature-33
Use format_not_mounted if path does not exist
This commit is contained in:
commit
adaa83222c
@ -238,7 +238,7 @@ is assumed to be "percentage_avail" and low_threshold to be set to 0, which
|
|||||||
implies no coloring at all.
|
implies no coloring at all.
|
||||||
|
|
||||||
You can define a different format with the option "format_not_mounted"
|
You can define a different format with the option "format_not_mounted"
|
||||||
which is used if the path is not a mount point. So you can just empty
|
which is used if the path does not exist or is not a mount point. So you can just empty
|
||||||
the output for the given path with adding +format_not_mounted=""+
|
the output for the given path with adding +format_not_mounted=""+
|
||||||
to the config section.
|
to the config section.
|
||||||
|
|
||||||
|
@ -124,10 +124,11 @@ void print_disk_info(yajl_gen json_gen, char *buffer, const char *path, const ch
|
|||||||
#else
|
#else
|
||||||
struct statvfs buf;
|
struct statvfs buf;
|
||||||
|
|
||||||
if (statvfs(path, &buf) == -1)
|
if (statvfs(path, &buf) == -1) {
|
||||||
return;
|
/* If statvfs errors, e.g., due to the path not existing,
|
||||||
|
* we use the format for a not mounted device. */
|
||||||
if (format_not_mounted != NULL) {
|
format = format_not_mounted;
|
||||||
|
} else if (format_not_mounted != NULL) {
|
||||||
FILE *mntentfile = setmntent("/etc/mtab", "r");
|
FILE *mntentfile = setmntent("/etc/mtab", "r");
|
||||||
struct mntent *m;
|
struct mntent *m;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user