Whamcloud - gitweb
ext2fs: check if Lustre filesystem is mounted
[tools/e2fsprogs.git] / misc / ismounted.c
index 72f4cba..6aa0e04 100644 (file)
@@ -9,6 +9,7 @@
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
@@ -28,6 +29,9 @@
 #endif
 #include <string.h>
 #include <sys/stat.h>
+#include <ctype.h>
+
+#include "fsck.h"
 
 /*
  * ext2fs_check_if_mounted flags
@@ -36,6 +40,7 @@
 
 #include "et/com_err.h"
 
+#ifdef HAVE_SETMNTENT
 static char *skip_over_blank(char *cp)
 {
        while (*cp && isspace(*cp))
@@ -65,6 +70,7 @@ static char *parse_word(char **buf)
        *buf = next;
        return word;
 }
+#endif
 
 /*
  * Helper function which checks a file in /etc/mtab format to see if a
@@ -74,18 +80,15 @@ static char *parse_word(char **buf)
 static errcode_t check_mntent_file(const char *mtab_file, const char *file,
                                   int *mount_flags)
 {
+#ifdef HAVE_SETMNTENT
        struct stat     st_buf;
        errcode_t       retval = 0;
        dev_t           file_dev=0, file_rdev=0;
        ino_t           file_ino=0;
        FILE            *f;
        char            buf[1024], *device = 0, *mnt_dir = 0, *cp;
-       int             fd;
 
        *mount_flags = 0;
-       if ((f = fopen(mtab_file, "r")) == NULL)
-               return errno;
-
        if ((f = setmntent (mtab_file, "r")) == NULL)
                return errno;
        if (stat(file, &st_buf) == 0) {
@@ -177,6 +180,9 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
 errout:
        endmntent (f);
        return retval;
+#else /* !HAVE_SETMNTENT */
+       return 0;
+#endif /* HAVE_MNTENT_H */
 }
 
 int is_mounted(const char *file)