[LTP] [PATCH] configure.ac: fix mount_attr detection

Li Wang liwang@redhat.com
Thu Mar 9 14:00:14 CET 2023


On Mon, Feb 27, 2023 at 7:26 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Commit b857f8723f30a4b9554bf6b0ff8fa52fd07e8b60 tried to fix build with
> > latest glibc which provides mount_attr in sys/mount.h. Unfortunately,
> > the following build failure is still raised because sys/mount is now
> > unconditionally included in include/lapi/fsmount.h:
> >
> > In file included from fsconfig01.c:9:
> > ../../../../include/lapi/fsmount.h:55:8: error: redefinition of 'struct
> mount_attr'
> >    55 | struct mount_attr {
> >       |        ^~~~~~~~~~
> > In file included from ../../../../include/lapi/fsmount.h:14:
> >
> /home/autobuild/autobuild/instance-4/output-1/host/armeb-buildroot-linux-gnueabi/sysroot/usr/include/sys/mount.h:210:8:
> note: originally defined here
> >   210 | struct mount_attr
> >       |        ^~~~~~~~~~
> >
> > Fixes:
> >  -
> http://autobuild.buildroot.org/results/4dbb72e1bf081afd3cd944571b9beeefc7608865
> >
> > Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
> > ---
> >  configure.ac | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index c2b0f48e7..a6d8ac826 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -225,10 +225,10 @@ AC_CHECK_TYPES([struct __kernel_old_timeval,
> struct __kernel_old_timespec, struc
> >
> >  AC_CHECK_TYPES([struct futex_waitv],,,[#include <linux/futex.h>])
> >  AC_CHECK_TYPES([struct mount_attr],,,[
> > -#ifdef HAVE_LINUX_MOUNT_H
> > -# include <linux/mount.h>
> > -#else
> > +#ifdef HAVE_MOUNT_SETATTR
> >  # include <sys/mount.h>
> > +#elif HAVE_LINUX_MOUNT_H
> > +# include <linux/mount.h>
> >  #endif
> >  ])
>
> I wonder if we can get this whole mess of two different fallback headers
> simplified. Looking at the glibc implementation it seems to include
> "linux/mount.h" if it does exist. So most reasonable solution would do
> the same I guess which we did before the commit you reference.
>
> @Li Wang where does the the sys/mount.h and linux/mount.h conflict? As
>

I remember in the newer Glibc that added new definitions
(e.g. mount_setattr, fsopen) support in sys/mount.h which
conflict with linux/mount.h.

That's the reason I submit the patch to resolve it for some
middle version of Glibc exists the problem.

But that problem later resolves in Glibc as well by:
https://github.com/kraj/glibc/commit/774058d72942249f71d74e7f2b639f77184160a6


Check my Fedora37:
---------------------------

$ rpm -qf /usr/include/sys/mount.h
glibc-headers-x86-2.34-49.fc35.noarch

$ grep mount_attr  /usr/include/sys/mount.h
#define MOUNT_ATTR_IDMAP        0x00100000 /* Idmap mount to @userns_fd in
struct mount_attr.  */
struct mount_attr
 struct mount_attr *__uattr, size_t __usize)

$ rpm -qf /usr/include/linux/mount.h
kernel-headers-6.1.5-200.fc37.x86_64

$ grep mount_attr  /usr/include/linux/mount.h
#define MOUNT_ATTR_IDMAP 0x00100000 /* Idmap mount to @userns_fd in struct
mount_attr. */
struct mount_attr {
/* List of all mount_attr versions. */


far as I can tell the UAPI linux/mount.h never defined any functions,
> just constants, which should be solvable without the complex ifdefs, we
> just need to check for existence of the types and define them only if
> missing.
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list