src: fix detached_mounts_propagation compile errors
PATCH 1/1 src: fix detached_mounts_propagation compile errors
Newer glibc such as glibc 2.36 also defines 'struct mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):
[CC] detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'struct mount_attr'
115 | struct mount_attr {
| ^~~~~~~~~~
In file included from detached_mounts_propagation.c:23:
/usr/include/sys/mount.h:210:8: note: originally defined here
210 | struct mount_attr
| ^~~~~~~~~~gmake[3]: *** [Makefile:102: detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2
---
Not quite look into that, but at a quick glance of tester reports it seems the cases.
configure.ac | 5 ++++- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)
configure.ac +4 -1
@@ -74,7 +74,10 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[ +#include <linux/mount.h> +#include <sys/mount.h> +]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>
src/detached_mounts_propagation.c +0 -1
@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h>
src/vfs/missing.h +1 -0
@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__
Signature · 1 line
2.24.4
Quoted 15 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~
Quoted 8 lines
gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Cc Christian Brauner <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This header mount.h mess is a neverending nightmare...
Quoted 14 lines
Not quite look into that, but at a quick glance of tester reports it seems the cases.
configure.ac | 5 ++++- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)configure.ac +0
-0
configure.ac AC_HAVE_FIEXCHANGE · line 79
Quoted 7 lines
configure.ac +3
-1@@ -74,7 +74,10 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[ +#include <linux/mount.h> +#include <sys/mount.h>
I think we should only rely on sys/mount.h. linux/mount.h and sys/mount.h are incompatible because linux/mount.h might have a #define where sys/mount.h has an enum.
Quoted 42 lines · Christian Brauner
Quoted 15 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~Quoted 8 lines
gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Cc Christian Brauner <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This header
mount.hmess is a neverending nightmare...Quoted 15 lines
Not quite look into that, but at a quick glance of tester reports it seems the cases.
configure.ac | 5 ++++- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)configure.ac +0
-0@@ -74,7 +74,10 @@ AC_HAVE_FIEXCHANGE
Quoted 10 lines
configure.ac AC_HAVE_FIEXCHANGE · line 79
Quoted 6 lines
configure.ac +3
-1AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[ +#include <linux/mount.h> +#include <sys/mount.h>I think we should only rely on
sys/mount.h.linux/mount.handsys/mount.hare incompatible becauselinux/mount.hmight have a #define wheresys/mount.hhas an enum.
Ok, got it. Let me play with it later.
Thanks,
Gao Xiang
Quoted 42 lines · Christian Brauner
Quoted 15 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~Quoted 8 lines
gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Cc Christian Brauner <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This header
mount.hmess is a neverending nightmare...Quoted 15 lines
Not quite look into that, but at a quick glance of tester reports it seems the cases.
configure.ac | 5 ++++- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 5 insertions(+), 2 deletions(-)configure.ac +0
-0@@ -74,7 +74,10 @@ AC_HAVE_FIEXCHANGE
Quoted 10 lines
configure.ac AC_HAVE_FIEXCHANGE · line 79
Quoted 6 lines
configure.ac +3
-1AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[ +#include <linux/mount.h> +#include <sys/mount.h>I think we should only rely on
sys/mount.h.linux/mount.handsys/mount.hare incompatible becauselinux/mount.hmight have a #define wheresys/mount.hhas an enum.
In fact, ltp also has this problem, but ltp has fixed this
We check whether mount_setattr() supported, if support, then use <sys/mount.h>,otherwise, use <linux/mount.h>
AC_CHECK_TYPES([struct mount_attr],,,[
#ifdef HAVE_MOUNT_SETATTR
# include <sys/mount.h> #elif HAVE_LINUX_MOUNT_H # include <linux/mount.h> #endif
see
https://github.com/linux-test-project/ltp/commit/30353a1eb3ee8940f38d6a0e8f5f39352fd8a179.
Best Regards
Yang Xu
PATCH v2 1/1 src: fix detached_mounts_propagation compile errors
In reply to Gao XiangNewer glibc such as glibc 2.36 also defines 'struct mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):
[CC] detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'struct mount_attr'
115 | struct mount_attr {
| ^~~~~~~~~~
In file included from detached_mounts_propagation.c:23:
/usr/include/sys/mount.h:210:8: note: originally defined here
210 | struct mount_attr
| ^~~~~~~~~~gmake[3]: *** [Makefile:102: detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2
Let's get rid of <linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.
--- configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
configure.ac +1 -1
@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>
src/detached_mounts_propagation.c +0 -1
@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h>
src/vfs/missing.h +1 -0
@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__
Signature · 1 line
2.24.4
Quoted 20 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2
Quoted 7 lines
Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
Seems good to me,
Quoted 20 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2
Quoted 7 lines
Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This patch works on latest fedora, but it cause fstests can't be built on RHEL-8 [1] and RHEL-9 [2], please check this incompatible problem.
Thanks,
Zorro
[1]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from /usr/include/linux/fs.h:18,
from /usr/include/xfs/linux.h:30,
from /usr/include/xfs/xfs.h:9,
from global.h:13,
from feature.c:29:/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
MS_RDONLY = 1, /* Mount read-only. */
^~~~~~~~~
gmake[2]: *** [Makefile:112: feature] Error 1
gmake[1]: *** [include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2
[2]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from /usr/include/linux/fs.h:19,
from /usr/include/xfs/linux.h:36,
from /usr/include/xfs/xfs.h:9,
from global.h:13,
from feature.c:29:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
35 | MS_RDONLY = 1, /* Mount read-only. */
| ^~~~~~~~~
In file included from feature.c:49:
vfs/missing.h:116:8: error: redefinition of 'struct mount_attr'
116 | struct mount_attr {
| ^~~~~~~~~~
In file included from /usr/include/linux/fs.h:19,
from /usr/include/xfs/linux.h:36,
from /usr/include/xfs/xfs.h:9,
from global.h:13,
from feature.c:29:
/usr/include/linux/mount.h:128:8: note: originally defined here
128 | struct mount_attr {
| ^~~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2
Quoted 45 lines
configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)configure.ac +1
-1@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/detached_mounts_propagation.c +0
-1@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__Signature · 1 line
2.24.4
Hi Zorro,
Quoted 24 lines · Zorro Lang
Quoted 23 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.
Quoted 7 lines
Quoted 4 lines
Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This patch works on latest fedora, but it cause fstests can't be built on RHEL-8 [1] and RHEL-9 [2], please check this incompatible problem.
I don't have RHEL-8 and RHEL-9 enviroment at hand, it seems that
#include <sys/mount.h> in vfs/missing.h
and xfs/xfs.h uapi header file causes more conflicts now.
So could you help check if _updating configure.ac only_ resolves the problem? I will recheck this as well.
Thanks,
Gao Xiang
Quoted 100 lines
Thanks,
Zorro[1]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:18,from /usr/include/xfs/linux.h:30, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant MS_RDONLY = 1, /* Mount read-only. */ ^~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2[2]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:19,from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant 35 | MS_RDONLY = 1, /* Mount read-only. */ | ^~~~~~~~~ In file included from feature.c:49: vfs/missing.h:116:8: error: redefinition of 'struct mount_attr' 116 | struct mount_attr { | ^~~~~~~~~~ In file included from /usr/include/linux/fs.h:19, from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/linux/mount.h:128:8: note: originally defined here 128 | struct mount_attr { | ^~~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2Quoted 45 lines
configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)configure.ac +1
-1@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/detached_mounts_propagation.c +0
-1@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__Signature · 1 line
2.24.4
Quoted 126 lines · Zorro Lang
Quoted 20 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Quoted 7 lines
Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This patch works on latest fedora, but it cause fstests can't be built on RHEL-8 [1] and RHEL-9 [2], please check this incompatible problem.
Thanks,
Zorro[1]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:18,from /usr/include/xfs/linux.h:30, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
MS_RDONLY= 1, /* Mount read-only. */
^~~~~~~~~
gmake[2]: *** [Makefile:112: feature] Error 1
gmake[1]: *** [include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2[2]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:19,from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant 35 | MS_RDONLY = 1, /* Mount read-only. */ | ^~~~~~~~~ In file included from feature.c:49: vfs/missing.h:116:8: error: redefinition of 'struct mount_attr' 116 | struct mount_attr { | ^~~~~~~~~~ In file included from /usr/include/linux/fs.h:19, from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/linux/mount.h:128:8: note: originally defined here 128 | struct mount_attr { | ^~~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2Quoted 40 lines
configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)configure.ac +1
-1@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/detached_mounts_propagation.c +0
-1@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h>
Quoted 5 lines
Quoted 5 lines
src/vfs/missing.h +0
-0#ifndef __NR_mount_setattr#if defined __alpha__Signature · 1 line
2.24.4
Hi Zorro,
Can you try this patch, which is inspired by Yang Xu[1].
[1]https://lore.kernel.org/fstests/[email protected]/T/#me981ae064b3ecb151b3321a4ee77f5d916cb017c
Regards,
Zhang
Patch:
configure.ac +13 -1
@@ -16,6 +16,7 @@ AC_CHECK_HEADERS([ assert.h \ sys/uuid.h \ sys/file.h \ sys/fcntl.h \ + sys/mount.h \ sys/syssgi.h \ sys/param.h \ sys/stat.h \
@@ -27,6 +28,7 @@ AC_CHECK_HEADERS([ assert.h \ strings.h \ err.h \ linux/falloc.h \ + linux/mount.h \ sys/fs/xfs_fsops.h \ sys/fs/xfs_itable.h \ xfs/platform_defs.h \
@@ -35,6 +37,10 @@ AC_CHECK_HEADERS([ assert.h \ sys/mman.h \ ]) +AC_CHECK_FUNCS_ONCE([ + mount_setattr +]) + AC_CHECK_HEADERS([xfs/xfs_log_format.h],,,[ #define _GNU_SOURCE #include <xfs/libxfs.h>])
@@ -68,7 +74,13 @@ AC_PACKAGE_WANT_LIBBTRFSUTIL AC_HAVE_COPY_FILE_RANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [],[[ +#ifdef HAVE_MOUNT_SETATTR +# include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> +#endif +]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>
src/vfs/missing.h +1 -0
@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__
Quoted 137 lines · Ziyang Zhang
Quoted 126 lines · Zorro Lang
Quoted 20 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Quoted 7 lines
Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This patch works on latest fedora, but it cause fstests can't be built on RHEL-8 [1] and RHEL-9 [2], please check this incompatible problem.
Thanks,
Zorro[1]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:18,from /usr/include/xfs/linux.h:30, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
MS_RDONLY= 1, /* Mount read-only. */
^~~~~~~~~
gmake[2]: *** [Makefile:112: feature] Error 1
gmake[1]: *** [include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2[2]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:19,from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant 35 | MS_RDONLY = 1, /* Mount read-only. */ | ^~~~~~~~~ In file included from feature.c:49: vfs/missing.h:116:8: error: redefinition of 'struct mount_attr' 116 | struct mount_attr { | ^~~~~~~~~~ In file included from /usr/include/linux/fs.h:19, from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/linux/mount.h:128:8: note: originally defined here 128 | struct mount_attr { | ^~~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2Quoted 40 lines
configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)configure.ac +1
-1@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/detached_mounts_propagation.c +0
-1@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> Quoted 5 lines
Quoted 5 lines
src/vfs/missing.h +0
-0#ifndef __NR_mount_setattr#if defined __alpha__Signature · 1 line
2.24.4Hi Zorro,
Can you try this patch, which is inspired by Yang Xu[1].
Quoted 7 lines
[1]https://lore.kernel.org/fstests/[email protected]/T/#me981ae064b3ecb151b3321a4ee77f5d916cb017c
Regards,
ZhangPatch:
Looks like not help [1]. The src/feature.c through global.h -> xfs/xfs.h -> xfs/linux.h -> linux/fs.h to include linux/mount.h, then it include "vfs/missing.h" manually. As you add "<sys/mount.h>" to vfs/missing.h, so there's a conflict.
Thanks,
Zorro
[1]
# make
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from /usr/include/linux/fs.h:18,
from /usr/include/xfs/linux.h:30,
from /usr/include/xfs/xfs.h:9,
from global.h:13,
from feature.c:29:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
MS_RDONLY = 1, /* Mount read-only. */
^~~~~~~~~
gmake[2]: *** [Makefile:112: feature] Error 1
gmake[1]: *** [include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2Quoted 60 lines
configure.ac +13
-1@@ -16,6 +16,7 @@ AC_CHECK_HEADERS([ assert.h \ sys/uuid.h \ sys/file.h \ sys/fcntl.h \ + sys/mount.h \ sys/syssgi.h \ sys/param.h \ sys/stat.h \@@ -27,6 +28,7 @@ AC_CHECK_HEADERS([ assert.h \ strings.h \ err.h \ linux/falloc.h \ + linux/mount.h \ sys/fs/xfs_fsops.h \ sys/fs/xfs_itable.h \ xfs/platform_defs.h \@@ -35,6 +37,10 @@ AC_CHECK_HEADERS([ assert.h \ sys/mman.h \ ]) +AC_CHECK_FUNCS_ONCE([ + mount_setattr +]) + AC_CHECK_HEADERS([xfs/xfs_log_format.h],,,[ #define _GNU_SOURCE #include <xfs/libxfs.h>])@@ -68,7 +74,13 @@ AC_PACKAGE_WANT_LIBBTRFSUTIL AC_HAVE_COPY_FILE_RANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [],[[ +#ifdef HAVE_MOUNT_SETATTR +# include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> +#endif +]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__
Quoted 144 lines · Zorro Lang
Quoted 143 lines · Ziyang Zhang
Quoted 126 lines · Zorro Lang
Quoted 20 lines · Gao Xiang
Newer glibc such as glibc 2.36 also defines 'struct
mount_attr' in addition to <linux/mount.h>. It will report as below when compiling with old linux kernel headers (without idmapped mounts, such as kernel-headers 5.10.134) but with newer glibc (here checked with glibc 2.36.6):[CC]
detached_mounts_propagation
In file included from detached_mounts_propagation.c:29:vfs/missing.h:115:8: error: redefinition of 'structmount_attr'115 | struct mount_attr { | ^~~~~~~~~~ In file included from detached_mounts_propagation.c:23: /usr/include/sys/mount.h:210:8: note: originally defined here 210 | struct mount_attr | ^~~~~~~~~~gmake[3]: *** [Makefile:102:
detached_mounts_propagation] Error 1 gmake[2]: *** [include/buildrules:31: src] Error 2 make[1]: *** [Makefile:51: default] Error 2
make: *** [Makefile:49: default] Error 2Quoted 7 lines
Let's get rid of <
linux/mount.h> as Christian suggested to avoid potential incompatibility between these two headers.Cc Christian Brauner <[email protected]>Cc "Yang Xu (Fujitsu)" <[email protected]>Signed-off-by Gao Xiang <[email protected]>---
This patch works on latest fedora, but it cause fstests can't be built on RHEL-8 [1] and RHEL-9 [2], please check this incompatible problem.
Thanks,
Zorro[1]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:18,from /usr/include/xfs/linux.h:30, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant MS_RDONLY = 1, /* Mount read-only. */ ^~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2[2]
...
Building include
Building lib
Building ltp
Building src
[CC] feature
In file included from/usr/include/linux/fs.h:19,from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant 35 | MS_RDONLY = 1, /* Mount read-only. */ | ^~~~~~~~~ In file included from feature.c:49: vfs/missing.h:116:8: error: redefinition of 'struct mount_attr' 116 | struct mount_attr { | ^~~~~~~~~~ In file included from /usr/include/linux/fs.h:19, from /usr/include/xfs/linux.h:36, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/linux/mount.h:128:8: note: originally defined here 128 | struct mount_attr { | ^~~~~~~~~~gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [
include/buildrules:31: src] Error 2
make: *** [Makefile:51: default] Error 2Quoted 40 lines
configure.ac | 2 +- src/detached_mounts_propagation.c | 1 - src/vfs/missing.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)configure.ac +1
-1@@ -74,7 +74,7 @@ AC_HAVE_FIEXCHANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <sys/mount.h>]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/detached_mounts_propagation.c +0
-1@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> Quoted 5 lines
Quoted 5 lines
src/vfs/missing.h +0
-0#ifndef __NR_mount_setattr#if defined __alpha__Signature · 1 line
2.24.4Hi Zorro,
Can you try this patch, which is inspired by Yang Xu[1].
[1]https://lore.kernel.org/fstests/[email protected]/T/#me981ae064b3ecb151b3321a4ee77f5d916cb017c
Regards,
Zhang
Quoted 6 lines
Quoted 1 line
Patch:
Looks like not help [1]. The
src/feature.cthroughglobal.h->xfs/xfs.h->xfs/linux.h->linux/fs.hto includelinux/mount.h, then it include "vfs/missing.h" manually. As you add "<sys/mount.h>" tovfs/missing.h, so there's a conflict.
Yes, here is a complex problem than ltp because global.h includes <linux/mount.h>. We don't include <sys/mount.h> or <linux/mount.h> together on older glibc(glibc 2.36.6). Newer glibc(glibc-2.37-1)[1] seems has sloved this problem.
[1]https://sourceware.org/git/?p=glibc.git;a=commit;h=774058d72942249f71d74e7f2b639f77184160a6
I guess we can not use <sys/mount.h> header,
then compile info as below:detached_mounts_propagation.c: In function 'main':
detached_mounts_propagation.c:129:15: warning: implicit declaration of function 'mount' [-Wimplicit-function-declaration]
129 | ret = mount(NULL, base_dir, NULL, MS_REC | MS_SHARED,
NULL);
| ^~~~~
detached_mounts_propagation.c:176:23: warning: implicit declaration of
function 'umount2'; did you mean 'sys_umount2'?
[-Wimplicit-function-declaration]
176 | ret = umount2(target, MNT_DETACH);
| ^~~~~~~
| sys_umount2then we can use syscall wrapper directly instead of glibc wrapper
src/detached_mounts_propagation.c +2 -3
@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h>
@@ -127,7 +126,7 @@ int main(int argc, char *argv[])if (ret <0 )exit_log ("%m - Failed to create new mount namespace" ); - ret =mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL ); + ret =sys_mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL );if (ret <0 )exit_log ("%m - Failed to make base_dir shared mountpoint" );
@@ -174,7 +173,7 @@ int main(int argc, char *argv[]) }close (fd_tree); - ret =umount2 (target,MNT_DETACH ); + ret =sys_umount2 (target,MNT_DETACH );if (ret <0 ) { fprintf(stderr, "%m - Failed to unmount %s",
target);
exit_code = EXIT_FAILURE;Best Regards
Yang Xu
Quoted 84 lines
Thanks,
Zorro[1]
# make Building include Building lib Building ltp Building src [CC] feature In file included from /usr/include/linux/fs.h:18, from /usr/include/xfs/linux.h:30, from /usr/include/xfs/xfs.h:9, from global.h:13, from feature.c:29: /usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant MS_RDONLY = 1, /* Mount read-only. */ ^~~~~~~~~ gmake[2]: *** [Makefile:112: feature] Error 1 gmake[1]: *** [include/buildrules:31: src] Error 2 make: *** [Makefile:51: default] Error 2Quoted 60 lines
configure.ac +13
-1@@ -16,6 +16,7 @@ AC_CHECK_HEADERS([ assert.h \ sys/uuid.h \ sys/file.h \ sys/fcntl.h \ + sys/mount.h \ sys/syssgi.h \ sys/param.h \ sys/stat.h \@@ -27,6 +28,7 @@ AC_CHECK_HEADERS([ assert.h \ strings.h \ err.h \ linux/falloc.h \ + linux/mount.h \ sys/fs/xfs_fsops.h \ sys/fs/xfs_itable.h \ xfs/platform_defs.h \@@ -35,6 +37,10 @@ AC_CHECK_HEADERS([ assert.h \ sys/mman.h \ ]) +AC_CHECK_FUNCS_ONCE([ + mount_setattr +]) + AC_CHECK_HEADERS([xfs/xfs_log_format.h],,,[ #define _GNU_SOURCE #include <xfs/libxfs.h>])@@ -68,7 +74,13 @@ AC_PACKAGE_WANT_LIBBTRFSUTIL AC_HAVE_COPY_FILE_RANGE AC_CHECK_FUNCS([renameat2]) AC_CHECK_FUNCS([reallocarray]) -AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) +AC_CHECK_TYPES([struct mount_attr], [], [],[[ +#ifdef HAVE_MOUNT_SETATTR +# include <sys/mount.h> +#elif HAVE_LINUX_MOUNT_H +# include <linux/mount.h> +#endif +]]) AC_CHECK_TYPES([struct btrfs_qgroup_limit], [], [], [[ #include <stddef.h> #include <linux/btrfs.h>src/vfs/missing.h +1
-0@@ -18,6 +18,7 @@#include <sys/types.h> #include <syscall.h> #include <unistd.h> +#include <sys/mount.h> #ifndef __NR_mount_setattr#if defined __alpha__
Quoted 1 line · Yang Xu (Fujitsu)
[...]
Quoted 61 lines
Quoted 5 lines
Looks like not help [1]. The
src/feature.cthroughglobal.h->xfs/xfs.h->xfs/linux.h->linux/fs.hto includelinux/mount.h, then it include "vfs/missing.h" manually. As you add "<sys/mount.h>" tovfs/missing.h, so there's a conflict.Yes, here is a complex problem than ltp because
global.hincludes <linux/mount.h>. We don't include <sys/mount.h> or <linux/mount.h> together on older glibc(glibc 2.36.6). Newer glibc(glibc-2.37-1)[1] seems has sloved this problem.[1]https://sourceware.org/git/?p=glibc.git;a=commit;h=774058d72942249f71d74e7f2b639f77184160a6
I guess we can not use <
sys/mount.h> header,
then compile info as below:detached_mounts_propagation.c: In function 'main':
detached_mounts_propagation.c:129:15: warning: implicit declaration of function 'mount' [-Wimplicit-function-declaration]
129 | ret = mount(NULL,base_dir, NULL,MS_REC|MS_SHARED,NULL); | ^~~~~ detached_mounts_propagation.c:176:23: warning: implicit declaration of function 'umount2'; did you mean 'sys_umount2'? [-Wimplicit-function-declaration] 176 | ret = umount2(target, MNT_DETACH); | ^~~~~~~ | sys_umount2then we can use syscall wrapper directly instead of glibc wrapper
src/detached_mounts_propagation.c +2
-3@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> @@ -127,7 +126,7 @@ int main(int argc, char *argv[])if (ret <0 )exit_log ("%m - Failed to create new mount namespace" ); - ret =mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL ); + ret =sys_mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL );if (ret <0 )exit_log ("%m - Failed to make base_dir shared mountpoint" );@@ -174,7 +173,7 @@ int main(int argc, char *argv[]) }close (fd_tree); - ret =umount2 (target,MNT_DETACH ); + ret =sys_umount2 (target,MNT_DETACH );if (ret <0 ) {fprintf (stderr,"%m - Failed to unmount %s" , target);exit_code = EXIT_FAILURE;
Quoted 3 lines
Best Regards
Yang Xu
Hi Yang,
You patch works for me(kernel: 5.10.134, glibc:2.36). I think we could just modify detached_mounts_propagation.c to solve this problem.
Regards,
Zhang
Quoted 66 lines · Ziyang Zhang
Quoted 1 line · Yang Xu (Fujitsu)
[...]
Quoted 61 lines
Quoted 5 lines
Looks like not help [1]. The
src/feature.cthroughglobal.h->xfs/xfs.h->xfs/linux.h->linux/fs.hto includelinux/mount.h, then it include "vfs/missing.h" manually. As you add "<sys/mount.h>" tovfs/missing.h, so there's a conflict.Yes, here is a complex problem than ltp because
global.hincludes <linux/mount.h>. We don't include <sys/mount.h> or <linux/mount.h> together on older glibc(glibc 2.36.6). Newer glibc(glibc-2.37-1)[1] seems has sloved this problem.[1]https://sourceware.org/git/?p=glibc.git;a=commit;h=774058d72942249f71d74e7f2b639f77184160a6
I guess we can not use <
sys/mount.h> header,
then compile info as below:detached_mounts_propagation.c: In function 'main':
detached_mounts_propagation.c:129:15: warning: implicit declaration of function 'mount' [-Wimplicit-function-declaration]
129 | ret = mount(NULL,base_dir, NULL,MS_REC|MS_SHARED,NULL); | ^~~~~ detached_mounts_propagation.c:176:23: warning: implicit declaration of function 'umount2'; did you mean 'sys_umount2'? [-Wimplicit-function-declaration] 176 | ret = umount2(target, MNT_DETACH); | ^~~~~~~ | sys_umount2then we can use syscall wrapper directly instead of glibc wrapper
src/detached_mounts_propagation.c +2
-3@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> @@ -127,7 +126,7 @@ int main(int argc, char *argv[])if (ret <0 )exit_log ("%m - Failed to create new mount namespace" ); - ret =mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL ); + ret =sys_mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL );if (ret <0 )exit_log ("%m - Failed to make base_dir shared mountpoint" );@@ -174,7 +173,7 @@ int main(int argc, char *argv[]) }close (fd_tree); - ret =umount2 (target,MNT_DETACH ); + ret =sys_umount2 (target,MNT_DETACH );if (ret <0 ) {fprintf (stderr,"%m - Failed to unmount %s" , target);exit_code = EXIT_FAILURE;
Quoted 8 lines
Quoted 3 lines
Best Regards
Yang XuHi Yang,
You patch works for
me(kernel: 5.10.134, glibc:2.36). I think we could just modifydetached_mounts_propagation.cto solve this problem.
OK, @Gao @Ziyang, so should I send a patch or you send it?
Best Regards
Yang Xu
Quoted 3 lines
Regards,
Zhang
Quoted 75 lines · Yang Xu (Fujitsu)
Quoted 72 lines · Ziyang Zhang
Quoted 1 line · Yang Xu (Fujitsu)
[...]
Quoted 61 lines
Quoted 5 lines
Looks like not help [1]. The
src/feature.cthroughglobal.h->xfs/xfs.h->xfs/linux.h->linux/fs.hto includelinux/mount.h, then it include "vfs/missing.h" manually. As you add "<sys/mount.h>" tovfs/missing.h, so there's a conflict.Yes, here is a complex problem than ltp because
global.hincludes <linux/mount.h>. We don't include <sys/mount.h> or <linux/mount.h> together on older glibc(glibc 2.36.6). Newer glibc(glibc-2.37-1)[1] seems has sloved this problem.[1]https://sourceware.org/git/?p=glibc.git;a=commit;h=774058d72942249f71d74e7f2b639f77184160a6
I guess we can not use <
sys/mount.h> header,
then compile info as below:detached_mounts_propagation.c: In function 'main':
detached_mounts_propagation.c:129:15: warning: implicit declaration of function 'mount' [-Wimplicit-function-declaration]
129 | ret = mount(NULL,base_dir, NULL,MS_REC|MS_SHARED,NULL); | ^~~~~ detached_mounts_propagation.c:176:23: warning: implicit declaration of function 'umount2'; did you mean 'sys_umount2'? [-Wimplicit-function-declaration] 176 | ret = umount2(target, MNT_DETACH); | ^~~~~~~ | sys_umount2then we can use syscall wrapper directly instead of glibc wrapper
src/detached_mounts_propagation.c +2
-3@@ -20,7 +20,6 @@#include <stdio.h> #include <stdlib.h> #include <string.h> -#include <sys/mount.h> #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> @@ -127,7 +126,7 @@ int main(int argc, char *argv[])if (ret <0 )exit_log ("%m - Failed to create new mount namespace" ); - ret =mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL ); + ret =sys_mount (NULL , base_dir,NULL ,MS_REC |MS_SHARED ,NULL );if (ret <0 )exit_log ("%m - Failed to make base_dir shared mountpoint" );@@ -174,7 +173,7 @@ int main(int argc, char *argv[]) }close (fd_tree); - ret =umount2 (target,MNT_DETACH ); + ret =sys_umount2 (target,MNT_DETACH );if (ret <0 ) {fprintf (stderr,"%m - Failed to unmount %s" , target);exit_code = EXIT_FAILURE;Quoted 3 lines
Best Regards
Yang XuHi Yang,
Quoted 7 lines
Quoted 2 lines
You patch works for
me(kernel: 5.10.134, glibc:2.36). I think we could just modifydetached_mounts_propagation.cto solve this problem.OK, @Gao @Ziyang, so should I send a patch or you send it?
Best Regards
Yang Xu
Hi, you can send it. :) Thanks.