Fix build error on non-GNU environment
[fio.git] / lib / mountcheck.c
CommitLineData
aae599ba
JA
1#include <stdio.h>
2#include <string.h>
aae599ba
JA
3
4#ifdef CONFIG_GETMNTENT
4ab72793 5#include <mntent.h>
aae599ba
JA
6
7#define MTAB "/etc/mtab"
8
9int device_is_mounted(const char *dev)
10{
11 FILE *mtab;
12 struct mntent *mnt;
13 int ret = 0;
14
15 mtab = setmntent(MTAB, "r");
16 if (!mtab)
17 return 0;
18
19 while ((mnt = getmntent(mtab)) != NULL) {
20 if (!mnt->mnt_fsname)
21 continue;
22 if (!strcmp(mnt->mnt_fsname, dev)) {
23 ret = 1;
24 break;
25 }
26 }
27
28 endmntent(mtab);
29 return ret;
30}
31
32#else
33
34int device_is_mounted(const char *dev)
35{
36 return 0;
37}
38
39#endif