From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v5] listmount04.c: Update case support mnt_id_req.mnt_ns_fd
Date: Fri, 12 Dec 2025 15:20:45 +0100 [thread overview]
Message-ID: <20251212142045.GD125889@pevik> (raw)
In-Reply-To: <aTwREz2-YroAAyl_@yuki.lan>
> 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:
Do we still need the check for the struct mnt_id_req now? I'd say no:
-AC_CHECK_TYPES([struct mnt_id_req],,,[#include <sys/mount.h>])
+AC_CHECK_MEMBERS([struct mnt_id_req.mnt_ns_fd, struct mnt_id_req.mnt_id],,,[#include <sys/mount.h>])
-#if !defined(HAVE_STRUCT_MNT_ID_REQ) || !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
+#if !defined(HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD) || !defined(HAVE_STRUCT_MNT_ID_REQ_MNT_ID)
But we also need to change listmount.h to use the struct fallback. Full diff is
at the end.
> > https://github.com/pevik/ltp/actions/runs/20166087670/job/57889711762
> > (CI does not work, therefore I pushed you patchset.)
> > > +typedef struct mnt_id_req_fallback mnt_id_req;
> > > +#else
> > > +typedef struct mnt_id_req mnt_id_req;
> > > #endif
> > ...
> > > +static void setup(void)
> > > +{
> > > + if (tst_kvercmp(6, 18, 0) >= 0) {
> > > + tcases[4].exp_errno = EBADF;
> > > + tcases[4].msg = "invalid mnt_id_req.mnt_ns_fd (EBADF)";
> > Hardcoding array index is asking for problems in the future.
> > That's why I suggested more complicated code in previous version.
> > https://lore.kernel.org/ltp/20251211115111.GA63924@pevik/
> Another solution would be to define testcases for both for EINVAL and
> EBADF and add a flag which should be enabled on newer kernel:
> #define BEFORE_6_18 1
> #define AFTER_6_18 2
> ...
> {
> .req_usage = 1,
> .size = MNT_ID_REQ_SIZE_VER0,
> .spare = -1,
> .mnt_id = LSMT_ROOT,
> .mnt_ids = mnt_ids,
> .nr_mnt_ids = MNT_SIZE,
> .exp_errno = EINVAL,
> .msg = "invalid mnt_id_req.spare",
> .kver = BEFORE_6_18,
> },
> {
> .req_usage = 1,
> .size = MNT_ID_REQ_SIZE_VER0,
> .spare = -1,
> .mnt_id = LSMT_ROOT,
> .mnt_ids = mnt_ids,
> .nr_mnt_ids = MNT_SIZE,
> .exp_errno = EBADF,
> .msg = "invalid mnt_id_req.mnt_nf_fd",
> .kver = AFTER_6_18,
> },
> ...
> static void run(...)
> {
> ...
> if (tc->kver && tc->kver != kver)
> return;
Yeah that would work as well, but I suppose TCONF will be needed
due check for results.
> ...
> }
> static void setup(void)
> {
> if (tst_kvercmp(6, 18, 0) >= 0)
> kver = AFTER_6_18;
> else
> kver = BEFORE_6_18;
> }
Kind regards,
Petr
Diff without kernel version change.
+++ configure.ac
@@ -262,8 +262,8 @@ 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 mnt_id_req],,,[#include <sys/mount.h>])
+AC_CHECK_MEMBERS([struct mnt_id_req.mnt_ns_fd, struct mnt_id_req.mnt_id],,,[#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..8bde0e563a 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
+#if !defined(HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD) || !defined(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);
}
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-12-12 14:21 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 14:39 [LTP] [PATCH v1] listmount04.c: Update case support mnt_id_req.mnt_ns_fd Wei Gao via ltp
2025-11-28 3:26 ` Li Wang via ltp
2025-11-28 7:37 ` Wei Gao via ltp
2025-12-08 11:51 ` Petr Vorel
2025-12-09 0:50 ` Wei Gao via ltp
2025-12-09 0:41 ` [LTP] [PATCH v2] " Wei Gao via ltp
2025-12-09 11:17 ` Petr Vorel
2025-12-09 15:53 ` Cyril Hrubis
2025-12-09 17:49 ` Petr Vorel
2025-12-10 6:19 ` [LTP] [PATCH v3] " Wei Gao via ltp
2025-12-10 8:38 ` Petr Vorel
2025-12-11 1:59 ` [LTP] [PATCH v4] " Wei Gao via ltp
2025-12-11 9:25 ` Cyril Hrubis
2025-12-11 11:51 ` Petr Vorel
2025-12-12 11:50 ` [LTP] [PATCH v5] " Wei Gao via ltp
2025-12-12 12:28 ` Petr Vorel
2025-12-12 12:56 ` Cyril Hrubis
2025-12-12 14:20 ` Petr Vorel [this message]
2025-12-12 15:11 ` Petr Vorel
2025-12-14 1:54 ` Wei Gao via ltp
2025-12-15 15:22 ` Petr Vorel
2025-12-14 2:15 ` [LTP] [PATCH v6] " Wei Gao via ltp
2025-12-15 15:20 ` Petr Vorel
2025-12-16 8:08 ` Li Wang via ltp
2025-12-17 9:32 ` Cyril Hrubis
2025-12-17 13:15 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251212142045.GD125889@pevik \
--to=pvorel@suse.cz \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.