OSDN Git Service

dumpe2fs: print journal's s_errno field if it is non-zero
[android-x86/external-e2fsprogs.git] / misc / ismounted.c
index 94a2d6e..4671af8 100644 (file)
@@ -9,6 +9,7 @@
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #if HAVE_UNISTD_H
 #include <unistd.h>
@@ -77,6 +78,7 @@ 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;
@@ -85,9 +87,6 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
        char            buf[1024], *device = 0, *mnt_dir = 0, *cp;
 
        *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) {
@@ -179,6 +178,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)