Whamcloud - gitweb
LU-13274 uapi: fix build on older kernels 20/38520/3
authorAndreas Dilger <adilger@whamcloud.com>
Thu, 7 May 2020 00:08:14 +0000 (18:08 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 19 May 2020 22:31:27 +0000 (22:31 +0000)
The recent changes to lustre_user.h broke building on older kernels,
because it resulted in the user tools including both <linux/quota.h>
and <sys/quota.h>, which results in conflicts for the declaration of
the quotactl() function.

Also, restore the compat declaration of __ALIGN_KERNEL(), though it
only in lustre_user.h, since it is included in other headers anyway.

Test-Parameters: trivial
Fixes: 0417dce9fc75 ("LU-13274 uapi: make lustre UAPI headers C99 compliant")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I9b31cabaf2732eb5872e88686e6af7d12e7d3564
Reviewed-on: https://review.whamcloud.com/38520
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/uapi/linux/lustre/lustre_user.h

index 1f703f1..055542c 100644 (file)
  * @{
  */
 
-#include <linux/fs.h>
 #include <linux/limits.h>
 #include <linux/kernel.h>
-#include <linux/string.h>
-#include <linux/quota.h>
 #include <linux/types.h>
-#include <linux/unistd.h>
-#include <linux/lustre/lustre_fiemap.h>
 
-#ifndef __KERNEL__
+#ifdef __KERNEL__
+# include <linux/fs.h>
+# include <linux/quota.h>
+# include <linux/string.h> /* snprintf() */
+# include <linux/unistd.h>
+#else /* ! __KERNEL__ */
 # include <stdbool.h>
 # include <stdio.h> /* snprintf() */
+# include <string.h>
+# define NEED_QUOTA_DEFS
+/* # include <sys/quota.h> - this causes complaints about caddr_t */
 # include <sys/stat.h>
 # define FILEID_LUSTRE 0x97 /* for name_to_handle_at() (and llapi_fd2fid()) */
 #endif /* !__KERNEL__ */
 
+/* Handle older distros */
+#ifndef __ALIGN_KERNEL
+#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
+#define __ALIGN_KERNEL(x, a)        __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+#endif
+
+#include <linux/lustre/lustre_fiemap.h>
+
 #if defined(__cplusplus)
 extern "C" {
 #endif