Whamcloud - gitweb
Don't assume that the presence of mntent.h means that setmntent() exists
authorTheodore Ts'o <tytso@mit.edu>
Thu, 5 Apr 2012 22:31:09 +0000 (15:31 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 5 Apr 2012 22:31:09 +0000 (15:31 -0700)
Change autoconf to test for setmntent() and use that to decide whether
to use getmntent() and setmntent(), since some systems don't have
setmntent() but they do have the mntent.h header file.

Also, remove the includes of mntent.h from e2fsck and mke2fs and other
places where it is not needed.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
configure
configure.in
e2fsck/iscan.c
e2fsck/scantest.c
e2fsck/unix.c
lib/config.h.in
lib/ext2fs/ismounted.c
misc/ismounted.c
misc/mke2fs.c

index aae5e60..ac0426e 100755 (executable)
--- a/configure
+++ b/configure
@@ -10893,7 +10893,7 @@ if test "$ac_res" != no; then :
 fi
 
 fi
-for ac_func in         __secure_getenv         backtrace       blkid_probe_get_topology        chflags         fallocate       fallocate64     fchown  fdatasync       fstat64         ftruncate64     getdtablesize   getmntinfo      getpwuid_r      getrlimit       getrusage       jrand48         llseek  lseek64         mallinfo        mbstowcs        memalign        mmap    msync   nanosleep       open64  pathconf        posix_fadvise   posix_memalign  prctl   quotactl        setresgid       setresuid       srandom         strcasecmp      strdup  strnlen         strptime        strtoull        sync_file_range         sysconf         usleep  utime   valloc
+for ac_func in         __secure_getenv         backtrace       blkid_probe_get_topology        chflags         fallocate       fallocate64     fchown  fdatasync       fstat64         ftruncate64     getdtablesize   getmntinfo      getpwuid_r      getrlimit       getrusage       jrand48         llseek  lseek64         mallinfo        mbstowcs        memalign        mmap    msync   nanosleep       open64  pathconf        posix_fadvise   posix_memalign  prctl   quotactl        setmntent       setresgid       setresuid       srandom         strcasecmp      strdup  strnlen         strptime        strtoull        sync_file_range         sysconf         usleep  utime   valloc
 do :
   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
 ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
index e458a7d..e15a77a 100644 (file)
@@ -986,6 +986,7 @@ AC_CHECK_FUNCS(m4_flatten([
        posix_memalign
        prctl
        quotactl
+       setmntent
        setresgid
        setresuid
        srandom
index f5286b7..e23d2ad 100644 (file)
@@ -16,9 +16,6 @@
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 #include <sys/ioctl.h>
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
index 852ff86..16380b3 100644 (file)
@@ -12,9 +12,6 @@
 #include <getopt.h>
 #endif
 #include <unistd.h>
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 #include <sys/ioctl.h>
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
index 63d1c65..fdefe7a 100644 (file)
@@ -33,9 +33,6 @@ extern int optind;
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 #ifdef HAVE_SYS_IOCTL_H
 #include <sys/ioctl.h>
 #endif
index bd57a47..18539c6 100644 (file)
 /* Define to 1 if you have the `setlocale' function. */
 #undef HAVE_SETLOCALE
 
+/* Define to 1 if you have the `setmntent' function. */
+#undef HAVE_SETMNTENT
+
 /* Define to 1 if you have the `setresgid' function. */
 #undef HAVE_SETRESGID
 
index 823eb3f..bf532ae 100644 (file)
@@ -35,7 +35,7 @@
 #include "ext2_fs.h"
 #include "ext2fs.h"
 
-#ifdef HAVE_MNTENT_H
+#ifdef HAVE_SETMNTENT
 /*
  * Helper function which checks a file in /etc/mtab format to see if a
  * filesystem is mounted.  Returns an error if the file doesn't exist
@@ -231,7 +231,7 @@ static errcode_t check_getmntinfo(const char *file, int *mount_flags,
        return 0;
 }
 #endif /* HAVE_GETMNTINFO */
-#endif /* HAVE_MNTENT_H */
+#endif /* HAVE_SETMNTENT */
 
 /*
  * Check to see if we're dealing with the swap device.
@@ -310,7 +310,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
                *mount_flags = EXT2_MF_MOUNTED | EXT2_MF_SWAP;
                strncpy(mtpt, "<swap>", mtlen);
        } else {
-#ifdef HAVE_MNTENT_H
+#ifdef HAVE_SETMNTENT
                retval = check_mntent(device, mount_flags, mtpt, mtlen);
 #else
 #ifdef HAVE_GETMNTINFO
@@ -321,7 +321,7 @@ errcode_t ext2fs_check_mount_point(const char *device, int *mount_flags,
 #endif
                *mount_flags = 0;
 #endif /* HAVE_GETMNTINFO */
-#endif /* HAVE_MNTENT_H */
+#endif /* HAVE_SETMNTENT */
        }
        if (retval)
                return retval;
index 9e8bebf..4671af8 100644 (file)
@@ -78,7 +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_MNTENT_H
+#ifdef HAVE_SETMNTENT
        struct stat     st_buf;
        errcode_t       retval = 0;
        dev_t           file_dev=0, file_rdev=0;
@@ -178,7 +178,7 @@ static errcode_t check_mntent_file(const char *mtab_file, const char *file,
 errout:
        endmntent (f);
        return retval;
-#else /* !HAVE_MNTENT_H */
+#else /* !HAVE_SETMNTENT */
        return 0;
 #endif /* HAVE_MNTENT_H */
 }
index 60389d4..7ec8cc2 100644 (file)
@@ -43,9 +43,6 @@ extern int optind;
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#ifdef HAVE_MNTENT_H
-#include <mntent.h>
-#endif
 #include <sys/ioctl.h>
 #include <sys/types.h>
 #include <sys/stat.h>