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

Wei Gao via ltp
2025-12-14T01:54:30Z

On Fri, Dec 12, 2025 at 04:11:56PM +0100, Petr Vorel wrote:
> > > Hi!
> > > > > -#ifndef HAVE_STRUCT_MNT_ID_REQ
> > > > > -struct mnt_id_req {
> > > > > +struct mnt_id_req_fallback {
> > > > > uint32_t size;
> > > > > - uint32_t spare;
> > > > > + uint32_t mnt_ns_fd;
> > > > > uint64_t mnt_id;
> > > > > uint64_t param;
> > > > > uint64_t mnt_ns_id;
> > > > > };
> > > > > +
> > > > > +#if !defined(HAVE_STRUCT_MNT_ID_REQ) || !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
> > > > Shouldn't be !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
> > > > !defined(HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD) ?
>
> > > > Also, this patchset introduces compilation error on old systems:
>
> > > > In file included from listmount03.c:13:0:
> > > > listmount.h:20:4: error: 'struct mnt_id_req' has no member named 'mnt_id'
> > > > .mnt_id = mnt_id,
>
> > > > Obviously some definition is wrong.
>
> > > That looks like we need configure check for mnt_id too however that
> > > happens in a different test.
>
> > Yes:
>
> Actually no, the problem was that typedef expects using pointer.
> And we now need to use it in all tests, therefore listmount.h needs to be
> updated.
>
> Below is diff (without handling different errno).
>
> Kind regards,
> Petr
>
> diff --git configure.ac configure.ac
> index fcff907991..2866ee981d 100644
> --- configure.ac
> +++ configure.ac
> @@ -172,6 +172,9 @@ AC_CHECK_FUNCS_ONCE([ \
> ])
> AC_CHECK_FUNCS(mkdtemp,[],AC_MSG_ERROR(mkdtemp() not found!))
>
> +# Defined in <linux/mount.h>, but include/lapi/mount.h includes <sys/mount.h> */
> +AC_CHECK_MEMBERS([struct mnt_id_req.mnt_ns_fd],,,[#include <sys/mount.h>])
> +
> AC_CHECK_MEMBERS([struct fanotify_event_info_fid.fsid.__val],,,[#include <sys/fanotify.h>])
> AC_CHECK_MEMBERS([struct perf_event_mmap_page.aux_head],,,[#include <linux/perf_event.h>])
> AC_CHECK_MEMBERS([struct sigaction.sa_sigaction],[],[],[#include <signal.h>])
> @@ -261,9 +264,6 @@ AC_CHECK_TYPES([struct mount_attr],,,[
> AC_CHECK_TYPES([struct cachestat_range],,,[#include <sys/mman.h>])
> 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 include/lapi/mount.h include/lapi/mount.h
> index 7b1c4ca0fe..5d9ccde28d 100644
> --- include/lapi/mount.h
> +++ include/lapi/mount.h
> @@ -53,7 +53,7 @@ struct mnt_id_req_fallback {
> uint64_t mnt_ns_id;
> };
>
> -#if !defined(HAVE_STRUCT_MNT_ID_REQ) || !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
> +#ifndef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_ID
> typedef struct mnt_id_req_fallback mnt_id_req;
> #else
> typedef struct mnt_id_req mnt_id_req;
> diff --git testcases/kernel/syscalls/listmount/listmount.h testcases/kernel/syscalls/listmount/listmount.h
> index aad927f714..74f334c74e 100644
> --- testcases/kernel/syscalls/listmount/listmount.h
> +++ testcases/kernel/syscalls/listmount/listmount.h
> @@ -8,6 +8,7 @@
>
> #define _GNU_SOURCE
>
> +#include "config.h"
> #include "tst_test.h"
> #include "lapi/mount.h"
> #include "lapi/syscalls.h"
> @@ -15,11 +16,10 @@
> static inline ssize_t listmount(uint64_t mnt_id, uint64_t last_mnt_id,
> uint64_t list[], size_t num, unsigned int flags)
> {
> - struct mnt_id_req req = {
> - .size = MNT_ID_REQ_SIZE_VER0,
> - .mnt_id = mnt_id,
> - .param = last_mnt_id,
> - };
> + mnt_id_req *req = NULL;
> + req->size = MNT_ID_REQ_SIZE_VER0;
> + req->mnt_id = mnt_id;
> + req->param = last_mnt_id;
>
> return tst_syscall(__NR_listmount, &req, list, num, flags);
Thanks for such detail feedback, will sent next patch.
I guess we need s/&req/req/,
or i think simple s/struct mnt_id_req/mnt_id_req/ more better.
> }