summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorYann Droneaud2010-03-31 16:14:04 +0200
committerKarel Zak2010-03-31 17:04:37 +0200
commitb832c2fe345c9576432af0db6f1c3a9010fdbf24 (patch)
tree3c712805c14939f057a3abd57b1e9e009cf61968 /configure.ac
parenttests: use POSIX locale (diff)
downloadkernel-qcow2-util-linux-b832c2fe345c9576432af0db6f1c3a9010fdbf24.tar.gz
kernel-qcow2-util-linux-b832c2fe345c9576432af0db6f1c3a9010fdbf24.tar.xz
kernel-qcow2-util-linux-b832c2fe345c9576432af0db6f1c3a9010fdbf24.zip
build-sys: improved check for fallocate()
With glibc 2.10 on a 32bits system, fallocate64() function is not exported. This a problem, since _FILE_OFFSET_BITS is set to 64 and fallocate() is redirected to fallocate64(). Sadly, AC_CHECK_FUNC() doesn't catch such problem, since it's overriding the function prototype. See this for references: http://sources.redhat.com/ml/libc-hacker/2009-05/msg00003.html Signed-off-by: Yann Droneaud <yann@droneaud.fr>
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac37
1 files changed, 36 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac
index 96d7219f9..02777a8ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,8 @@ AC_CHECK_HEADERS(
linux/fd.h \
linux/tiocl.h \
linux/version.h \
+ linux/falloc.h \
+ fcntl.h \
locale.h \
stdint.h \
inttypes.h \
@@ -580,7 +582,40 @@ UTIL_CHECK_SYSCALL([ioprio_get],
dnl fallocate could be available as libc function or as syscall only
UTIL_CHECK_SYSCALL([fallocate])
-AC_CHECK_FUNCS([fallocate])
+
+dnl check for valid fallocate() function
+dnl with 32 bits glibc 2.10, fallocate() exists but not fallocate64()
+dnl when _FILE_OFFSET_BITS==64, fallocate() is redirect to fallocate64()
+dnl and program can't be linked.
+dnl AC_CHECK_FUNC can't catch such errors since it's redefining
+dnl function prototype.
+AC_MSG_CHECKING([for valid fallocate() function])
+AC_LINK_IFELSE([
+AC_LANG_PROGRAM([[
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_LINUX_FALLOC_H
+# include <linux/falloc.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+]],[[
+ long ret;
+
+ ret = fallocate(0, FALLOC_FL_KEEP_SIZE, 0xfffffffful, 0xfffffffful);
+
+ if (ret != 0) {
+ return 1;
+ }
+ ]])],[
+AC_MSG_RESULT([yes])
+AC_DEFINE(HAVE_FALLOCATE,1,[Have valid fallocate() function])],[
+AC_MSG_RESULT([no])])
dnl unshare could be available as libc function or as syscall only
UTIL_CHECK_SYSCALL([unshare])