[LTP] [PATCH v3 1/4] lib: Add tst_fd iterator

Petr Vorel pvorel@suse.cz
Tue Jan 16 01:32:19 CET 2024


Hi all,

[ removed kernel folks to not bother them with our old distros ]

> Obviously ready to merge, thanks!

I'm sorry, there are still 2 build failures [1] even with my attempt to fix it [2]:

Both Leap 42.2 and Ubuntu Bionic fail to build on:

In file included from ../include/lapi/io_uring.h:17:0,
                 from tst_fd.c:21:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
   MS_RDONLY = 1,  /* Mount read-only.  */
   ^

I found quite useful to have new LTP for these old distros, but if it's too much
pain I'm ok to drop them. I'm not even sure if it's possible to fix it.
The only way to do that would be for these old distros (which cannot combine
these two headers) to also avoid BPF and io_uring. Code below compiles [3], but
I don't think myself it's a good solution even if we polish the check (transform
into m4 macro).

OTOH fsopen haven't been defined in <sys/mount.h> yet in libc (checked: glibc,
musl, uclibc-ng, bionic), thus the effect would be that we'd just use
<linux/mount.h> instead of <sys/mount.h> in lib/*.c. And mount() related tests
which test <sys/mount.h> (or use lapi/mount.h) could not include <linux/mount.h>
nor <linux/io_uring.h> nor <lapi/bpf.h>. Of course, we can't keep these two old
distros too long.

Kind regards,
Petr

[1] https://github.com/pevik/ltp/actions/runs/7534892435
[2] https://lore.kernel.org/ltp/20240105002914.1463989-1-pvorel@suse.cz/
[3] https://github.com/pevik/ltp/actions/runs/7535285434

> Kind regards,
> Petr

diff --git include/lapi/fsmount.h include/lapi/fsmount.h
index 07eb42ffa..a9491a16d 100644
--- include/lapi/fsmount.h
+++ include/lapi/fsmount.h
@@ -11,12 +11,11 @@
 #include "config.h"
 #include <sys/syscall.h>
 #include <sys/types.h>
-#include <sys/mount.h>
 
-#ifndef HAVE_FSOPEN
-# ifdef HAVE_LINUX_MOUNT_H
+#if !defined(HAVE_FSOPEN) && defined(HAVE_LINUX_MOUNT_H)
 # include <linux/mount.h>
-# endif
+#else
+# include <sys/mount.h>
 #endif
 
 #include "lapi/fcntl.h"
diff --git include/tst_fd.h include/tst_fd.h
index 2183ea068..cdf9867e6 100644
--- include/tst_fd.h
+++ include/tst_fd.h
@@ -26,8 +26,10 @@ enum tst_fd_type {
 	TST_FD_INOTIFY,
 	TST_FD_USERFAULTFD,
 	TST_FD_PERF_EVENT,
+#if defined(HAVE_FSOPEN) || !defined(HAVE_LINUX_MOUNT_H)
 	TST_FD_IO_URING,
 	TST_FD_BPF_MAP,
+#endif
 	TST_FD_FSOPEN,
 	TST_FD_FSPICK,
 	TST_FD_OPEN_TREE,
diff --git lib/tst_fd.c lib/tst_fd.c
index b0d6fb1d6..0766328a9 100644
--- lib/tst_fd.c
+++ lib/tst_fd.c
@@ -18,9 +18,12 @@
 #include "tst_safe_macros.h"
 
 #include "lapi/pidfd.h"
+#include "lapi/fsmount.h"
+
+#if defined(HAVE_FSOPEN) || !defined(HAVE_LINUX_MOUNT_H)
 #include "lapi/io_uring.h"
 #include "lapi/bpf.h"
-#include "lapi/fsmount.h"
+#endif
 
 #include "tst_fd.h"
 
@@ -190,6 +193,7 @@ static void open_perf_event(struct tst_fd *fd)
 	}
 }
 
+#if defined(HAVE_FSOPEN) || !defined(HAVE_LINUX_MOUNT_H)
 static void open_io_uring(struct tst_fd *fd)
 {
 	struct io_uring_params uring_params = {};
@@ -216,6 +220,7 @@ static void open_bpf_map(struct tst_fd *fd)
 			"Skipping %s", tst_fd_desc(fd));
 	}
 }
+#endif
 
 static void open_fsopen(struct tst_fd *fd)
 {
@@ -281,8 +286,10 @@ static struct tst_fd_desc fd_desc[] = {
 	[TST_FD_INOTIFY] = {.open_fd = open_inotify, .desc = "inotify"},
 	[TST_FD_USERFAULTFD] = {.open_fd = open_userfaultfd, .desc = "userfaultfd"},
 	[TST_FD_PERF_EVENT] = {.open_fd = open_perf_event, .desc = "perf event"},
+#if defined(HAVE_FSOPEN) || !defined(HAVE_LINUX_MOUNT_H)
 	[TST_FD_IO_URING] = {.open_fd = open_io_uring, .desc = "io uring"},
 	[TST_FD_BPF_MAP] = {.open_fd = open_bpf_map, .desc = "bpf map"},
+#endif
 	[TST_FD_FSOPEN] = {.open_fd = open_fsopen, .desc = "fsopen"},
 	[TST_FD_FSPICK] = {.open_fd = open_fspick, .desc = "fspick"},
 	[TST_FD_OPEN_TREE] = {.open_fd = open_open_tree, .desc = "open_tree"},


More information about the ltp mailing list