From b24efa218794b567c27ad99db319b4bd5d696958 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 5 Apr 2012 15:31:09 -0700 Subject: [PATCH] Don't assume that the presence of mntent.h means that setmntent() exists 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" --- configure | 2 +- configure.in | 1 + e2fsck/iscan.c | 3 --- e2fsck/scantest.c | 3 --- e2fsck/unix.c | 3 --- lib/config.h.in | 3 +++ lib/ext2fs/ismounted.c | 8 ++++---- misc/ismounted.c | 4 ++-- misc/mke2fs.c | 3 --- 9 files changed, 11 insertions(+), 19 deletions(-) diff --git a/configure b/configure index aae5e60..ac0426e 100755 --- 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" diff --git a/configure.in b/configure.in index e458a7d..e15a77a 100644 --- a/configure.in +++ b/configure.in @@ -986,6 +986,7 @@ AC_CHECK_FUNCS(m4_flatten([ posix_memalign prctl quotactl + setmntent setresgid setresuid srandom diff --git a/e2fsck/iscan.c b/e2fsck/iscan.c index f5286b7..e23d2ad 100644 --- a/e2fsck/iscan.c +++ b/e2fsck/iscan.c @@ -16,9 +16,6 @@ #ifdef HAVE_ERRNO_H #include #endif -#ifdef HAVE_MNTENT_H -#include -#endif #include #ifdef HAVE_MALLOC_H #include diff --git a/e2fsck/scantest.c b/e2fsck/scantest.c index 852ff86..16380b3 100644 --- a/e2fsck/scantest.c +++ b/e2fsck/scantest.c @@ -12,9 +12,6 @@ #include #endif #include -#ifdef HAVE_MNTENT_H -#include -#endif #include #ifdef HAVE_MALLOC_H #include diff --git a/e2fsck/unix.c b/e2fsck/unix.c index 63d1c65..fdefe7a 100644 --- a/e2fsck/unix.c +++ b/e2fsck/unix.c @@ -33,9 +33,6 @@ extern int optind; #ifdef HAVE_ERRNO_H #include #endif -#ifdef HAVE_MNTENT_H -#include -#endif #ifdef HAVE_SYS_IOCTL_H #include #endif diff --git a/lib/config.h.in b/lib/config.h.in index bd57a47..18539c6 100644 --- a/lib/config.h.in +++ b/lib/config.h.in @@ -314,6 +314,9 @@ /* 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 diff --git a/lib/ext2fs/ismounted.c b/lib/ext2fs/ismounted.c index 823eb3f..bf532ae 100644 --- a/lib/ext2fs/ismounted.c +++ b/lib/ext2fs/ismounted.c @@ -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, "", 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; diff --git a/misc/ismounted.c b/misc/ismounted.c index 9e8bebf..4671af8 100644 --- a/misc/ismounted.c +++ b/misc/ismounted.c @@ -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 */ } diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 60389d4..7ec8cc2 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -43,9 +43,6 @@ extern int optind; #ifdef HAVE_ERRNO_H #include #endif -#ifdef HAVE_MNTENT_H -#include -#endif #include #include #include -- 1.8.3.1