[LTP] [PATCH 2/2] Fix conflicting linux/mount.h and sys/mount.h

Khem Raj raj.khem@gmail.com
Tue Aug 16 07:15:39 CEST 2022


glibc 2.36 mount.h is conflicting with linux/mount.h [1] which is included
by linux/fs.h via lapi/fs.h, as a compromize define needed macros from
linux/fs.h and avoid the conflict

[1] https://sourceware.org/glibc/wiki/Release/2.36#Usage_of_.3Clinux.2Fmount.h.3E_and_.3Csys.2Fmount.h.3E
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 include/lapi/fsmount.h                    |  5 +----
 testcases/kernel/syscalls/statx/statx09.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h
index 3609855f6..a61711d52 100644
--- a/include/lapi/fsmount.h
+++ b/include/lapi/fsmount.h
@@ -12,11 +12,8 @@
 #include <sys/syscall.h>
 #include <sys/types.h>
 
-#ifdef HAVE_LINUX_MOUNT_H
-# include <linux/mount.h>
-#endif
-
 #include "lapi/fcntl.h"
+#include "lapi/mount.h"
 #include "lapi/syscalls.h"
 
 #ifndef HAVE_FSOPEN
diff --git a/testcases/kernel/syscalls/statx/statx09.c b/testcases/kernel/syscalls/statx/statx09.c
index aea329e08..e03f29613 100644
--- a/testcases/kernel/syscalls/statx/statx09.c
+++ b/testcases/kernel/syscalls/statx/statx09.c
@@ -18,14 +18,22 @@
  */
 
 #define _GNU_SOURCE
-#include <sys/mount.h>
 #include <stdlib.h>
 #include "tst_test.h"
-#include "lapi/fs.h"
 #include "lapi/fsverity.h"
 #include "lapi/stat.h"
+#include "lapi/mount.h"
 #include <inttypes.h>
 
+/* define neded FS_* macros to avoid linux/fs.h conflict with sys/mount.h */
+#ifndef FS_IOC_GETFLAGS
+#define FS_IOC_GETFLAGS _IOR('f', 1, long)
+#endif
+
+#ifndef FS_VERITY_FL
+#define FS_VERITY_FL 0x00100000 /* Verity protected inode */
+#endif
+
 #define MNTPOINT "mnt_point"
 #define TESTFILE_FLAGGED MNTPOINT"/test_file1"
 #define TESTFILE_UNFLAGGED MNTPOINT"/test_file2"
-- 
2.37.2



More information about the ltp mailing list