[LTP] [PATCH 2/2] lapi/fsmount: resolve conflict in different header files

Li Wang liwang@redhat.com
Fri Aug 5 08:34:01 CEST 2022


The latest glibc added new wrappers (e.g. mount_setattr, fsopen) support
in sys/mount.h, which partly conflicts with linux/mount.h at the same time.

We need to make adjustments to header files to fix compiling error on
different platforms.

Signed-off-by: Li Wang <liwang@redhat.com>
---
 configure.ac                                              | 1 +
 include/lapi/fs.h                                         | 6 ++++--
 include/lapi/fsmount.h                                    | 6 ++++--
 testcases/kernel/syscalls/fsconfig/fsconfig01.c           | 1 +
 testcases/kernel/syscalls/fsconfig/fsconfig02.c           | 1 +
 testcases/kernel/syscalls/fsmount/fsmount01.c             | 1 +
 testcases/kernel/syscalls/fsmount/fsmount02.c             | 1 +
 testcases/kernel/syscalls/fsopen/fsopen01.c               | 1 +
 testcases/kernel/syscalls/fsopen/fsopen02.c               | 1 +
 testcases/kernel/syscalls/fspick/fspick01.c               | 1 +
 testcases/kernel/syscalls/fspick/fspick02.c               | 1 +
 testcases/kernel/syscalls/mount_setattr/mount_setattr01.c | 1 +
 testcases/kernel/syscalls/move_mount/move_mount01.c       | 1 +
 testcases/kernel/syscalls/move_mount/move_mount02.c       | 1 +
 testcases/kernel/syscalls/open_tree/open_tree01.c         | 1 +
 testcases/kernel/syscalls/open_tree/open_tree02.c         | 1 +
 16 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index d50ec1ea7..dbd53cab6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,7 @@ AC_CHECK_FUNCS_ONCE([ \
     mkdirat \
     mknodat \
     modify_ldt \
+    mount_setattr \
     move_mount \
     name_to_handle_at \
     open_tree \
diff --git a/include/lapi/fs.h b/include/lapi/fs.h
index 27b3a183c..84a168a67 100644
--- a/include/lapi/fs.h
+++ b/include/lapi/fs.h
@@ -6,8 +6,10 @@
  * Email: code@zilogic.com
  */
 
-#ifdef HAVE_LINUX_FS_H
-# include <linux/fs.h>
+#ifndef HAVE_MOUNT_SETATTR
+# ifdef HAVE_LINUX_FS_H
+#  include <linux/fs.h>
+# endif
 #endif
 
 #include <sys/user.h>
diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index b11e7a7bd..9b1993580 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -12,8 +12,10 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
+#ifndef HAVE_FSOPEN
+# ifdef HAVE_LINUX_MOUNT_H
+#  include <linux/mount.h>
+# endif
 #endif
 
 #include "lapi/fcntl.h"
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig01.c b/testcases/kernel/syscalls/fsconfig/fsconfig01.c
index a585daa6d..f1dc7d8da 100644
--- a/testcases/kernel/syscalls/fsconfig/fsconfig01.c
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c
@@ -5,6 +5,7 @@
  * Basic fsconfig() test which tries to configure and mount the filesystem as
  * well.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig02.c b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
index 272e25a6f..bbad6def6 100644
--- a/testcases/kernel/syscalls/fsconfig/fsconfig02.c
+++ b/testcases/kernel/syscalls/fsconfig/fsconfig02.c
@@ -4,6 +4,7 @@
  *
  * Basic fsconfig() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c
index 5f755863f..1232b0914 100644
--- a/testcases/kernel/syscalls/fsmount/fsmount01.c
+++ b/testcases/kernel/syscalls/fsmount/fsmount01.c
@@ -6,6 +6,7 @@
  * Basic fsmount() test.
  */
 
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fsmount/fsmount02.c b/testcases/kernel/syscalls/fsmount/fsmount02.c
index a4f42dc18..91512b74a 100644
--- a/testcases/kernel/syscalls/fsmount/fsmount02.c
+++ b/testcases/kernel/syscalls/fsmount/fsmount02.c
@@ -4,6 +4,7 @@
  *
  * Basic fsmount() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fsopen/fsopen01.c b/testcases/kernel/syscalls/fsopen/fsopen01.c
index c2c719c96..332821cf0 100644
--- a/testcases/kernel/syscalls/fsopen/fsopen01.c
+++ b/testcases/kernel/syscalls/fsopen/fsopen01.c
@@ -5,6 +5,7 @@
  * Basic fsopen() test which tries to configure and mount the filesystem as
  * well.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c
index 3f287bf29..8c643b9a8 100644
--- a/testcases/kernel/syscalls/fsopen/fsopen02.c
+++ b/testcases/kernel/syscalls/fsopen/fsopen02.c
@@ -4,6 +4,7 @@
  *
  * Basic fsopen() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c
index d3309a912..ae6cad6fb 100644
--- a/testcases/kernel/syscalls/fspick/fspick01.c
+++ b/testcases/kernel/syscalls/fspick/fspick01.c
@@ -4,6 +4,7 @@
  *
  * Basic fspick() test.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/fspick/fspick02.c b/testcases/kernel/syscalls/fspick/fspick02.c
index f9a3697c1..907b463b6 100644
--- a/testcases/kernel/syscalls/fspick/fspick02.c
+++ b/testcases/kernel/syscalls/fspick/fspick02.c
@@ -4,6 +4,7 @@
  *
  * Basic fspick() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
index 83746b878..fcf491c33 100644
--- a/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
+++ b/testcases/kernel/syscalls/mount_setattr/mount_setattr01.c
@@ -30,6 +30,7 @@
 #define _GNU_SOURCE
 
 #include <sys/statvfs.h>
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 #include "lapi/stat.h"
diff --git a/testcases/kernel/syscalls/move_mount/move_mount01.c b/testcases/kernel/syscalls/move_mount/move_mount01.c
index 445e6197e..b65141a28 100644
--- a/testcases/kernel/syscalls/move_mount/move_mount01.c
+++ b/testcases/kernel/syscalls/move_mount/move_mount01.c
@@ -4,6 +4,7 @@
  *
  * Basic move_mount() test.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/move_mount/move_mount02.c b/testcases/kernel/syscalls/move_mount/move_mount02.c
index 45b1db4be..373c8c3ac 100644
--- a/testcases/kernel/syscalls/move_mount/move_mount02.c
+++ b/testcases/kernel/syscalls/move_mount/move_mount02.c
@@ -4,6 +4,7 @@
  *
  * Basic move_mount() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/open_tree/open_tree01.c b/testcases/kernel/syscalls/open_tree/open_tree01.c
index 808d25665..6d2299449 100644
--- a/testcases/kernel/syscalls/open_tree/open_tree01.c
+++ b/testcases/kernel/syscalls/open_tree/open_tree01.c
@@ -4,6 +4,7 @@
  *
  * Basic open_tree() test.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
diff --git a/testcases/kernel/syscalls/open_tree/open_tree02.c b/testcases/kernel/syscalls/open_tree/open_tree02.c
index ddaa204f2..59a5a4ca2 100644
--- a/testcases/kernel/syscalls/open_tree/open_tree02.c
+++ b/testcases/kernel/syscalls/open_tree/open_tree02.c
@@ -4,6 +4,7 @@
  *
  * Basic open_tree() failure tests.
  */
+#include <sys/mount.h>
 #include "tst_test.h"
 #include "lapi/fsmount.h"
 
-- 
2.35.3



More information about the ltp mailing list