statmount.h: add check for STATMOUNT_MNT_NS_ID
PATCH v2 1/1 statmount.h: add check for STATMOUNT_MNT_NS_ID
statmount.h: add check for STATMOUNT_MNT_NS_ID
Enable check for STATMOUNT_MNT_NS_ID in kernel headers. Define LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID for mnt_ns_id and mnt_id use cases.
--- testcases/kernel/syscalls/statmount/statmount.h | 5 +++++ 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/statmount/statmount.h +5 -0
@@ -13,6 +13,11 @@#include "lapi/syscalls.h" #include "tst_safe_stdio.h" +/* Enable STATMOUNT_MNT_NS_ID check for struct statmount. */ +#if !defined(HAVE_STRUCT_STATMOUNT ) || defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID ) +#define LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID 1 +#endif +static inline int statmount (uint64_t mnt_id,uint64_t mask,struct statmount *buf,size_t bufsize,unsigned int flags) {
--
2.51.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
When LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID is defined, use mnt_ns_id for statmount09 test case. Otherswise, use mnt_id.
--- testcases/kernel/syscalls/statmount/statmount09.c | 4 ++++ 1 file changed, 4 insertions(+)
testcases/kernel/syscalls/statmount/statmount09.c +4 -0
@@ -39,7 +39,11 @@ static void run(void)return ;TST_EXP_EQ_LI (st_mount->mask,STATMOUNT_MNT_NS_ID ); +#ifdef LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID TST_EXP_EQ_LI (st_mount->mnt_ns_id, mnt_ns_id); +#else +tst_res (TCONF ,"statmount.mnt_ns_id not available in current headers, skipping check" ); +#endif }static void setup (void )
--
2.51.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
Hi!
Review
Quoted 5 lines · Jack Morgan
(quoted diff) +4
-0+#ifdef LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID TST_EXP_EQ_LI(st_mount->mnt_ns_id, mnt_ns_id); +#else + tst_res(TCONF, "statmount.mnt_ns_id not available in current headers, skipping check"); +#endif
The statmount09 is testing STATMOUNT_MNT_NS_ID feature, which is carrying the mnt_ns_id as well, so we don't need to run this test if HAVE_STRUCT_STATMOUNT_MNT_NS_ID is not defined. We can do something like:
configure.ac +0 -0
@@ -264,6 +264,7 @@ AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>])
# Defined in <linux/mount.h>, but include/lapi/mount.h includes <sys/mount.h> */ AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>]) AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>]) +AC_CHECK_MEMBERS([struct statmount.mnt_ns_id],,,[#include <linux/mount.h>])
AC_CHECK_TYPES([struct pidfd_info],,,[#include <sys/pidfd.h>]) AC_CHECK_TYPES([struct file_attr],,,[#include <linux/fs.h>])
testcases/kernel/syscalls/statmount/statmount09.c +0 -0
@@ -15,6 +15,11 @@
* namespace
*/
+#include "config.h"
+#include "tst_test.h"
+
+#ifdef HAVE_STRUCT_STATMOUNT_MNT_NS_ID
+
#define _GNU_SOURCE
#include "statmount.h"
@@ -72,3 +77,8 @@ static struct tst_test test = {
}
};
+#else
+
+TST_TEST_TCONF("STATMOUNT_MNT_NS_ID support is required"); +
+#endif
This could be done by checking if STATMOUNT_MNT_NS_ID exists, but since mnt_ns_id attribute and STATMOUNT_MNT_NS_ID are defined in the same commit (09b31295f833031c88419550172703d45c5401e3 - fs: export the mount ns id via statmount), we can safely use configure.ac.
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
Hi Cyril
Quoted 53 lines · Andrea Cervesato
Hi!
Quoted 6 lines · Jack Morgan
+#ifdef
LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_IDTST_EXP_EQ_LI(st_mount->mnt_ns_id, mnt_ns_id); +#else
+tst_res(TCONF, "statmount.mnt_ns_id not available in current headers, skipping check");
+#endifThe statmount09 is testing
STATMOUNT_MNT_NS_IDfeature, which is carrying themnt_ns_idas well, so we don't need to run this test ifHAVE_STRUCT_STATMOUNT_MNT_NS_IDis not defined. We can do something like:configure.ac +1
-0@@ -264,6 +264,7 @@ AC_CHECK_TYPES([struct cachestat],,,[#include <sys/mman.h>]) # Defined in <linux/mount.h>, but include/lapi/mount.h includes <sys/mount.h> */ AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>]) AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>]) +AC_CHECK_MEMBERS([struct statmount.mnt_ns_id],,,[#include <linux/mount.h>])AC_CHECK_TYPES([struct pidfd_info],,,[#include <
sys/pidfd.h>])AC_CHECK_TYPES([struct file_attr],,,[#include <linux/fs.h>])testcases/kernel/syscalls/statmount/statmount09.c +10
-0@@ -15,6 +15,11 @@* namespace */ +#include "config.h" +#include "tst_test.h" + +#ifdef HAVE_STRUCT_STATMOUNT_MNT_NS_ID + #define _GNU_SOURCE #include "statmount.h"@@ -72,3 +77,8 @@ static struct tst_test test = { } }; +#else + +TST_TEST_TCONF ("STATMOUNT_MNT_NS_ID support is required" ); + +#endif
Quoted 4 lines
This could be done by checking if
STATMOUNT_MNT_NS_IDexists, but sincemnt_ns_idattribute andSTATMOUNT_MNT_NS_IDare defined in the same commit (09b31295f833031c88419550172703d45c5401e3- fs: export the mount ns id via statmount), we can safely use configure.ac.- Andrea
FYI this patch might be needed for the release, since it's breaking the build on old kernels before 09b31295f833031c88419550172703d45c5401e3 commit. What do you think?
---
Andrea Cervesato
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
Hi!
Quoted 3 lines
FYI this patch might be needed for the release, since it's breaking the build on old kernels before
09b31295f833031c88419550172703d45c5401e3commit. What do you think?
Yes, this is one of the fixes that should go in.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
In reply to Andrea Cervesato via ltpReview
Quoted 2 lines · Andrea Cervesato
(quoted diff) +2
-0+#ifdef HAVE_STRUCT_STATMOUNT_MNT_NS_ID +
According to the follow-up discussion, this is more correct:
#if!defined(HAVE_STRUCT_STATMOUNT) || defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID)
Signature · 7 lines
Andrea Cervesato [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID
Quoted 7 lines · Andrea Cervesato
Review
Quoted 2 lines · Andrea Cervesato
(quoted diff) +2
-0+#ifdef HAVE_STRUCT_STATMOUNT_MNT_NS_ID +According to the follow-up discussion, this is more correct:
#if!defined(HAVE_STRUCT_STATMOUNT) ||
defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID)
Thank you for the feedback. I'll update my patch with this change and send v3 shortly.
For the change to configure.ac, I've sent a separate patch for this[1].
Finally, the suggestion is to then drop patch for statmount.h as checks will be in statmount09.c test case, correct?
Is there anything else I'm missing?
[1]
https://lore.kernel.org/ltp/[email protected]/T/#u
Regards,
Jack Morgan
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/syscalls/statmount/statmount.h line 19
Quoted 4 lines · Jack Morgan
testcases/kernel/syscalls/statmount/statmount.h +4
-0+/* Enable STATMOUNT_MNT_NS_ID check for struct statmount. */ +#if !defined(HAVE_STRUCT_STATMOUNT ) || defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID ) +#define LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID 1 +#endif
This is not a good practice, better to avoid defining LTP_* wrappers, since we already have the HAVE_* variables defined by autoconf.
- Andrea
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 7 lines
testcases/kernel/syscalls/statmount/statmount.h line 19
Quoted 4 lines
testcases/kernel/syscalls/statmount/statmount.h +4
-0+/* Enable STATMOUNT_MNT_NS_ID check for struct statmount. */ +#if !defined(HAVE_STRUCT_STATMOUNT ) || defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID ) +#define LTP_HAVE_STRUCT_STATMOUNT_MNT_NS_ID 1 +#endif This is not a good practice, better to avoid defining LTP_* wrappers, since we already have the HAVE_* variables defined by autoconf.
This has to be unfortunately there because the field is present if we are using lapi fallback or if we have new enough system headers. So either we open code the ifdefs in the test, or define the macro like this.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Cyril Hrubis
This has to be unfortunately there because the field is present if we are using lapi fallback or if we have new enough system headers. So either we open code the ifdefs in the test, or define the macro like this.
Why not just using "#if!defined(HAVE_STRUCT_STATMOUNT) || defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID)" inside the statmount09 test then? These LTP_HAVE_* wrappers are a bit weird because they are mixing with internal LTP macros, also considering the fact we are not testing "struct statmount.mnt_ns_id" anywhere else but in statmount09.
Signature · 6 lines
Andrea Cervesato [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 5 lines
Why not just using "#if!defined(HAVE_STRUCT_STATMOUNT) ||
defined(HAVE_STRUCT_STATMOUNT_MNT_NS_ID)" inside the statmount09 test then? These LTP_HAVE_* wrappers are a bit weird because they are mixing with internal LTP macros, also considering the fact we are not testing "struct statmount.mnt_ns_id" anywhere else but in statmount09.
Works for me as well, I do not have a strong opinion here.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp