#include <stdlib.h>
#include <string.h>
#include <ctype.h>
-#include <mntent.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/statvfs.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || (__OpenBSD__) || defined(__DragonFly__)
#include <sys/param.h>
#include <sys/mount.h>
+#else
+#include <mntent.h>
#endif
#include <yajl/yajl_gen.h>
#include <yajl/yajl_version.h>
#else
struct statvfs buf;
- if (statvfs(path, &buf) == -1)
- return;
-
- if (format_not_mounted != NULL) {
+ if (statvfs(path, &buf) == -1) {
+ /* If statvfs errors, e.g., due to the path not existing,
+ * we use the format for a not mounted device. */
+ format = format_not_mounted;
+ } else if (format_not_mounted != NULL) {
FILE *mntentfile = setmntent("/etc/mtab", "r");
struct mntent *m;
bool found = false;