Update documentation for random_distribution=gauss
[fio.git] / lib / mountcheck.c
index dea27462e121befd46793c0b057948912bacc36a..e37e9f927b0c3cc2ecfca6cd26ea7017eb3c083f 100644 (file)
@@ -1,8 +1,8 @@
 #include <stdio.h>
 #include <string.h>
-#include <mntent.h>
 
 #ifdef CONFIG_GETMNTENT
+#include <mntent.h>
 
 #define MTAB   "/etc/mtab"
 
@@ -29,7 +29,30 @@ int device_is_mounted(const char *dev)
        return ret;
 }
 
+#elif defined(CONFIG_GETMNTINFO)
+/* for BSDs */
+#include <sys/param.h>
+#include <sys/mount.h>
+
+int device_is_mounted(const char *dev)
+{
+       struct statfs *st;
+       int i, ret;
+
+       ret = getmntinfo(&st, MNT_NOWAIT);
+       if (ret <= 0)
+               return 0;
+
+       for (i = 0; i < ret; i++) {
+               if (!strcmp(st[i].f_mntfromname, dev))
+                       return 1;
+       }
+
+       return 0;
+}
+
 #else
+/* others */
 
 int device_is_mounted(const char *dev)
 {