[LTP] [PATCH v2] statmount09.c: Enable mnt_ns_id for STATMOUNT_MNT_NS_ID

Andrea Cervesato andrea.cervesato@suse.com
Fri Sep 26 09:32:19 CEST 2025


Hi!

On 9/26/25 6:07 AM, Jack Morgan wrote:
> +#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:

diff --git a/configure.ac b/configure.ac
index d4dd13033..189d8771e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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>])
diff --git a/testcases/kernel/syscalls/statmount/statmount09.c 
b/testcases/kernel/syscalls/statmount/statmount09.c
index 20c76ba24..b78cec6b4 100644
--- a/testcases/kernel/syscalls/statmount/statmount09.c
+++ b/testcases/kernel/syscalls/statmount/statmount09.c
@@ -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



More information about the ltp mailing list