X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=lib%2Fmountcheck.c;h=2fb6fe742faa3e3348c994e9e75a8167b633013b;hb=8db390cd9131caec46d252dee39a2a511735283c;hp=2eedcc718c1300add44d1b425a2a3ba641af0648;hpb=e7e136da9253290a96ccfbfae5cadaf109b59b3c;p=fio.git diff --git a/lib/mountcheck.c b/lib/mountcheck.c index 2eedcc71..2fb6fe74 100644 --- a/lib/mountcheck.c +++ b/lib/mountcheck.c @@ -4,6 +4,8 @@ #ifdef CONFIG_GETMNTENT #include +#include "mountcheck.h" + #define MTAB "/etc/mtab" int device_is_mounted(const char *dev) @@ -30,7 +32,7 @@ int device_is_mounted(const char *dev) } #elif defined(CONFIG_GETMNTINFO) -/* for BSDs */ +/* for most BSDs */ #include #include @@ -51,4 +53,33 @@ int device_is_mounted(const char *dev) return 0; } +#elif defined(CONFIG_GETMNTINFO_STATVFS) +/* for NetBSD */ +#include + +int device_is_mounted(const char *dev) +{ + struct statvfs *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) +{ + return 0; +} + #endif