From: Dmitry V. Levin Date: Feb. 22, 2017, 2:29 a.m. Subject: uapi: add a compatibility layer between linux/uio.h and glibc References: bsc#1053501 Patch-mainline: Not yet, submitted 2/22/2017 to lkml Do not define struct iovec in linux/uio.h when or is already included and provides these definitions. This fixes the following compilation error when or is included before : /usr/include/linux/uio.h:16:8: error: redefinition of 'struct iovec' Signed-off-by: Dmitry V. Levin Acked-by: Lee Duncan --- include/uapi/linux/libc-compat.h | 10 ++++++++++ include/uapi/linux/uio.h | 3 +++ 2 files changed, 13 insertions(+) --- a/include/uapi/linux/libc-compat.h +++ b/include/uapi/linux/libc-compat.h @@ -158,6 +158,13 @@ #endif /* defined(__NETIPX_IPX_H) */ +/* Coordinate with glibc bits/uio.h header. */ +#if defined(_SYS_UIO_H) || defined(_FCNTL_H) +#define __UAPI_DEF_IOVEC 0 +#else +#define __UAPI_DEF_IOVEC 1 +#endif + /* Definitions for xattr.h */ #if defined(_SYS_XATTR_H) #define __UAPI_DEF_XATTR 0 @@ -205,6 +212,9 @@ #define __UAPI_DEF_IPX_ROUTE_DEF 1 #endif +/* Definitions for uio.h */ +#define __UAPI_DEF_IOVEC 1 + /* Definitions for xattr.h */ #ifndef __UAPI_DEF_XATTR #define __UAPI_DEF_XATTR 1 --- a/include/uapi/linux/uio.h +++ b/include/uapi/linux/uio.h @@ -9,15 +9,18 @@ #ifndef _UAPI__LINUX_UIO_H #define _UAPI__LINUX_UIO_H +#include #include #include +#if __UAPI_DEF_IOVEC struct iovec { void __user *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ __kernel_size_t iov_len; /* Must be size_t (1003.1g) */ }; +#endif /* __UAPI_DEF_IOVEC */ /* * UIO_MAXIOV shall be at least 16 1003.1g (5.4.1.1)