From cea9451f780d13e528f1722a67eccbbc78b2daf9 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 9 Aug 2022 10:29:24 +0000 Subject: [PATCH] vfs_io_uring: hide a possible definition of struct open_how in liburing/compat.h 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 Reviewed-by: Volker Lendecke --- source3/modules/vfs_io_uring.c | 18 ++++++++++++++++++ source3/wscript | 13 +++++++++++++ 2 files changed, 31 insertions(+) diff --git a/source3/modules/vfs_io_uring.c b/source3/modules/vfs_io_uring.c index 5168df7a97b..65dd151bb02 100644 --- a/source3/modules/vfs_io_uring.c +++ b/source3/modules/vfs_io_uring.c @@ -20,6 +20,24 @@ * 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 +#undef open_how +#endif /* HAVE_STRUCT_OPEN_HOW_LIBURING_COMPAT_H */ + #include "includes.h" #include "system/filesys.h" #include "smbd/smbd.h" diff --git a/source3/wscript b/source3/wscript index 2121b8b6510..04c278bbe36 100644 --- a/source3/wscript +++ b/source3/wscript @@ -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 -- 2.47.3