Fix fanotify_mark decoding on 32-bit architectures
The fanotify_mark syscall takes a 64-bit mask, and on 32-bit
architectures it is split up into two syscall arguments.
* configure.ac (AC_CHECK_FUNCS): Add fanotify_mark.
(AC_CHECK_HEADERS): Add sys/fanotify.h.
* defs.h (getllval): New prototype.
* util.c (getllval): New function based on printllval.
(printllval): Use getllval.
* fanotify.c (sys_fanotify_mark): Use getllval to properly decode
64-bit mask and two syscall arguments followed by it.
* tests/fanotify_mark.c: New file.
* tests/fanotify_mark.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add fanotify_mark.
(TESTS): Add fanotify_mark.test.
* tests/.gitignore: Add fanotify_mark.
diff --git a/tests/.gitignore b/tests/.gitignore
index af463d0..ce3e210 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -1,4 +1,5 @@
caps
+fanotify_mark
inet-accept-connect-send-recv
mmsg
net-accept-connect
diff --git a/tests/Makefile.am b/tests/Makefile.am
index b88ed55..7c8f7b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -5,6 +5,7 @@
check_PROGRAMS = \
inet-accept-connect-send-recv \
caps \
+ fanotify_mark \
mmsg \
net-accept-connect \
netlink_inet_diag \
@@ -32,6 +33,7 @@
strace-f.test \
qual_syscall.test \
caps.test \
+ fanotify_mark.test \
getdents.test \
scm_rights-fd.test \
sigaction.test \
diff --git a/tests/fanotify_mark.c b/tests/fanotify_mark.c
new file mode 100644
index 0000000..7160acd
--- /dev/null
+++ b/tests/fanotify_mark.c
@@ -0,0 +1,19 @@
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined HAVE_SYS_FANOTIFY_H && defined HAVE_FANOTIFY_MARK
+# include <sys/fanotify.h>
+int
+main(void)
+{
+ fanotify_mark(-1, FAN_MARK_ADD, FAN_MODIFY | FAN_ONDIR, -100, ".");
+ return 0;
+}
+#else
+int
+main(void)
+{
+ return 77;
+}
+#endif
diff --git a/tests/fanotify_mark.test b/tests/fanotify_mark.test
new file mode 100755
index 0000000..c5eb4eb
--- /dev/null
+++ b/tests/fanotify_mark.test
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Check fanotify_mark syscall decoding.
+
+. "${srcdir=.}/init.sh"
+
+check_prog grep
+
+./fanotify_mark || {
+ if [ $? -eq 77 ]; then
+ framework_skip_ 'fanotify_mark is not available'
+ else
+ fail_ 'fanotify_mark failed'
+ fi
+}
+
+args="-efanotify_mark ./fanotify_mark"
+$STRACE -o "$LOG" $args || {
+ cat "$LOG"
+ fail_ "$STRACE $args failed"
+}
+
+grep_log()
+{
+ local syscall="$1"; shift
+
+ LC_ALL=C grep -E -x "$syscall$*" $LOG > /dev/null || {
+ cat $LOG
+ fail_ "$STRACE $args failed to trace \"$syscall\" properly"
+ }
+}
+
+grep_log fanotify_mark '\(-1, FAN_MARK_ADD, FAN_MODIFY\|FAN_ONDIR, AT_FDCWD, "\."\) += -1.*'
+
+exit 0