linux-test-project/ltp

tst_fd imports sys/fanotify.h

edliaw opened this issue · 4 comments

It looks like tst_fd.c was added recently:

#include <sys/fanotify.h>
and it imports sys/fanotify.h. On Android, bionic doesn't provide this header, and has HAVE_SYS_FANOTIFY_H unset; how should this be handled? Should ifdefs be added around the import and open_fanotify?

Hmm, I guess that the easiest fix would be to just call the raw syscall then, given that we do need just a file descriptor.

What about this, will it work for you?

diff --git a/lib/tst_fd.c b/lib/tst_fd.c
index b3d43a7c3..6538a098c 100644
--- a/lib/tst_fd.c
+++ b/lib/tst_fd.c
@@ -10,9 +10,9 @@
 #include <sys/eventfd.h>
 #include <sys/signalfd.h>
 #include <sys/timerfd.h>
-#include <sys/fanotify.h>
 #include <sys/inotify.h>
 #include <linux/perf_event.h>
+#include <linux/fanotify.h>
 
 #include "tst_test.h"
 #include "tst_safe_macros.h"
@@ -146,7 +146,7 @@ static void open_pidfd(struct tst_fd *fd)
 
 static void open_fanotify(struct tst_fd *fd)
 {
-       fd->fd = fanotify_init(FAN_CLASS_NOTIF, O_RDONLY);
+       fd->fd = syscall(__NR_fanotify_init, FAN_CLASS_NOTIF, O_RDONLY);
        if (fd->fd < 0) {
                tst_res(TCONF | TERRNO,
                        "Skipping %s", tst_fd_desc(fd));

Yeah, that works for me.

@edliaw please send a patch for this.