On 2023/4/25 09:28, Yang Xu (Fujitsu) wrote: > [...] >> >> 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. > > 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_umount2 > > > then we can use syscall wrapper directly instead of glibc wrapper > --- a/src/detached_mounts_propagation.c > +++ b/src/detached_mounts_propagation.c > @@ -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 > 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