]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
src: Don't include <sys/mount.h> and <linux/mount.h> together
authorYang Xu <xuyang2018.jy@fujitsu.com>
Tue, 25 Apr 2023 08:21:30 +0000 (16:21 +0800)
committerZorro Lang <zlang@kernel.org>
Fri, 28 Apr 2023 18:31:04 +0000 (02:31 +0800)
Newer glibc such as glibc 2.36 also defines 'struct mount_attr'
in addition to <linux/mount.h>.

Usually we should use glibc header instead of kernel header.
But now mount.h is a special case because both new glibc header and
kernel header all define "struct mount_attr'. They also define MS*
macro.

Since we have some syscall wrapper in vfs/missing.h, we can use
<linux.mount.h> directly instead of <sys/mount.h> for
detached_mounts_propagation.c.

For utils.c, it doesn't use the macro or function in <sys/mount.h>,
so remove it directly.

In fact, newer glibc(2.37-1)[1] has sloved conflict problem between
<sys/mount.h> and <linux/mount.h>. In the future(maybe ten years), we
can remove this kernel header and use glibc header.

[1]https://sourceware.org/git/?p=glibc.git;a=commit;h=774058d72942249f71d74e7f2b639f77184160a6

Acked-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Tested-by: Ziyang Zhang <ZiyangZhang@linux.alibaba.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
src/detached_mounts_propagation.c
src/vfs/utils.c

index 17db2c026ebfa283a7e761b7664f32ddf136372e..dd11f7be883187722962c63afedc801331b6358a 100644 (file)
@@ -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;
index 9e67ac3724207c757073d1462af1949c5f3129c2..0ab5de15e60ba56b1cba760f1eaf1fc56209d197 100644 (file)
@@ -10,7 +10,6 @@
 #include <stdlib.h>
 #include <sys/eventfd.h>
 #include <sys/fsuid.h>
-#include <sys/mount.h>
 #include <sys/prctl.h>
 #include <sys/socket.h>
 #include <sys/stat.h>