X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=lib%2Fmountcheck.c;h=0aec7441f91d412a01fc17d1ec083415f3f58e26;hp=bb01f69f46b1ed579fbd36bb6d4a4cf6f8f4f374;hb=b765bec0be97ef05e5af6cfbf4e0a2c8b7596a03;hpb=4ab727936660d49a81879e2105d17905dc6437ef diff --git a/lib/mountcheck.c b/lib/mountcheck.c index bb01f69f..0aec7441 100644 --- a/lib/mountcheck.c +++ b/lib/mountcheck.c @@ -4,6 +4,8 @@ #ifdef CONFIG_GETMNTENT #include +#include "lib/mountcheck.h" + #define MTAB "/etc/mtab" int device_is_mounted(const char *dev) @@ -29,7 +31,51 @@ int device_is_mounted(const char *dev) return ret; } +#elif defined(CONFIG_GETMNTINFO) +/* for most BSDs */ +#include +#include + +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; +} + +#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) {