From 6529e6565e7a2fd57e07863e4175936a12c09ecb Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 25 Oct 2016 15:14:32 -0700 Subject: [PATCH] libxfs: add autoconf mechanism to override system header fsxattr By default, libxfs will use the kernel/system headers to define struct fsxattr. Unfortunately, this creates a problem for developers who are writing new features but building xfsprogs on a stable system, because the stable kernel's headers don't reflect the new feature. In this case, we want to be able to use the internal fsxattr definition while the kernel headers catch up, so provide some configure magic to allow further patches to force the use of the internal definition. Signed-off-by: Darrick J. Wong --- v2: Remove the user-visible configure option but leave the fsxattr override ability so that subsequent patches can trigger it if necessary. --- configure.ac | 1 + include/builddefs.in | 4 ++++ include/linux.h | 10 +++++++++- io/fiemap.c | 1 - m4/package_libcdev.m4 | 11 +++++++++++ 5 files changed, 25 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 50e04dfd9..ee918d131 100644 --- a/configure.ac +++ b/configure.ac @@ -129,6 +129,7 @@ AC_HAVE_FLS AC_HAVE_READDIR AC_HAVE_FSETXATTR AC_HAVE_MREMAP +AC_NEED_INTERNAL_FSXATTR if test "$enable_blkid" = yes; then AC_HAVE_BLKID_TOPO diff --git a/include/builddefs.in b/include/builddefs.in index 7153d7a76..317adc613 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -109,6 +109,7 @@ HAVE_MNTENT = @have_mntent@ HAVE_FLS = @have_fls@ HAVE_FSETXATTR = @have_fsetxattr@ HAVE_MREMAP = @have_mremap@ +NEED_INTERNAL_FSXATTR = @need_internal_fsxattr@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall # -Wbitwise -Wno-transparent-union -Wno-old-initializer -Wno-decl @@ -148,6 +149,9 @@ endif ifeq ($(ENABLE_BLKID),yes) PCFLAGS+= -DENABLE_BLKID endif +ifeq ($(NEED_INTERNAL_FSXATTR),yes) +PCFLAGS+= -DOVERRIDE_SYSTEM_FSXATTR +endif GCFLAGS = $(OPTIMIZER) $(DEBUG) \ diff --git a/include/linux.h b/include/linux.h index ddc053e0e..e26388b2e 100644 --- a/include/linux.h +++ b/include/linux.h @@ -32,7 +32,13 @@ #include #include #include +#ifdef OVERRIDE_SYSTEM_FSXATTR +# define fsxattr sys_fsxattr +#endif #include /* fsxattr defintion for new kernels */ +#ifdef OVERRIDE_SYSTEM_FSXATTR +# undef fsxattr +#endif static __inline__ int xfsctl(const char *path, int fd, int cmd, void *p) { @@ -175,7 +181,7 @@ static inline void platform_mntent_close(struct mntent_cursor * cursor) * are a copy of the definitions moved to linux/uapi/fs.h in the 4.5 kernel, * so this is purely for supporting builds against old kernel headers. */ -#ifndef FS_IOC_FSGETXATTR +#if !defined FS_IOC_FSGETXATTR || defined OVERRIDE_SYSTEM_FSXATTR struct fsxattr { __u32 fsx_xflags; /* xflags field value (get/set) */ __u32 fsx_extsize; /* extsize field value (get/set)*/ @@ -184,7 +190,9 @@ struct fsxattr { __u32 fsx_cowextsize; /* cow extsize field value (get/set) */ unsigned char fsx_pad[8]; }; +#endif +#ifndef FS_IOC_FSGETXATTR /* * Flags for the fsx_xflags field */ diff --git a/io/fiemap.c b/io/fiemap.c index f89da068e..bcbae49fe 100644 --- a/io/fiemap.c +++ b/io/fiemap.c @@ -19,7 +19,6 @@ #include "platform_defs.h" #include "command.h" #include -#include #include "init.h" #include "io.h" diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4 index 7a847e91d..e0a95e2d8 100644 --- a/m4/package_libcdev.m4 +++ b/m4/package_libcdev.m4 @@ -265,3 +265,14 @@ AC_DEFUN([AC_HAVE_MREMAP], ) AC_SUBST(have_mremap) ]) + +# +# Check if we need to override the system struct fsxattr with +# the internal definition. This /only/ happens if the system +# actually defines struct fsxattr /and/ the system definition +# is missing certain fields. +# +AC_DEFUN([AC_NEED_INTERNAL_FSXATTR], + [ + AC_SUBST(need_internal_fsxattr) + ]) -- 2.50.1