X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=lib%2Fmountcheck.c;h=e8780eb3b46a166f81726c9a2966a1a0c901a465;hp=bb01f69f46b1ed579fbd36bb6d4a4cf6f8f4f374;hb=9ada751de9177687b19e3398d43fdb706ea14a09;hpb=a53d4f7847273faeef9795ad7a3f5865b0c22840 diff --git a/lib/mountcheck.c b/lib/mountcheck.c index bb01f69f..e8780eb3 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,30 @@ int device_is_mounted(const char *dev) return ret; } +#elif defined(CONFIG_GETMNTINFO) +/* for 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; +} + #else +/* others */ int device_is_mounted(const char *dev) {