[PATCH v3 09/11] xfsprogs: Add mntent.h check into autoconf

Jan Tulak
2015-08-03T14:40:33Z

configure.ac | 1 +
fsr/xfs_fsr.c | 6 +++---
include/builddefs.in | 4 ++++
m4/package_libcdev.m4 | 12 ++++++++++++
4 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8f966a6..e2d395b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,7 @@ AC_HAVE_PREADV
AC_HAVE_SYNC_FILE_RANGE
AC_HAVE_BLKID_TOPO($enable_blkid)
AC_HAVE_READDIR
+AC_HAVE_MNTENT
AC_HAVE_FLS

AC_CHECK_SIZEOF([long])
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index d8a4ece..12eb172 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -25,16 +25,16 @@

#include <fcntl.h>
#include <errno.h>
-#include <malloc.h>
-#include <mntent.h>
#include <syslog.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
-#include <sys/vfs.h>
#include <sys/statvfs.h>
#include <sys/xattr.h>

+#ifdef HAVE_MNTENT
+# include <mntent.h>
+#endif

#ifndef XFS_XFLAG_NODEFRAG
#define XFS_XFLAG_NODEFRAG 0x00002000 /* src dependancy, remove later */
diff --git a/include/builddefs.in b/include/builddefs.in
index 9feb096..1132f26 100644
--- a/include/builddefs.in
+++ b/include/builddefs.in
@@ -104,6 +104,7 @@ HAVE_FIEMAP = @have_fiemap@
HAVE_PREADV = @have_preadv@
HAVE_SYNC_FILE_RANGE = @have_sync_file_range@
HAVE_READDIR = @have_readdir@
+HAVE_MNTENT = @have_mntent@
HAVE_FLS = @have_fls@

GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall
@@ -135,6 +136,9 @@ endif
ifeq ($(HAVE_FLS),yes)
LCFLAGS+= -DHAVE_FLS
endif
+ifeq ($(HAVE_MNTENT),yes)
+PCFLAGS+= -DHAVE_MNTENT
+endif

GCFLAGS = $(OPTIMIZER) $(DEBUG) \
-DVERSION=\"$(PKG_VERSION)\" -DLOCALEDIR=\"$(PKG_LOCALE_DIR)\" \
diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index d7f37ca..bb7bcdb 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -216,3 +216,15 @@ AC_DEFUN([AC_HAVE_FLS],
AC_MSG_RESULT(no))
AC_SUBST(have_fls)
])
+
+#
+# Check if there is mntent.h
+#
+AC_DEFUN([AC_HAVE_MNTENT],
+ [ AC_MSG_CHECKING([for mntent])
+ AC_CHECK_HEADERS(mntent.h,
+ have_mntent=yes
+ AC_MSG_RESULT(yes),
+ AC_MSG_RESULT(no))
+ AC_SUBST(have_mntent)
+ ])
--
2.4.3