Re: [LTP] [PATCH v1] listmount04.c: Update case support mnt_id_req.mnt_ns_fd

Li Wang via ltp
2025-11-28T03:26:52Z

Hi Wei,

On Thu, Nov 27, 2025 at 9:41 AM Wei Gao via ltp <ltp@lists.linux.it> wrote:

> New kernel commit lead test case failure with following error message:
> listmount04.c:128: TFAIL: invalid mnt_id_req.spare expected EINVAL: EBADF
> (9)
>
> Detail of new kernel commit:
> commit: 78f0e33cd6c939a555aa80dbed2fec6b333a7660
> fs/namespace: correctly handle errors returned by grab_requested_mnt_ns
>
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> configure.ac | 1 +
> .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------
> 2 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 0480f46ca..fcff90799 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -263,6 +263,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_MEMBERS([struct mnt_id_req.mnt_ns_fd],,,[#include <sys/mount.h>])
> AC_CHECK_TYPES([struct statmount],,,[#include <sys/mount.h>])
> AC_CHECK_MEMBERS([struct statmount.mnt_ns_id],,,[#include <unistd.h>
> #include <linux/mount.h>])
> diff --git a/testcases/kernel/syscalls/listmount/listmount04.c
> b/testcases/kernel/syscalls/listmount/listmount04.c
> index a52bad064..3be3be4f2 100644
> --- a/testcases/kernel/syscalls/listmount/listmount04.c
> +++ b/testcases/kernel/syscalls/listmount/listmount04.c
> @@ -18,6 +18,7 @@
> #include "lapi/mount.h"
> #include "lapi/syscalls.h"
>
> +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
> #define MNT_SIZE 32
>
> static struct mnt_id_req *request;
> @@ -26,7 +27,7 @@ static uint64_t mnt_ids[MNT_SIZE];
> static struct tcase {
> int req_usage;
> uint32_t size;
> - uint32_t spare;
> + uint32_t mnt_ns_fd;
> uint64_t mnt_id;
> uint64_t param;
> uint64_t *mnt_ids;
> @@ -73,12 +74,12 @@ static struct tcase {
> {
> .req_usage = 1,
> .size = MNT_ID_REQ_SIZE_VER0,
> - .spare = -1,
> + .mnt_ns_fd = -1,
> .mnt_id = LSMT_ROOT,
> .mnt_ids = mnt_ids,
> .nr_mnt_ids = MNT_SIZE,
> - .exp_errno = EINVAL,
> - .msg = "invalid mnt_id_req.spare",
> + .exp_errno = EBADF,
> + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor",
> },
> {
> .req_usage = 1,
> @@ -122,7 +123,7 @@ static void run(unsigned int n)
> req->mnt_id = tc->mnt_id;
> req->param = tc->param;
> req->size = tc->size;
> - req->spare = tc->spare;
> + req->mnt_ns_fd = tc->mnt_ns_fd;
> }
>
> TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
> @@ -133,9 +134,14 @@ static void run(unsigned int n)
> static struct tst_test test = {
> .test = run,
> .tcnt = ARRAY_SIZE(tcases),
> - .min_kver = "6.8",
> + .min_kver = "6.18",
>

Reviewed-by: Li Wang <liwang@redhat.com>

This patch looks good, I have one question do we need to cover the 'spare'
field test for kernels between 6.8 to 6.18?

.bufs = (struct tst_buffers []) {
> { &request, .size = MNT_ID_REQ_SIZE_VER0 },
> {},
> },
> };
> +
> +#else
> + TST_TEST_TCONF(
> + "This system does not support mnt_id_req.mnt_ns_fd.");
> +#endif /* HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD */
> --
> 2.51.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

--
Regards,
Li Wang