diff mbox series

[v7,5/5] linux: Add mount_setattr

Message ID 20220624195919.435424-6-adhemerval.zanella@linaro.org
State Committed
Headers show
Series linux: Add new syscalls | expand

Checks

Context Check Description
dj/TryBot-32bit success Build for i686

Commit Message

Adhemerval Zanella Netto June 24, 2022, 7:59 p.m. UTC
It was added on Linux 5.12 (2a1867219c7b27f928e2545782b86daaf9ad50bd)
to allow change the properties of a mount or a mount tree using file
descriptors which the new mount api is based on.

Checked on x86_64-linux-gnu.
---
 NEWS                                          |  8 ++---
 sysdeps/unix/sysv/linux/Versions              |  1 +
 sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  1 +
 sysdeps/unix/sysv/linux/alpha/libc.abilist    |  1 +
 sysdeps/unix/sysv/linux/arc/libc.abilist      |  1 +
 sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  1 +
 sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  1 +
 sysdeps/unix/sysv/linux/csky/libc.abilist     |  1 +
 sysdeps/unix/sysv/linux/hppa/libc.abilist     |  1 +
 sysdeps/unix/sysv/linux/i386/libc.abilist     |  1 +
 sysdeps/unix/sysv/linux/ia64/libc.abilist     |  1 +
 .../sysv/linux/m68k/coldfire/libc.abilist     |  1 +
 .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  1 +
 .../sysv/linux/microblaze/be/libc.abilist     |  1 +
 .../sysv/linux/microblaze/le/libc.abilist     |  1 +
 .../sysv/linux/mips/mips32/fpu/libc.abilist   |  1 +
 .../sysv/linux/mips/mips32/nofpu/libc.abilist |  1 +
 .../sysv/linux/mips/mips64/n32/libc.abilist   |  1 +
 .../sysv/linux/mips/mips64/n64/libc.abilist   |  1 +
 sysdeps/unix/sysv/linux/nios2/libc.abilist    |  1 +
 sysdeps/unix/sysv/linux/or1k/libc.abilist     |  1 +
 .../linux/powerpc/powerpc32/fpu/libc.abilist  |  1 +
 .../powerpc/powerpc32/nofpu/libc.abilist      |  1 +
 .../linux/powerpc/powerpc64/be/libc.abilist   |  1 +
 .../linux/powerpc/powerpc64/le/libc.abilist   |  1 +
 .../unix/sysv/linux/riscv/rv32/libc.abilist   |  1 +
 .../unix/sysv/linux/riscv/rv64/libc.abilist   |  1 +
 .../unix/sysv/linux/s390/s390-32/libc.abilist |  1 +
 .../unix/sysv/linux/s390/s390-64/libc.abilist |  1 +
 sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  1 +
 sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  1 +
 .../sysv/linux/sparc/sparc32/libc.abilist     |  1 +
 .../sysv/linux/sparc/sparc64/libc.abilist     |  1 +
 sysdeps/unix/sysv/linux/sys/mount.h           | 22 ++++++++++++++
 sysdeps/unix/sysv/linux/syscalls.list         |  1 +
 sysdeps/unix/sysv/linux/tst-mount-consts.py   |  4 ++-
 sysdeps/unix/sysv/linux/tst-mount.c           | 30 +++++++++++++++++--
 .../unix/sysv/linux/x86_64/64/libc.abilist    |  1 +
 .../unix/sysv/linux/x86_64/x32/libc.abilist   |  1 +
 39 files changed, 91 insertions(+), 8 deletions(-)

Comments

Carlos O'Donell July 4, 2022, 9:51 p.m. UTC | #1
On 6/24/22 15:59, Adhemerval Zanella wrote:
> It was added on Linux 5.12 (2a1867219c7b27f928e2545782b86daaf9ad50bd)
> to allow change the properties of a mount or a mount tree using file
> descriptors which the new mount api is based on.
> 
> Checked on x86_64-linux-gnu.

LGTM. Matches kernel API.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> ---
>  NEWS                                          |  8 ++---
>  sysdeps/unix/sysv/linux/Versions              |  1 +
>  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |  1 +
>  sysdeps/unix/sysv/linux/alpha/libc.abilist    |  1 +
>  sysdeps/unix/sysv/linux/arc/libc.abilist      |  1 +
>  sysdeps/unix/sysv/linux/arm/be/libc.abilist   |  1 +
>  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |  1 +
>  sysdeps/unix/sysv/linux/csky/libc.abilist     |  1 +
>  sysdeps/unix/sysv/linux/hppa/libc.abilist     |  1 +
>  sysdeps/unix/sysv/linux/i386/libc.abilist     |  1 +
>  sysdeps/unix/sysv/linux/ia64/libc.abilist     |  1 +
>  .../sysv/linux/m68k/coldfire/libc.abilist     |  1 +
>  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |  1 +
>  .../sysv/linux/microblaze/be/libc.abilist     |  1 +
>  .../sysv/linux/microblaze/le/libc.abilist     |  1 +
>  .../sysv/linux/mips/mips32/fpu/libc.abilist   |  1 +
>  .../sysv/linux/mips/mips32/nofpu/libc.abilist |  1 +
>  .../sysv/linux/mips/mips64/n32/libc.abilist   |  1 +
>  .../sysv/linux/mips/mips64/n64/libc.abilist   |  1 +
>  sysdeps/unix/sysv/linux/nios2/libc.abilist    |  1 +
>  sysdeps/unix/sysv/linux/or1k/libc.abilist     |  1 +
>  .../linux/powerpc/powerpc32/fpu/libc.abilist  |  1 +
>  .../powerpc/powerpc32/nofpu/libc.abilist      |  1 +
>  .../linux/powerpc/powerpc64/be/libc.abilist   |  1 +
>  .../linux/powerpc/powerpc64/le/libc.abilist   |  1 +
>  .../unix/sysv/linux/riscv/rv32/libc.abilist   |  1 +
>  .../unix/sysv/linux/riscv/rv64/libc.abilist   |  1 +
>  .../unix/sysv/linux/s390/s390-32/libc.abilist |  1 +
>  .../unix/sysv/linux/s390/s390-64/libc.abilist |  1 +
>  sysdeps/unix/sysv/linux/sh/be/libc.abilist    |  1 +
>  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |  1 +
>  .../sysv/linux/sparc/sparc32/libc.abilist     |  1 +
>  .../sysv/linux/sparc/sparc64/libc.abilist     |  1 +
>  sysdeps/unix/sysv/linux/sys/mount.h           | 22 ++++++++++++++
>  sysdeps/unix/sysv/linux/syscalls.list         |  1 +
>  sysdeps/unix/sysv/linux/tst-mount-consts.py   |  4 ++-
>  sysdeps/unix/sysv/linux/tst-mount.c           | 30 +++++++++++++++++--
>  .../unix/sysv/linux/x86_64/64/libc.abilist    |  1 +
>  .../unix/sysv/linux/x86_64/x32/libc.abilist   |  1 +
>  39 files changed, 91 insertions(+), 8 deletions(-)
> 
> diff --git a/NEWS b/NEWS
> index f52718aa77..3fe7c29644 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -41,10 +41,10 @@ Major new features:
>    have adverse impact.  It is incompatible with EDNS0 usage and DNSSEC
>    validation by applications.
>  
> -* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, and open_tree
> -  functions have been added.  They are part of the new Linux kernel mount
> -  APIs that allow applications to more flexibly configure and operate on
> -  filesystem mounts.  The new mount APIs are specifically designed to work
> +* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, open_tree,
> +  and mount_setattr have been added.  They are part of the new Linux kernel
> +  mount APIs that allow applications to more flexibly configure and operate
> +  on filesystem mounts.  The new mount APIs are specifically designed to work

OK.

>    with namespaces.
>  
>  Deprecated and removed features, and other changes affecting compatibility:
> diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
> index b70530ef40..65d2ceda2c 100644
> --- a/sysdeps/unix/sysv/linux/Versions
> +++ b/sysdeps/unix/sysv/linux/Versions
> @@ -305,6 +305,7 @@ libc {
>      fsopen;
>      fspick;
>      move_mount;
> +    mount_setattr;

OK.

>      open_tree;
>      pidfd_open;
>      pidfd_getfd;
> diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> index 2a666d8135..16d34b55c6 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
> @@ -2620,6 +2620,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> index 41bd7c1959..3f794bea0f 100644
> --- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
> @@ -2717,6 +2717,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
> index 198fdab2f7..072627810c 100644
> --- a/sysdeps/unix/sysv/linux/arc/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
> @@ -2381,6 +2381,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> index 6fd4e75df2..dbd5f07e6e 100644
> --- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
> @@ -500,6 +500,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> index 3ec572b50f..0f02d79faa 100644
> --- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
> @@ -497,6 +497,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
> index 94f3deb3e5..11d3b36a78 100644
> --- a/sysdeps/unix/sysv/linux/csky/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
> @@ -2656,6 +2656,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> index a7deaf3e26..5caa1321b1 100644
> --- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
> @@ -2605,6 +2605,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
> index 5f1a1bc4d0..276d7d5619 100644
> --- a/sysdeps/unix/sysv/linux/i386/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
> @@ -2789,6 +2789,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> index 1af8a55836..5e2249518e 100644
> --- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
> @@ -2555,6 +2555,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> index ad3a4b4008..802469a5b9 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
> @@ -501,6 +501,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> index 87e76f33a0..2f949397df 100644
> --- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
> @@ -2732,6 +2732,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> index 73df42c7aa..f63cc9cd4c 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
> @@ -2705,6 +2705,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> index 5c2e936547..88d2b707f9 100644
> --- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
> @@ -2702,6 +2702,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> index 45919d27d6..6c2bc0ee78 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
> @@ -2697,6 +2697,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> index 8321b0efac..09c9980d95 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
> @@ -2695,6 +2695,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> index c7198646d2..763920ea8f 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
> @@ -2703,6 +2703,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> index 8b3cca2a54..36d30558c1 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
> @@ -2606,6 +2606,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> index 2f1595bb35..e4383fe464 100644
> --- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
> @@ -2744,6 +2744,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
> index d1d4e12d12..735a8eea7e 100644
> --- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
> @@ -2127,6 +2127,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> index 50c9fadaf0..715dd31afe 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
> @@ -2759,6 +2759,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> index 8998a560cd..ac4b69e5fc 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
> @@ -2792,6 +2792,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> index bca46bdbe5..fd42f1bc11 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
> @@ -2514,6 +2514,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> index 97f6d96cd6..24688916dd 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
> @@ -2816,6 +2816,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> index f588745b28..536eddf9f1 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
> @@ -2383,6 +2383,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> index 1acf8a4c54..214b4f1c87 100644
> --- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
> @@ -2583,6 +2583,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> index 7c8b410f1a..bd738a4eb8 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
> @@ -2757,6 +2757,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> index ba9317ee01..170361236a 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
> @@ -2551,6 +2551,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> index 75fa8834f1..88fcd03300 100644
> --- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
> @@ -2612,6 +2612,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> index 4a4f8ff33f..f1115ef46d 100644
> --- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
> @@ -2609,6 +2609,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> index d26671dba8..6063da1acf 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
> @@ -2752,6 +2752,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> index 16c2a98ab5..780d2c0987 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
> @@ -2578,6 +2578,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
> index 534d05b3f5..f965986ba8 100644
> --- a/sysdeps/unix/sysv/linux/sys/mount.h
> +++ b/sysdeps/unix/sysv/linux/sys/mount.h
> @@ -23,6 +23,8 @@
>  
>  #include <fcntl.h>
>  #include <features.h>
> +#include <stdint.h>
> +#include <stddef.h>
>  #include <sys/ioctl.h>
>  
>  #define BLOCK_SIZE	1024
> @@ -155,6 +157,17 @@ enum
>  #define MOUNT_ATTR_NOSYMFOLLOW  0x00200000 /* Do not follow symlinks.  */
>  
>  
> +/* For mount_setattr.  */
> +struct mount_attr
> +{
> +  uint64_t attr_set;
> +  uint64_t attr_clr;
> +  uint64_t propagation;
> +  uint64_t userns_fd;
> +};

OK. Kernel uses __u64, but all names match and uint64_t is appropriate. Matches kernel.

> +
> +#define MOUNT_ATTR_SIZE_VER0    32 /* sizeof first published struct */

OK. Value 32 matches kernel.

> +
>  /* move_mount flags.  */
>  #define MOVE_MOUNT_F_SYMLINKS   0x00000001 /* Follow symlinks on from path */
>  #define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
> @@ -240,6 +253,15 @@ extern int fspick (int __dfd, const char *__path, unsigned int __flags)
>  extern int open_tree (int __dfd, const char *__filename, unsigned int __flags)
>    __THROW;
>  
> +/* Change the mount properties of the mount or an entire mount tree.  If
> +   PATH is a relative pathname, then it is interpreted relative to the
> +   directory referred to by the file descriptor dirfd.  Otherwise if DFD is
> +   the special value AT_FDCWD then PATH is interpreted relative to the current
> +   working directory of the calling process.  */
> +extern int mount_setattr (int __dfd, const char *__path, unsigned int __flags,
> +			  struct mount_attr *__uattr, size_t __usize)
> +  __THROW;

OK. Returns int error. 5 arguments. Signature is int, const char *, unsigned int, struct mount_attr *, size_t.
Matches kernel.

> +
>  __END_DECLS
>  
>  #endif /* _SYS_MOUNT_H */
> diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
> index 493e68b834..6420049e8b 100644
> --- a/sysdeps/unix/sysv/linux/syscalls.list
> +++ b/sysdeps/unix/sysv/linux/syscalls.list
> @@ -39,6 +39,7 @@ mincore		-	mincore		i:aUV	mincore
>  mlock		-	mlock		i:bU	mlock
>  mlockall	-	mlockall	i:i	mlockall
>  mount		EXTRA	mount		i:sssUp	__mount	mount
> +mount_setattr	EXTRA	mount_setattr	i:isUpU	mount_setattr

OK. i:isUpU.

>  move_mount	EXTRA	move_mount	i:isisU	move_mount
>  munlock		-	munlock		i:aU	munlock
>  munlockall	-	munlockall	i:	munlockall
> diff --git a/sysdeps/unix/sysv/linux/tst-mount-consts.py b/sysdeps/unix/sysv/linux/tst-mount-consts.py
> index 82ab18d963..a62f803123 100755
> --- a/sysdeps/unix/sysv/linux/tst-mount-consts.py
> +++ b/sysdeps/unix/sysv/linux/tst-mount-consts.py
> @@ -56,7 +56,9 @@ def main():
>          check('FSMOUNT_.*'),
>          # MOVE_MOUNT__MASK may vary depending of the kernel version.
>          check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK'),
> -        check('OPEN_TREE_*'))
> +        check('OPEN_TREE_*'),
> +        # MOUNT_ATTR_SIZE_VER0 is used for mount_setattr.
> +        check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0'))

OK. Test all 11 MOUNT_ATTR_.* constants except for MOUNT_ATTR_SIZE_VER0 which may vary.

>      sys.exit(status)
>  
>  if __name__ == '__main__':
> diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c
> index 12a665f950..502d7e3433 100644
> --- a/sysdeps/unix/sysv/linux/tst-mount.c
> +++ b/sysdeps/unix/sysv/linux/tst-mount.c
> @@ -23,6 +23,9 @@
>  #include <sys/wait.h>
>  #include <sys/mount.h>
>  
> +_Static_assert (sizeof (struct mount_attr) == MOUNT_ATTR_SIZE_VER0,
> +		"sizeof (struct mount_attr) != MOUNT_ATTR_SIZE_VER0");

OK. Check that the values match or error out.

> +
>  static void
>  subprocess (void)
>  {
> @@ -67,10 +70,31 @@ subprocess (void)
>  
>    TEST_COMPARE (open_tree (AT_FDCWD, "", 0), -1);
>    TEST_COMPARE (errno, ENOENT);
> +  int fd_tree = open_tree (AT_FDCWD, "/tmp",
> +			   OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
> +  TEST_VERIFY (fd_tree != -1);
> +
>    {
> -    int fd_tree = open_tree (AT_FDCWD, "/tmp",
> -			     OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
> -    TEST_VERIFY (fd_tree != -1);
> +    struct mount_attr attr =
> +    {
> +      .attr_set = MOUNT_ATTR_RDONLY,
> +    };
> +     mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
> +			   sizeof (attr));
> +    int r = mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
> +			   sizeof (attr));
> +    /* New mount API was added on 5.1, but mount_setattr on 5.12.  */
> +    if (r == -1)
> +      TEST_COMPARE (errno, ENOSYS);

OK.

> +    else
> +      {
> +	TEST_COMPARE (mount_setattr (-1, "", AT_EMPTY_PATH, &attr,
> +				     sizeof (attr)), -1);
> +	TEST_COMPARE (errno, EBADF);

OK. -1 for fd.

> +	TEST_COMPARE (mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
> +				     sizeof (attr) - 8), -1);
> +	TEST_COMPARE (errno, EINVAL);

OK. Invalid.

> +      }
>    }
>  
>    _exit (0);
> diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> index bd7c4ef801..56cad609fe 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
> @@ -2529,6 +2529,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
> diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> index 1c7f60b41a..2ed242a62d 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> +++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
> @@ -2635,6 +2635,7 @@ GLIBC_2.36 fsconfig F
>  GLIBC_2.36 fsmount F
>  GLIBC_2.36 fsopen F
>  GLIBC_2.36 fspick F
> +GLIBC_2.36 mount_setattr F
>  GLIBC_2.36 move_mount F
>  GLIBC_2.36 open_tree F
>  GLIBC_2.36 pidfd_getfd F
Andreas Schwab July 6, 2022, 9:25 a.m. UTC | #2
This is causing a conflict with <linux/mount.h>, breaking the build of
gcc.

In file included from /usr/include/linux/fs.h:19,
                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
/usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
   95 | enum fsconfig_command {
      |      ^~~~~~~~~~~~~~~~
In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
/usr/include/sys/mount.h:189:6: note: previous definition here
  189 | enum fsconfig_command
      |      ^~~~~~~~~~~~~~~~
/usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
  129 | struct mount_attr {
      |        ^~~~~~~~~~
/usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
  161 | struct mount_attr
      |        ^~~~~~~~~~
make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
Adhemerval Zanella Netto July 6, 2022, 12:21 p.m. UTC | #3
> On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
> 
> This is causing a conflict with <linux/mount.h>, breaking the build of
> gcc.
> 
> In file included from /usr/include/linux/fs.h:19,
>                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
> /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
>   95 | enum fsconfig_command {
>      |      ^~~~~~~~~~~~~~~~
> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
> /usr/include/sys/mount.h:189:6: note: previous definition here
>  189 | enum fsconfig_command
>      |      ^~~~~~~~~~~~~~~~
> /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
>  129 | struct mount_attr {
>      |        ^~~~~~~~~~
> /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
>  161 | struct mount_attr
>      |        ^~~~~~~~~~
> make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1

I am not sure how to handle it, glibc sys/mount.h should be a standalone
header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
kernel definition? Or check the kernel version and __has_include and use
kernel version instead?

> 
> -- 
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
Rudi Heitbaum July 10, 2022, 2:28 a.m. UTC | #4
I am facing the same issue compiling gcc-12.1.0. but since
linux-Add-fsconfig.patch also facing the following error with
systemd-251.2.

I was successfully able to compile systemd-251.2 by reverting:
- linux-Add-fsconfig.patch
- linux-Add-fspick.patch
- linux-Add-open_tree.patch
- linux-Add-tst-mount-to-check-for-Linux-new-mount-API.patch
- linux-Add-mount_setattr.patch
- stdlib-Implement-mbrtoc8-c8rtomb-and-the-char8_t-typ.patch
from 2a5b4f7a715921a232f67f6810268c6cd6aa0af2

Executing (target): ninja 
[100/868] Compiling C object src/basic/libbasic.a.p/chase-symlinks.c.o
FAILED: src/basic/libbasic.a.p/chase-symlinks.c.o 
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/chase-symlinks.c.o -MF src/basic/libbasic.a.p/chase-symlinks.c.o.d -o src/basic/libbasic.a.p/chase-symlinks.c.o -c ../src/basic/chase-symlinks.c
In file included from ../src/basic/stat-util.h:13,
                 from ../src/basic/chase-symlinks.h:7,
                 from ../src/basic/chase-symlinks.c:6:
../src/basic/missing_stat.h:39:8: error: redefinition of 'struct statx_timestamp'
   39 | struct statx_timestamp {
      |        ^~~~~~~~~~~~~~~
In file included from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/statx.h:31,
                 from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:465,
                 from ../src/basic/stat-util.h:7:
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:56:8: note: originally defined here
   56 | struct statx_timestamp {
      |        ^~~~~~~~~~~~~~~
../src/basic/missing_stat.h:45:8: error: redefinition of 'struct statx'
   45 | struct statx STATX_DEFINITION;
      |        ^~~~~
/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:99:8: note: originally defined here
   99 | struct statx {
      |        ^~~~~

Regards
Rudi

On Wed, Jul 06, 2022 at 09:21:32AM -0300, Adhemerval Zanella wrote:
> 
> > On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
> > 
> > This is causing a conflict with <linux/mount.h>, breaking the build of
> > gcc.
> > 
> > In file included from /usr/include/linux/fs.h:19,
> >                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
> > /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
> >   95 | enum fsconfig_command {
> >      |      ^~~~~~~~~~~~~~~~
> > In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
> > /usr/include/sys/mount.h:189:6: note: previous definition here
> >  189 | enum fsconfig_command
> >      |      ^~~~~~~~~~~~~~~~
> > /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
> >  129 | struct mount_attr {
> >      |        ^~~~~~~~~~
> > /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
> >  161 | struct mount_attr
> >      |        ^~~~~~~~~~
> > make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
> 
> I am not sure how to handle it, glibc sys/mount.h should be a standalone
> header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
> kernel definition? Or check the kernel version and __has_include and use
> kernel version instead?
> 
> > 
> > -- 
> > Andreas Schwab, SUSE Labs, schwab@suse.de
> > GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> > "And now for something completely different."
>
Andreas Schwab July 11, 2022, 8:30 a.m. UTC | #5
https://reviews.llvm.org/D129471
Florian Weimer July 11, 2022, 8:55 a.m. UTC | #6
* Adhemerval Zanella via Libc-alpha:

> I am not sure how to handle it, glibc sys/mount.h should be a standalone
> header.

Is it really necessary to keep <sys/mount.h> standalone?  It's not even
a standard interface, and we don't have conform tests for this header as
far as I can see.

So I think the usual __has_include approach should work here, too.

Thanks,
Florian
Adhemerval Zanella Netto July 11, 2022, 12:49 p.m. UTC | #7
> On 11 Jul 2022, at 05:55, Florian Weimer <fweimer@redhat.com> wrote:
> 
> * Adhemerval Zanella via Libc-alpha:
> 
>> I am not sure how to handle it, glibc sys/mount.h should be a standalone
>> header.
> 
> Is it really necessary to keep <sys/mount.h> standalone?  It's not even
> a standard interface, and we don't have conform tests for this header as
> far as I can see.
> 
> So I think the usual __has_include approach should work here, too.

The main problem is sys/mount.h defines interfaces for syscall added
in multiple releases.  It means that depending of the kernel version
used by the compiler we will need to add some defines (for instance
fsconfig_command).  There is also a small difference where glibc
header define the MS_* constant as a unnamed enum (not sure if this
affects C++ mangling).

I know that using kernel headers simplify some support, specially sync
with newer releases; but this also adds more complexity where we need
to handle integration outside glibc project.
Adhemerval Zanella Netto July 11, 2022, 12:51 p.m. UTC | #8
> On 9 Jul 2022, at 23:28, Rudi Heitbaum <rudi@heitbaum.com> wrote:
> 
> I am facing the same issue compiling gcc-12.1.0. but since
> linux-Add-fsconfig.patch also facing the following error with
> systemd-251.2.
> 
> I was successfully able to compile systemd-251.2 by reverting:
> - linux-Add-fsconfig.patch
> - linux-Add-fspick.patch
> - linux-Add-open_tree.patch
> - linux-Add-tst-mount-to-check-for-Linux-new-mount-API.patch
> - linux-Add-mount_setattr.patch
> - stdlib-Implement-mbrtoc8-c8rtomb-and-the-char8_t-typ.patch
> from 2a5b4f7a715921a232f67f6810268c6cd6aa0af2

Which patch exactly broke the build, because from the logs is hard to
tell exactly (specially because it should not interfere with statx
definition)?

> 
> Executing (target): ninja 
> [100/868] Compiling C object src/basic/libbasic.a.p/chase-symlinks.c.o
> FAILED: src/basic/libbasic.a.p/chase-symlinks.c.o 
> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/chase-symlinks.c.o -MF src/basic/libbasic.a.p/chase-symlinks.c.o.d -o src/basic/libbasic.a.p/chase-symlinks.c.o -c ../src/basic/chase-symlinks.c
> In file included from ../src/basic/stat-util.h:13,
>                 from ../src/basic/chase-symlinks.h:7,
>                 from ../src/basic/chase-symlinks.c:6:
> ../src/basic/missing_stat.h:39:8: error: redefinition of 'struct statx_timestamp'
>   39 | struct statx_timestamp {
>      |        ^~~~~~~~~~~~~~~
> In file included from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/statx.h:31,
>                 from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:465,
>                 from ../src/basic/stat-util.h:7:
> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:56:8: note: originally defined here
>   56 | struct statx_timestamp {
>      |        ^~~~~~~~~~~~~~~
> ../src/basic/missing_stat.h:45:8: error: redefinition of 'struct statx'
>   45 | struct statx STATX_DEFINITION;
>      |        ^~~~~
> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:99:8: note: originally defined here
>   99 | struct statx {
>      |        ^~~~~
> 
> Regards
> Rudi
> 
> On Wed, Jul 06, 2022 at 09:21:32AM -0300, Adhemerval Zanella wrote:
>> 
>>> On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
>>> 
>>> This is causing a conflict with <linux/mount.h>, breaking the build of
>>> gcc.
>>> 
>>> In file included from /usr/include/linux/fs.h:19,
>>>                from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
>>> /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
>>>  95 | enum fsconfig_command {
>>>     |      ^~~~~~~~~~~~~~~~
>>> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
>>> /usr/include/sys/mount.h:189:6: note: previous definition here
>>> 189 | enum fsconfig_command
>>>     |      ^~~~~~~~~~~~~~~~
>>> /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
>>> 129 | struct mount_attr {
>>>     |        ^~~~~~~~~~
>>> /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
>>> 161 | struct mount_attr
>>>     |        ^~~~~~~~~~
>>> make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
>> 
>> I am not sure how to handle it, glibc sys/mount.h should be a standalone
>> header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
>> kernel definition? Or check the kernel version and __has_include and use
>> kernel version instead?
>> 
>>> 
>>> -- 
>>> Andreas Schwab, SUSE Labs, schwab@suse.de
>>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
>>> "And now for something completely different."
>>
Florian Weimer July 11, 2022, 12:53 p.m. UTC | #9
* Adhemerval Zanella:

>> On 11 Jul 2022, at 05:55, Florian Weimer <fweimer@redhat.com> wrote:
>> 
>> * Adhemerval Zanella via Libc-alpha:
>> 
>>> I am not sure how to handle it, glibc sys/mount.h should be a standalone
>>> header.
>> 
>> Is it really necessary to keep <sys/mount.h> standalone?  It's not even
>> a standard interface, and we don't have conform tests for this header as
>> far as I can see.
>> 
>> So I think the usual __has_include approach should work here, too.
>
> The main problem is sys/mount.h defines interfaces for syscall added
> in multiple releases.  It means that depending of the kernel version
> used by the compiler we will need to add some defines (for instance
> fsconfig_command).  There is also a small difference where glibc
> header define the MS_* constant as a unnamed enum (not sure if this
> affects C++ mangling).

You are right, I had missed that.

> I know that using kernel headers simplify some support, specially sync
> with newer releases; but this also adds more complexity where we need
> to handle integration outside glibc project.

For openat2, we got a separate header.  Maybe we can request that for
the fsmount interfaces, too?  Than we can do the usual thing just for
<linux/fsmount.h>.  <linux/mount.h> can still include <linux/fsmount.h>,
so the change would be transparent.

Thanks,
Florian
Rudi Heitbaum July 11, 2022, 1:13 p.m. UTC | #10
Hi Adhemerval,

linux-Add-fsconfig.patch broke the build, I reverted the others for a
clean revert.
Just adding linux-Add-fsconfig.patch back causes the systemd build to fail.

Thanks
Rudi

On Mon, 11 Jul 2022 at 22:51, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> > On 9 Jul 2022, at 23:28, Rudi Heitbaum <rudi@heitbaum.com> wrote:
> >
> > I am facing the same issue compiling gcc-12.1.0. but since
> > linux-Add-fsconfig.patch also facing the following error with
> > systemd-251.2.
> >
> > I was successfully able to compile systemd-251.2 by reverting:
> > - linux-Add-fsconfig.patch
> > - linux-Add-fspick.patch
> > - linux-Add-open_tree.patch
> > - linux-Add-tst-mount-to-check-for-Linux-new-mount-API.patch
> > - linux-Add-mount_setattr.patch
> > - stdlib-Implement-mbrtoc8-c8rtomb-and-the-char8_t-typ.patch
> > from 2a5b4f7a715921a232f67f6810268c6cd6aa0af2
>
> Which patch exactly broke the build, because from the logs is hard to
> tell exactly (specially because it should not interfere with statx
> definition)?
>
> >
> > Executing (target): ninja
> > [100/868] Compiling C object src/basic/libbasic.a.p/chase-symlinks.c.o
> > FAILED: src/basic/libbasic.a.p/chase-symlinks.c.o
> > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/chase-symlinks.c.o -MF src/basic/libbasic.a.p/chase-symlinks.c.o.d -o src/basic/libbasic.a.p/chase-symlinks.c.o -c ../src/basic/chase-symlinks.c
> > In file included from ../src/basic/stat-util.h:13,
> >                 from ../src/basic/chase-symlinks.h:7,
> >                 from ../src/basic/chase-symlinks.c:6:
> > ../src/basic/missing_stat.h:39:8: error: redefinition of 'struct statx_timestamp'
> >   39 | struct statx_timestamp {
> >      |        ^~~~~~~~~~~~~~~
> > In file included from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/statx.h:31,
> >                 from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:465,
> >                 from ../src/basic/stat-util.h:7:
> > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:56:8: note: originally defined here
> >   56 | struct statx_timestamp {
> >      |        ^~~~~~~~~~~~~~~
> > ../src/basic/missing_stat.h:45:8: error: redefinition of 'struct statx'
> >   45 | struct statx STATX_DEFINITION;
> >      |        ^~~~~
> > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:99:8: note: originally defined here
> >   99 | struct statx {
> >      |        ^~~~~
> >
> > Regards
> > Rudi
> >
> > On Wed, Jul 06, 2022 at 09:21:32AM -0300, Adhemerval Zanella wrote:
> >>
> >>> On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
> >>>
> >>> This is causing a conflict with <linux/mount.h>, breaking the build of
> >>> gcc.
> >>>
> >>> In file included from /usr/include/linux/fs.h:19,
> >>>                from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
> >>> /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
> >>>  95 | enum fsconfig_command {
> >>>     |      ^~~~~~~~~~~~~~~~
> >>> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
> >>> /usr/include/sys/mount.h:189:6: note: previous definition here
> >>> 189 | enum fsconfig_command
> >>>     |      ^~~~~~~~~~~~~~~~
> >>> /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
> >>> 129 | struct mount_attr {
> >>>     |        ^~~~~~~~~~
> >>> /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
> >>> 161 | struct mount_attr
> >>>     |        ^~~~~~~~~~
> >>> make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
> >>
> >> I am not sure how to handle it, glibc sys/mount.h should be a standalone
> >> header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
> >> kernel definition? Or check the kernel version and __has_include and use
> >> kernel version instead?
> >>
> >>>
> >>> --
> >>> Andreas Schwab, SUSE Labs, schwab@suse.de
> >>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> >>> "And now for something completely different."
> >>
>
Rudi Heitbaum July 12, 2022, 1:11 p.m. UTC | #11
Hi Adhemerval,

I tracked down the build error with systemd being the
HAVE_STRUCT_STATX was not being set in the meson.build - due to the
conflict occurring with the inclusion of linux/fs.h.

The fix was to drop linux/fs.h (the same as in gcc libsanitizer.) I'll
raise an issue on the systemd GitHub.
The following patch (whilst not tested on < glibc 2.36) allowed the
compile to succeed.)

--- a/meson.build       2022-07-12 12:20:25.366313151 +0000
+++ b/meson.build       2022-07-12 12:46:19.276121413 +0000
@@ -479,7 +479,6 @@
 #include <uchar.h>
 #include <sys/mount.h>
 #include <sys/stat.h>
-#include <linux/fs.h>
 '''

 foreach decl : ['char16_t',
--- a/src/shared/mount-util.c   2022-06-02 18:07:11.000000000 +0000
+++ b/src/shared/mount-util.c   2022-07-12 12:52:46.644787385 +0000
@@ -7,7 +7,6 @@
 #include <sys/statvfs.h>
 #include <unistd.h>
 #include <linux/loop.h>
-#include <linux/fs.h>

 #include "alloc-util.h"
 #include "chase-symlinks.h"
--- a/src/core/namespace.c      2022-06-02 18:07:11.000000000 +0000
+++ b/src/core/namespace.c      2022-07-12 12:56:35.807502035 +0000
@@ -6,7 +6,6 @@
 #include <stdio.h>
 #include <sys/mount.h>
 #include <unistd.h>
-#include <linux/fs.h>

 #include "alloc-util.h"
 #include "base-filesystem.h"

On Mon, 11 Jul 2022 at 23:13, Rudi Heitbaum <rudi@heitbaum.com> wrote:
>
> Hi Adhemerval,
>
> linux-Add-fsconfig.patch broke the build, I reverted the others for a
> clean revert.
> Just adding linux-Add-fsconfig.patch back causes the systemd build to fail.
>
> Thanks
> Rudi
>
> On Mon, 11 Jul 2022 at 22:51, Adhemerval Zanella
> <adhemerval.zanella@linaro.org> wrote:
> >
> >
> >
> > > On 9 Jul 2022, at 23:28, Rudi Heitbaum <rudi@heitbaum.com> wrote:
> > >
> > > I am facing the same issue compiling gcc-12.1.0. but since
> > > linux-Add-fsconfig.patch also facing the following error with
> > > systemd-251.2.
> > >
> > > I was successfully able to compile systemd-251.2 by reverting:
> > > - linux-Add-fsconfig.patch
> > > - linux-Add-fspick.patch
> > > - linux-Add-open_tree.patch
> > > - linux-Add-tst-mount-to-check-for-Linux-new-mount-API.patch
> > > - linux-Add-mount_setattr.patch
> > > - stdlib-Implement-mbrtoc8-c8rtomb-and-the-char8_t-typ.patch
> > > from 2a5b4f7a715921a232f67f6810268c6cd6aa0af2
> >
> > Which patch exactly broke the build, because from the logs is hard to
> > tell exactly (specially because it should not interfere with statx
> > definition)?
> >
> > >
> > > Executing (target): ninja
> > > [100/868] Compiling C object src/basic/libbasic.a.p/chase-symlinks.c.o
> > > FAILED: src/basic/libbasic.a.p/chase-symlinks.c.o
> > > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/chase-symlinks.c.o -MF src/basic/libbasic.a.p/chase-symlinks.c.o.d -o src/basic/libbasic.a.p/chase-symlinks.c.o -c ../src/basic/chase-symlinks.c
> > > In file included from ../src/basic/stat-util.h:13,
> > >                 from ../src/basic/chase-symlinks.h:7,
> > >                 from ../src/basic/chase-symlinks.c:6:
> > > ../src/basic/missing_stat.h:39:8: error: redefinition of 'struct statx_timestamp'
> > >   39 | struct statx_timestamp {
> > >      |        ^~~~~~~~~~~~~~~
> > > In file included from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/statx.h:31,
> > >                 from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:465,
> > >                 from ../src/basic/stat-util.h:7:
> > > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:56:8: note: originally defined here
> > >   56 | struct statx_timestamp {
> > >      |        ^~~~~~~~~~~~~~~
> > > ../src/basic/missing_stat.h:45:8: error: redefinition of 'struct statx'
> > >   45 | struct statx STATX_DEFINITION;
> > >      |        ^~~~~
> > > /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:99:8: note: originally defined here
> > >   99 | struct statx {
> > >      |        ^~~~~
> > >
> > > Regards
> > > Rudi
> > >
> > > On Wed, Jul 06, 2022 at 09:21:32AM -0300, Adhemerval Zanella wrote:
> > >>
> > >>> On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
> > >>>
> > >>> This is causing a conflict with <linux/mount.h>, breaking the build of
> > >>> gcc.
> > >>>
> > >>> In file included from /usr/include/linux/fs.h:19,
> > >>>                from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
> > >>> /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
> > >>>  95 | enum fsconfig_command {
> > >>>     |      ^~~~~~~~~~~~~~~~
> > >>> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
> > >>> /usr/include/sys/mount.h:189:6: note: previous definition here
> > >>> 189 | enum fsconfig_command
> > >>>     |      ^~~~~~~~~~~~~~~~
> > >>> /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
> > >>> 129 | struct mount_attr {
> > >>>     |        ^~~~~~~~~~
> > >>> /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
> > >>> 161 | struct mount_attr
> > >>>     |        ^~~~~~~~~~
> > >>> make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
> > >>
> > >> I am not sure how to handle it, glibc sys/mount.h should be a standalone
> > >> header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
> > >> kernel definition? Or check the kernel version and __has_include and use
> > >> kernel version instead?
> > >>
> > >>>
> > >>> --
> > >>> Andreas Schwab, SUSE Labs, schwab@suse.de
> > >>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> > >>> "And now for something completely different."
> > >>
> >
Adhemerval Zanella Netto July 12, 2022, 3:33 p.m. UTC | #12
Hi Rudi,

Thanks for track this down, it does seems a better alternative to avoid
mixing glibc and Linux headers.  Even though we try to make them
compatible, it means implementation detais (such internal defines)
or extra boilerplate code (such as has_include) needs to be added
to handle it.

On 12/07/22 10:11, Rudi Heitbaum wrote:
> Hi Adhemerval,
> 
> I tracked down the build error with systemd being the
> HAVE_STRUCT_STATX was not being set in the meson.build - due to the
> conflict occurring with the inclusion of linux/fs.h.
> 
> The fix was to drop linux/fs.h (the same as in gcc libsanitizer.) I'll
> raise an issue on the systemd GitHub.
> The following patch (whilst not tested on < glibc 2.36) allowed the
> compile to succeed.)
> 
> --- a/meson.build       2022-07-12 12:20:25.366313151 +0000
> +++ b/meson.build       2022-07-12 12:46:19.276121413 +0000
> @@ -479,7 +479,6 @@
>   #include <uchar.h>
>   #include <sys/mount.h>
>   #include <sys/stat.h>
> -#include <linux/fs.h>
>   '''
> 
>   foreach decl : ['char16_t',
> --- a/src/shared/mount-util.c   2022-06-02 18:07:11.000000000 +0000
> +++ b/src/shared/mount-util.c   2022-07-12 12:52:46.644787385 +0000
> @@ -7,7 +7,6 @@
>   #include <sys/statvfs.h>
>   #include <unistd.h>
>   #include <linux/loop.h>
> -#include <linux/fs.h>
> 
>   #include "alloc-util.h"
>   #include "chase-symlinks.h"
> --- a/src/core/namespace.c      2022-06-02 18:07:11.000000000 +0000
> +++ b/src/core/namespace.c      2022-07-12 12:56:35.807502035 +0000
> @@ -6,7 +6,6 @@
>   #include <stdio.h>
>   #include <sys/mount.h>
>   #include <unistd.h>
> -#include <linux/fs.h>
> 
>   #include "alloc-util.h"
>   #include "base-filesystem.h"
> 
> On Mon, 11 Jul 2022 at 23:13, Rudi Heitbaum <rudi@heitbaum.com> wrote:
>>
>> Hi Adhemerval,
>>
>> linux-Add-fsconfig.patch broke the build, I reverted the others for a
>> clean revert.
>> Just adding linux-Add-fsconfig.patch back causes the systemd build to fail.
>>
>> Thanks
>> Rudi
>>
>> On Mon, 11 Jul 2022 at 22:51, Adhemerval Zanella
>> <adhemerval.zanella@linaro.org> wrote:
>>>
>>>
>>>
>>>> On 9 Jul 2022, at 23:28, Rudi Heitbaum <rudi@heitbaum.com> wrote:
>>>>
>>>> I am facing the same issue compiling gcc-12.1.0. but since
>>>> linux-Add-fsconfig.patch also facing the following error with
>>>> systemd-251.2.
>>>>
>>>> I was successfully able to compile systemd-251.2 by reverting:
>>>> - linux-Add-fsconfig.patch
>>>> - linux-Add-fspick.patch
>>>> - linux-Add-open_tree.patch
>>>> - linux-Add-tst-mount-to-check-for-Linux-new-mount-API.patch
>>>> - linux-Add-mount_setattr.patch
>>>> - stdlib-Implement-mbrtoc8-c8rtomb-and-the-char8_t-typ.patch
>>>> from 2a5b4f7a715921a232f67f6810268c6cd6aa0af2
>>>
>>> Which patch exactly broke the build, because from the logs is hard to
>>> tell exactly (specially because it should not interfere with statx
>>> definition)?
>>>
>>>>
>>>> Executing (target): ninja
>>>> [100/868] Compiling C object src/basic/libbasic.a.p/chase-symlinks.c.o
>>>> FAILED: src/basic/libbasic.a.p/chase-symlinks.c.o
>>>> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/bin/x86_64-libreelec-linux-gnu-gcc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I. -I.. -I/var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -ffunction-sections -fdata-sections -Werror=shadow -include config.h -march=x86-64-v3 -Wall -pipe -O2 -fomit-frame-pointer -DNDEBUG -fno-schedule-insns -fno-schedule-insns2 -Wno-format-truncation -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/chase-symlinks.c.o -MF src/basic/libbasic.a.p/chase-symlinks.c.o.d -o src/basic/libbasic.a.p/chase-symlinks.c.o -c ../src/basic/chase-symlinks.c
>>>> In file included from ../src/basic/stat-util.h:13,
>>>>                  from ../src/basic/chase-symlinks.h:7,
>>>>                  from ../src/basic/chase-symlinks.c:6:
>>>> ../src/basic/missing_stat.h:39:8: error: redefinition of 'struct statx_timestamp'
>>>>    39 | struct statx_timestamp {
>>>>       |        ^~~~~~~~~~~~~~~
>>>> In file included from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/bits/statx.h:31,
>>>>                  from /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/sys/stat.h:465,
>>>>                  from ../src/basic/stat-util.h:7:
>>>> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:56:8: note: originally defined here
>>>>    56 | struct statx_timestamp {
>>>>       |        ^~~~~~~~~~~~~~~
>>>> ../src/basic/missing_stat.h:45:8: error: redefinition of 'struct statx'
>>>>    45 | struct statx STATX_DEFINITION;
>>>>       |        ^~~~~
>>>> /var/media/DATA/home-rudi/LibreELEC.tv/build.LibreELEC-Generic.x86_64-11.0-devel/toolchain/x86_64-libreelec-linux-gnu/sysroot/usr/include/linux/stat.h:99:8: note: originally defined here
>>>>    99 | struct statx {
>>>>       |        ^~~~~
>>>>
>>>> Regards
>>>> Rudi
>>>>
>>>> On Wed, Jul 06, 2022 at 09:21:32AM -0300, Adhemerval Zanella wrote:
>>>>>
>>>>>> On 6 Jul 2022, at 06:25, Andreas Schwab <schwab@suse.de> wrote:
>>>>>>
>>>>>> This is causing a conflict with <linux/mount.h>, breaking the build of
>>>>>> gcc.
>>>>>>
>>>>>> In file included from /usr/include/linux/fs.h:19,
>>>>>>                 from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:76:
>>>>>> /usr/include/linux/mount.h:95:6: error: multiple definition of 'enum fsconfig_command'
>>>>>>   95 | enum fsconfig_command {
>>>>>>      |      ^~~~~~~~~~~~~~~~
>>>>>> In file included from ../../../../libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp:63:
>>>>>> /usr/include/sys/mount.h:189:6: note: previous definition here
>>>>>> 189 | enum fsconfig_command
>>>>>>      |      ^~~~~~~~~~~~~~~~
>>>>>> /usr/include/linux/mount.h:129:8: error: redefinition of 'struct mount_attr'
>>>>>> 129 | struct mount_attr {
>>>>>>      |        ^~~~~~~~~~
>>>>>> /usr/include/sys/mount.h:161:8: note: previous definition of 'struct mount_attr'
>>>>>> 161 | struct mount_attr
>>>>>>      |        ^~~~~~~~~~
>>>>>> make[4]: *** [Makefile:617: sanitizer_platform_limits_posix.lo] Error 1
>>>>>
>>>>> I am not sure how to handle it, glibc sys/mount.h should be a standalone
>>>>> header.  Maybe check if _UAPI_LINUX_MOUNT_H is defined so to use the
>>>>> kernel definition? Or check the kernel version and __has_include and use
>>>>> kernel version instead?
>>>>>
>>>>>>
>>>>>> --
>>>>>> Andreas Schwab, SUSE Labs, schwab@suse.de
>>>>>> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
>>>>>> "And now for something completely different."
>>>>>
>>>
Andreas Schwab July 25, 2022, 3:08 p.m. UTC | #13
There are quite a few packages that fail to build now.
Rudi Heitbaum July 26, 2022, 12:28 a.m. UTC | #14
Hi All,

As an fyi - LibreELEC (JeOS) is now building and run tested with the
2022-07-22 glibc 2.35.9000 ready for 2.36 release.

These were the changes required.

upstream patches available:
- gcc: enable compile with glibc 2.36
- systemd: enable compile with glibc 2.36

downstream patches:
- hdparm: enable compile with glibc 2.36
- syslinux: enable compile with glibc 2.36
- efivar: enable compile with glibc 2.36
- stress-ng: update to 0.14.03 and enable compile with glibc 2.36

https://github.com/LibreELEC/LibreELEC.tv/pull/6684

On Tue, 26 Jul 2022 at 01:09, Andreas Schwab via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> There are quite a few packages that fail to build now.
>
> --
> Andreas Schwab, SUSE Labs, schwab@suse.de
> GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
> "And now for something completely different."
diff mbox series

Patch

diff --git a/NEWS b/NEWS
index f52718aa77..3fe7c29644 100644
--- a/NEWS
+++ b/NEWS
@@ -41,10 +41,10 @@  Major new features:
   have adverse impact.  It is incompatible with EDNS0 usage and DNSSEC
   validation by applications.
 
-* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, and open_tree
-  functions have been added.  They are part of the new Linux kernel mount
-  APIs that allow applications to more flexibly configure and operate on
-  filesystem mounts.  The new mount APIs are specifically designed to work
+* On Linux, the fsopen, fsmount, move_mount, fsconfig, fspick, open_tree,
+  and mount_setattr have been added.  They are part of the new Linux kernel
+  mount APIs that allow applications to more flexibly configure and operate
+  on filesystem mounts.  The new mount APIs are specifically designed to work
   with namespaces.
 
 Deprecated and removed features, and other changes affecting compatibility:
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions
index b70530ef40..65d2ceda2c 100644
--- a/sysdeps/unix/sysv/linux/Versions
+++ b/sysdeps/unix/sysv/linux/Versions
@@ -305,6 +305,7 @@  libc {
     fsopen;
     fspick;
     move_mount;
+    mount_setattr;
     open_tree;
     pidfd_open;
     pidfd_getfd;
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc.abilist b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
index 2a666d8135..16d34b55c6 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libc.abilist
@@ -2620,6 +2620,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/alpha/libc.abilist b/sysdeps/unix/sysv/linux/alpha/libc.abilist
index 41bd7c1959..3f794bea0f 100644
--- a/sysdeps/unix/sysv/linux/alpha/libc.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libc.abilist
@@ -2717,6 +2717,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/arc/libc.abilist b/sysdeps/unix/sysv/linux/arc/libc.abilist
index 198fdab2f7..072627810c 100644
--- a/sysdeps/unix/sysv/linux/arc/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arc/libc.abilist
@@ -2381,6 +2381,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libc.abilist b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
index 6fd4e75df2..dbd5f07e6e 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libc.abilist
@@ -500,6 +500,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libc.abilist b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
index 3ec572b50f..0f02d79faa 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libc.abilist
@@ -497,6 +497,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/csky/libc.abilist b/sysdeps/unix/sysv/linux/csky/libc.abilist
index 94f3deb3e5..11d3b36a78 100644
--- a/sysdeps/unix/sysv/linux/csky/libc.abilist
+++ b/sysdeps/unix/sysv/linux/csky/libc.abilist
@@ -2656,6 +2656,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/hppa/libc.abilist b/sysdeps/unix/sysv/linux/hppa/libc.abilist
index a7deaf3e26..5caa1321b1 100644
--- a/sysdeps/unix/sysv/linux/hppa/libc.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libc.abilist
@@ -2605,6 +2605,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/i386/libc.abilist b/sysdeps/unix/sysv/linux/i386/libc.abilist
index 5f1a1bc4d0..276d7d5619 100644
--- a/sysdeps/unix/sysv/linux/i386/libc.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libc.abilist
@@ -2789,6 +2789,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/ia64/libc.abilist b/sysdeps/unix/sysv/linux/ia64/libc.abilist
index 1af8a55836..5e2249518e 100644
--- a/sysdeps/unix/sysv/linux/ia64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/ia64/libc.abilist
@@ -2555,6 +2555,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
index ad3a4b4008..802469a5b9 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
@@ -501,6 +501,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
index 87e76f33a0..2f949397df 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
@@ -2732,6 +2732,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
index 73df42c7aa..f63cc9cd4c 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libc.abilist
@@ -2705,6 +2705,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
index 5c2e936547..88d2b707f9 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libc.abilist
@@ -2702,6 +2702,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
index 45919d27d6..6c2bc0ee78 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
@@ -2697,6 +2697,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
index 8321b0efac..09c9980d95 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
@@ -2695,6 +2695,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
index c7198646d2..763920ea8f 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
@@ -2703,6 +2703,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
index 8b3cca2a54..36d30558c1 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
@@ -2606,6 +2606,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/nios2/libc.abilist b/sysdeps/unix/sysv/linux/nios2/libc.abilist
index 2f1595bb35..e4383fe464 100644
--- a/sysdeps/unix/sysv/linux/nios2/libc.abilist
+++ b/sysdeps/unix/sysv/linux/nios2/libc.abilist
@@ -2744,6 +2744,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/or1k/libc.abilist b/sysdeps/unix/sysv/linux/or1k/libc.abilist
index d1d4e12d12..735a8eea7e 100644
--- a/sysdeps/unix/sysv/linux/or1k/libc.abilist
+++ b/sysdeps/unix/sysv/linux/or1k/libc.abilist
@@ -2127,6 +2127,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
index 50c9fadaf0..715dd31afe 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
@@ -2759,6 +2759,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
index 8998a560cd..ac4b69e5fc 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
@@ -2792,6 +2792,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
index bca46bdbe5..fd42f1bc11 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libc.abilist
@@ -2514,6 +2514,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
index 97f6d96cd6..24688916dd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libc.abilist
@@ -2816,6 +2816,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
index f588745b28..536eddf9f1 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv32/libc.abilist
@@ -2383,6 +2383,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
index 1acf8a4c54..214b4f1c87 100644
--- a/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/riscv/rv64/libc.abilist
@@ -2583,6 +2583,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
index 7c8b410f1a..bd738a4eb8 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
@@ -2757,6 +2757,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
index ba9317ee01..170361236a 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
@@ -2551,6 +2551,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libc.abilist b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
index 75fa8834f1..88fcd03300 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libc.abilist
@@ -2612,6 +2612,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libc.abilist b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
index 4a4f8ff33f..f1115ef46d 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libc.abilist
@@ -2609,6 +2609,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
index d26671dba8..6063da1acf 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
@@ -2752,6 +2752,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
index 16c2a98ab5..780d2c0987 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
@@ -2578,6 +2578,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/sys/mount.h b/sysdeps/unix/sysv/linux/sys/mount.h
index 534d05b3f5..f965986ba8 100644
--- a/sysdeps/unix/sysv/linux/sys/mount.h
+++ b/sysdeps/unix/sysv/linux/sys/mount.h
@@ -23,6 +23,8 @@ 
 
 #include <fcntl.h>
 #include <features.h>
+#include <stdint.h>
+#include <stddef.h>
 #include <sys/ioctl.h>
 
 #define BLOCK_SIZE	1024
@@ -155,6 +157,17 @@  enum
 #define MOUNT_ATTR_NOSYMFOLLOW  0x00200000 /* Do not follow symlinks.  */
 
 
+/* For mount_setattr.  */
+struct mount_attr
+{
+  uint64_t attr_set;
+  uint64_t attr_clr;
+  uint64_t propagation;
+  uint64_t userns_fd;
+};
+
+#define MOUNT_ATTR_SIZE_VER0    32 /* sizeof first published struct */
+
 /* move_mount flags.  */
 #define MOVE_MOUNT_F_SYMLINKS   0x00000001 /* Follow symlinks on from path */
 #define MOVE_MOUNT_F_AUTOMOUNTS 0x00000002 /* Follow automounts on from path */
@@ -240,6 +253,15 @@  extern int fspick (int __dfd, const char *__path, unsigned int __flags)
 extern int open_tree (int __dfd, const char *__filename, unsigned int __flags)
   __THROW;
 
+/* Change the mount properties of the mount or an entire mount tree.  If
+   PATH is a relative pathname, then it is interpreted relative to the
+   directory referred to by the file descriptor dirfd.  Otherwise if DFD is
+   the special value AT_FDCWD then PATH is interpreted relative to the current
+   working directory of the calling process.  */
+extern int mount_setattr (int __dfd, const char *__path, unsigned int __flags,
+			  struct mount_attr *__uattr, size_t __usize)
+  __THROW;
+
 __END_DECLS
 
 #endif /* _SYS_MOUNT_H */
diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list
index 493e68b834..6420049e8b 100644
--- a/sysdeps/unix/sysv/linux/syscalls.list
+++ b/sysdeps/unix/sysv/linux/syscalls.list
@@ -39,6 +39,7 @@  mincore		-	mincore		i:aUV	mincore
 mlock		-	mlock		i:bU	mlock
 mlockall	-	mlockall	i:i	mlockall
 mount		EXTRA	mount		i:sssUp	__mount	mount
+mount_setattr	EXTRA	mount_setattr	i:isUpU	mount_setattr
 move_mount	EXTRA	move_mount	i:isisU	move_mount
 munlock		-	munlock		i:aU	munlock
 munlockall	-	munlockall	i:	munlockall
diff --git a/sysdeps/unix/sysv/linux/tst-mount-consts.py b/sysdeps/unix/sysv/linux/tst-mount-consts.py
index 82ab18d963..a62f803123 100755
--- a/sysdeps/unix/sysv/linux/tst-mount-consts.py
+++ b/sysdeps/unix/sysv/linux/tst-mount-consts.py
@@ -56,7 +56,9 @@  def main():
         check('FSMOUNT_.*'),
         # MOVE_MOUNT__MASK may vary depending of the kernel version.
         check('MOVE_MOUNT_.*', 'MOVE_MOUNT__MASK'),
-        check('OPEN_TREE_*'))
+        check('OPEN_TREE_*'),
+        # MOUNT_ATTR_SIZE_VER0 is used for mount_setattr.
+        check('MOUNT_ATTR_.*', 'MOUNT_ATTR_SIZE_VER0'))
     sys.exit(status)
 
 if __name__ == '__main__':
diff --git a/sysdeps/unix/sysv/linux/tst-mount.c b/sysdeps/unix/sysv/linux/tst-mount.c
index 12a665f950..502d7e3433 100644
--- a/sysdeps/unix/sysv/linux/tst-mount.c
+++ b/sysdeps/unix/sysv/linux/tst-mount.c
@@ -23,6 +23,9 @@ 
 #include <sys/wait.h>
 #include <sys/mount.h>
 
+_Static_assert (sizeof (struct mount_attr) == MOUNT_ATTR_SIZE_VER0,
+		"sizeof (struct mount_attr) != MOUNT_ATTR_SIZE_VER0");
+
 static void
 subprocess (void)
 {
@@ -67,10 +70,31 @@  subprocess (void)
 
   TEST_COMPARE (open_tree (AT_FDCWD, "", 0), -1);
   TEST_COMPARE (errno, ENOENT);
+  int fd_tree = open_tree (AT_FDCWD, "/tmp",
+			   OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
+  TEST_VERIFY (fd_tree != -1);
+
   {
-    int fd_tree = open_tree (AT_FDCWD, "/tmp",
-			     OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC);
-    TEST_VERIFY (fd_tree != -1);
+    struct mount_attr attr =
+    {
+      .attr_set = MOUNT_ATTR_RDONLY,
+    };
+     mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+			   sizeof (attr));
+    int r = mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+			   sizeof (attr));
+    /* New mount API was added on 5.1, but mount_setattr on 5.12.  */
+    if (r == -1)
+      TEST_COMPARE (errno, ENOSYS);
+    else
+      {
+	TEST_COMPARE (mount_setattr (-1, "", AT_EMPTY_PATH, &attr,
+				     sizeof (attr)), -1);
+	TEST_COMPARE (errno, EBADF);
+	TEST_COMPARE (mount_setattr (fd_tree, "", AT_EMPTY_PATH, &attr,
+				     sizeof (attr) - 8), -1);
+	TEST_COMPARE (errno, EINVAL);
+      }
   }
 
   _exit (0);
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
index bd7c4ef801..56cad609fe 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
@@ -2529,6 +2529,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
index 1c7f60b41a..2ed242a62d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist
@@ -2635,6 +2635,7 @@  GLIBC_2.36 fsconfig F
 GLIBC_2.36 fsmount F
 GLIBC_2.36 fsopen F
 GLIBC_2.36 fspick F
+GLIBC_2.36 mount_setattr F
 GLIBC_2.36 move_mount F
 GLIBC_2.36 open_tree F
 GLIBC_2.36 pidfd_getfd F