Blob Blame Raw
From 4cd8ed07d0313bca37b01064208eafa842f1a169 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Wed, 9 Oct 2013 12:17:30 +0200
Subject: [PATCH] switch to glibc functions for fanotify

Switch to glibc functions for fanotify instead of using the incomplete
hand-crafted support. It makes possible to build clamav on non-x86
Linux architectures.
---
 clamd/fan-syscalllib.h | 28 ----------------------------
 clamd/fan.c            |  3 +--
 configure              |  4 ++--
 configure.ac           |  2 +-
 4 files changed, 4 insertions(+), 33 deletions(-)
 delete mode 100644 clamd/fan-syscalllib.h

diff --git a/clamd/fan-syscalllib.h b/clamd/fan-syscalllib.h
deleted file mode 100644
index 288cd99..0000000
--- a/clamd/fan-syscalllib.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef __FANOTIFY_SYSCALL_LIB
-#define __FANOTIFY_SYSCALL_LIB
-
-#include <unistd.h>
-#include <linux/types.h>
-
-#if defined(__x86_64__)
-# define __NR_fanotify_init	300
-# define __NR_fanotify_mark	301
-#elif defined(__i386__)
-# define __NR_fanotify_init	338
-# define __NR_fanotify_mark	339
-#else
-# error "System call numbers not defined for this architecture"
-#endif
-
-static inline int fanotify_init(unsigned int flags, unsigned int event_f_flags)
-{
-	return syscall(__NR_fanotify_init, flags, event_f_flags);
-}
-
-static inline int fanotify_mark(int fanotify_fd, unsigned int flags, __u64 mask,
-				int dfd, const char *pathname)
-{
-	return syscall(__NR_fanotify_mark, fanotify_fd, flags, mask,
-		       dfd, pathname);
-}
-#endif
diff --git a/clamd/fan.c b/clamd/fan.c
index 303f52e..66d2932 100644
--- a/clamd/fan.c
+++ b/clamd/fan.c
@@ -34,8 +34,7 @@
 #include <string.h>
 #include <errno.h>
 
-#include <linux/fanotify.h>
-#include "fan-syscalllib.h"
+#include <sys/fanotify.h>
 #include "fan.h"
 
 #include "libclamav/clamav.h"
diff --git a/configure b/configure
index a570707..b75e740 100755
--- a/configure
+++ b/configure
@@ -17840,8 +17840,8 @@ $as_echo "#define C_LINUX 1" >>confdefs.h
 	THREAD_LIBS="-lpthread"
 	TH_SAFE="-thread-safe"
 	if test "$want_fanotify" = "yes"; then
-	    ac_fn_c_check_header_mongrel "$LINENO" "linux/fanotify.h" "ac_cv_header_linux_fanotify_h" "$ac_includes_default"
-if test "x$ac_cv_header_linux_fanotify_h" = xyes; then :
+	    ac_fn_c_check_header_mongrel "$LINENO" "sys/fanotify.h" "ac_cv_header_sys_fanotify_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_fanotify_h" = xyes; then :
 
 $as_echo "#define FANOTIFY 1" >>confdefs.h
 
diff --git a/configure.ac b/configure.ac
index 8ea9dac..4dba8f7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1001,7 +1001,7 @@ linux*)
 	THREAD_LIBS="-lpthread"
 	TH_SAFE="-thread-safe"
 	if test "$want_fanotify" = "yes"; then
-	    AC_CHECK_HEADER([linux/fanotify.h],AC_DEFINE([FANOTIFY],1,[use fanotify]),)
+	    AC_CHECK_HEADER([sys/fanotify.h],AC_DEFINE([FANOTIFY],1,[use fanotify]),)
 	fi
     fi
     ;;
-- 
1.8.1.4