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" <tytso@mit.edu>
bitmap-optimize
Theodore Ts'o 2012-04-05 15:31:09 -07:00
parent d47e2af763
commit b24efa2187
9 changed files with 11 additions and 19 deletions

2
configure vendored
View File

@ -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"

View File

@ -986,6 +986,7 @@ AC_CHECK_FUNCS(m4_flatten([
posix_memalign
prctl
quotactl
setmntent
setresgid
setresuid
srandom

View 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>

View 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>

View 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

View File

@ -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

View 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;

View 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 */
}

View 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>