]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_io_uring: hide a possible definition of struct open_how in liburing/compat.h
authorStefan Metzmacher <metze@samba.org>
Tue, 9 Aug 2022 10:29:24 +0000 (10:29 +0000)
committerVolker Lendecke <vl@samba.org>
Mon, 15 Aug 2022 15:03:36 +0000 (15:03 +0000)
liburing.h will include liburing/compat.h, which either includes
linux/openat2.h or defines struct open_how itself.

This will help with the following changes, which will provide
openat2() via libreplace's system/filesys.h, either including
linux/openat2.h or defining open_how ourself.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/modules/vfs_io_uring.c
source3/wscript

index 5168df7a97ba83ab07f5e4bc22c92d8667241a4a..65dd151bb02392c051d181d28e192d451cbacbab 100644 (file)
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include "replace.h"
+
+/*
+ * liburing.h only needs a forward declaration
+ * of struct open_how.
+ *
+ * If struct open_how is defined in liburing/compat.h
+ * itself, hide it away in order to avoid conflicts
+ * with including linux/openat2.h or defining 'struct open_how'
+ * in libreplace.
+ */
+struct open_how;
+#ifdef HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H
+#define open_how __ignore_liburing_compat_h_open_how
+#include <liburing/compat.h>
+#undef open_how
+#endif /* HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H */
+
 #include "includes.h"
 #include "system/filesys.h"
 #include "smbd/smbd.h"
index 2121b8b6510d3daf234a2bef83a087c3e3588903..04c278bbe36ee5220b819d44150fc6f16a55ada0 100644 (file)
@@ -1738,6 +1738,19 @@ main() {
                                       and conf.CHECK_LIB('uring', shlib=True)):
             conf.CHECK_FUNCS_IN('io_uring_ring_dontfork', 'uring',
                                 headers='liburing.h')
+            # There are a few distributions, which
+            # don't seem to have linux/openat2.h available
+            # during the liburing build, which means liburing/compat.h
+            # defines struct open_how directly instead of including
+            # linux/openat2.h, while linux/openat2.h is
+            # available on the installed system, which cause problems
+            # when we try to include both files.
+            #
+            # check if struct open_how is defined in liburing/compat.h
+            # itself and not via inclusing linux/openat2.h
+            conf.CHECK_TYPE_IN('struct open_how', 'liburing/compat.h',
+                               cflags='-D_LINUX_OPENAT2_H',
+                               define='HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H')
             conf.DEFINE('HAVE_LIBURING', '1')
 
     conf.env.build_regedit = False