listmount04.c: Update case support mnt_id_req.mnt_ns_fd
PATCH 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
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
--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)
configure.ac +1 -0
@@ -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>])
testcases/kernel/syscalls/listmount/listmount04.c +12 -6
@@ -18,6 +18,7 @@#include "lapi/mount.h" #include "lapi/syscalls.h" +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD #define MNT_SIZE 32static 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" , .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 */
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 76 lines · Wei Gao via ltp
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:78f0e33cd6c939a555aa80dbed2fec6b333a7660fs/namespace: correctly handle errors returned bygrab_requested_mnt_nsSigned-off-by Wei Gao <[email protected]>--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)configure.ac +0
-0@@ -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>])configure.ac +1
-0+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>])testcases/kernel/syscalls/listmount/listmount04.c +6
-5@@ -18,6 +18,7 @@#include "lapi/mount.h" #include "lapi/syscalls.h" +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD #define MNT_SIZE 32static 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,
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 138
Quoted 6 lines
testcases/kernel/syscalls/listmount/listmount04.c +1
-1@@ -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" ,
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 []) {Quoted 17 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-1{ &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
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 90 lines · Li Wang
Hi Wei,
Quoted 76 lines · Wei Gao via ltp
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:78f0e33cd6c939a555aa80dbed2fec6b333a7660fs/namespace: correctly handle errors returned bygrab_requested_mnt_nsSigned-off-by Wei Gao <[email protected]>--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)configure.ac +0
-0@@ -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>])configure.ac +1
-0+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>])testcases/kernel/syscalls/listmount/listmount04.c +6
-5@@ -18,6 +18,7 @@#include "lapi/mount.h" #include "lapi/syscalls.h" +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD #define MNT_SIZE 32static 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,testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 138
Quoted 6 lines
testcases/kernel/syscalls/listmount/listmount04.c +1
-1@@ -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 <[email protected]>
Quoted 2 lines
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?
I think only keep tracking latest feature's change can make our life easy for this case :)
Quoted 24 lines
.bufs = (struct tst_buffers []) {Quoted 17 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-1{ &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/ltpSignature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi all,
first, we have a different patch increasing value to 6.11.
https://lore.kernel.org/ltp/[email protected]/
Quoted 80 lines · Li Wang
Quoted 78 lines
Hi Wei,
Quoted 73 lines · Wei Gao via ltp
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:78f0e33cd6c939a555aa80dbed2fec6b333a7660fs/namespace: correctly handle errors returned bygrab_requested_mnt_nsSigned-off-by Wei Gao <[email protected]>--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)configure.ac +0
-0@@ -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>])configure.ac +1
-0+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>])testcases/kernel/syscalls/listmount/listmount04.c +6
-5@@ -18,6 +18,7 @@#include "lapi/mount.h" #include "lapi/syscalls.h" +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD #define MNT_SIZE 32static 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; }
Quoted 7 lines
Quoted 7 lines
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 137
Quoted 7 lines
testcases/kernel/syscalls/listmount/listmount04.c +1
-1TST_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" ,
FYI this is a runtime check, but the problem is with kernel headers. include/lapi/mount.h [1] uses <sys/mount.h> (see LTP include/lapi/mount.h [1] and the reason why we did endup using <sys/mount.h> instead of <linux/mount.h>
[2] [3]), but glibc (since certain version, unlike musl) includes <linux/mount.h>. Therefore while the problem is on current Debian testing with linux-libc-dev all 6.17.9-1 (it was working in previous builds with linux-libc-dev all 6.17.8-1). But OTOH my openSUSE Tumbleweed VM with 6.18.0-rc6-4.gfea0d97 works without this patch. Also SLE16 with 6.12 based kernel works without this patch.
tst_test.c:2028: TINFO: Tested kernel: 6.18.0-rc6-4.gfea0d97-default #1 SMP PREEMPT_DYNAMIC Sat Nov 22 19:46:55 UTC 2025 (fea0d97) x86_64 tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO: CONFIG_FAULT_INJECTION kernel option detected which might slow the execution tst_test.c:1846: TINFO: Overall timeout per run is 0h 02m 00s
listmount04.c:128: TPASS: request points to unaccessible memory : EFAULT (14)
listmount04.c:128: TPASS: mnt_ids points to unaccessible memory : EFAULT (14)
listmount04.c:128: TPASS: invalid flags : EINVAL (22)
listmount04.c:128: TPASS: insufficient mnt_id_req.size : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.spare : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.param : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.mnt_id : EINVAL (22)
listmount04.c:128: TPASS: non-existant mnt_id : ENOENT (2)
[1] https://github.com/linux-test-project/ltp/blob/master/include/lapi/mount.h
[2] https://github.com/linux-test-project/ltp/commit/a2300dc0f51f46ffb07a465d8734639dbe3af044
[3] https://github.com/linux-test-project/ltp/commit/1feeb57811a4aa2f56ad85edf69a8ea870867c65
Quoted 6 lines
Quoted 4 lines
Reviewed-by Li Wang <[email protected]>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?
I think only keep tracking latest feature's change can make our life easy for this case :)
Due the above IMHO we should consider support for <6.11, 6.17> as well. We have similar crazy approach for a struct change in include/lapi/fanotify.h, see FSID_VAL_MEMBER().
Kind regards,
Petr
Quoted 22 lines
Quoted 22 lines
.bufs = (struct tst_buffers []) {Quoted 15 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-1{ &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/ltpSignature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 4 lines · Petr Vorel
Hi all,
first, we have a different patch increasing value to 6.11.
https://lore.kernel.org/ltp/[email protected]/
I guess above new change should not handled within this commit correct?
Quoted 118 lines
Quoted 81 lines · Li Wang
Quoted 78 lines
Hi Wei,
Quoted 73 lines · Wei Gao via ltp
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:78f0e33cd6c939a555aa80dbed2fec6b333a7660fs/namespace: correctly handle errors returned bygrab_requested_mnt_nsSigned-off-by Wei Gao <[email protected]>--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-)configure.ac +0
-0@@ -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>])configure.ac +1
-0+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>])testcases/kernel/syscalls/listmount/listmount04.c +6
-5@@ -18,6 +18,7 @@#include "lapi/mount.h" #include "lapi/syscalls.h" +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD #define MNT_SIZE 32static 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; }Quoted 7 lines
Quoted 7 lines
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 137
Quoted 7 lines
testcases/kernel/syscalls/listmount/listmount04.c +1
-1TST_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" ,FYI this is a runtime check, but the problem is with kernel headers.
include/lapi/mount.h[1] uses <sys/mount.h> (see LTPinclude/lapi/mount.h[1] and the reason why we did endup using <sys/mount.h> instead of <linux/mount.h>
[2] [3]), but glibc (since certain version, unlike musl) includes <linux/mount.h>. Therefore while the problem is on current Debian testing with linux-libc-dev all 6.17.9-1 (it was working in previous builds with linux-libc-dev all 6.17.8-1). But OTOH my openSUSE Tumbleweed VM with 6.18.0-rc6-4.gfea0d97 works without this patch. Also SLE16 with 6.12 based kernel works without this patch.tst_test.c:2028: TINFO: Tested kernel: 6.18.0-rc6-4.gfea0d97-default #1 SMP
PREEMPT_DYNAMICSat Nov 22 19:46:55 UTC 2025 (fea0d97)x86_64tst_kconfig.c:88: TINFO: Parsing kernel config '/proc/config.gz'
tst_kconfig.c:676: TINFO:CONFIG_FAULT_INJECTIONkernel option detected which might slow the execution tst_test.c:1846: TINFO: Overall timeout per run is 0h 02m 00s
listmount04.c:128: TPASS: request points to unaccessible memory : EFAULT (14)
listmount04.c:128: TPASS:mnt_idspoints to unaccessible memory : EFAULT (14)
listmount04.c:128: TPASS: invalid flags : EINVAL (22)
listmount04.c:128: TPASS: insufficient mnt_id_req.size : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.spare : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.param : EINVAL (22)
listmount04.c:128: TPASS: invalid mnt_id_req.mnt_id : EINVAL (22)
listmount04.c:128: TPASS: non-existantmnt_id: ENOENT (2)[1] https://github.com/linux-test-project/ltp/blob/master/include/lapi/mount.h
[2] https://github.com/linux-test-project/ltp/commit/a2300dc0f51f46ffb07a465d8734639dbe3af044
[3] https://github.com/linux-test-project/ltp/commit/1feeb57811a4aa2f56ad85edf69a8ea870867c65Quoted 1 line
Quoted 1 line
Reviewed-by Li Wang <[email protected]>
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
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?
I think only keep tracking latest feature's change can make our life easy for this case :)
Due the above IMHO we should consider support for <6.11, 6.17> as well. We have similar crazy approach for a struct change in
include/lapi/fanotify.h, seeFSID_VAL_MEMBER().
v2 patch is sent wihtout touch min version, since another patch will increase min version seperately.
Quoted 26 lines
Kind regards,
PetrQuoted 22 lines
Quoted 22 lines
.bufs = (struct tst_buffers []) {Quoted 15 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-1{ &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/ltpSignature · 2 lines
Regards, Li Wang
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
In reply to Wei Gao via ltpNew 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
--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
configure.ac +1 -0
@@ -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>])
testcases/kernel/syscalls/listmount/listmount04.c +17 -0
@@ -26,7 +26,11 @@ static uint64_t mnt_ids[MNT_SIZE]; static struct tcase { int req_usage; uint32_t size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id; uint64_t param; uint64_t *mnt_ids;
@@ -73,12 +77,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids, .nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif }, { .req_usage = 1,
@@ -122,7 +135,11 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + req->mnt_ns_fd = tc->mnt_ns_fd; +#else req->spare = tc->spare; +#endif } TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 1 line
New kernel commit lead test case failure with following error message:
"New" will eventually become "old" :). Why not to state that it's change from v6.18-rc7? (it saves people in the future to search.)
Quoted 1 line
listmount04.c:128: TFAIL: invalid mnt_id_req.spare expected EINVAL: EBADF (9)
2 things needs to be changed.
Quoted 27 lines
Detail of new kernel commit:
commit:78f0e33cd6c939a555aa80dbed2fec6b333a7660fs/namespace: correctly handle errors returned bygrab_requested_mnt_nsSigned-off-by Wei Gao <[email protected]>--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)configure.ac +1
-0@@ -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>])testcases/kernel/syscalls/listmount/listmount04.c +0
-0
testcases/kernel/syscalls/listmount/listmount04.c static uint64_t mnt_ids[MNT_SIZE]; · line 29
Quoted 4 lines
testcases/kernel/syscalls/listmount/listmount04.c +1
-0@@ -26,7 +26,11 @@ static uint64_t mnt_ids[MNT_SIZE]; static struct tcase { int req_usage; uint32_t size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
Any time you modify configure.ac please remember to use:
#include "config.h"
Quoted 16 lines
testcases/kernel/syscalls/listmount/listmount04.c +7
-0+uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id;uint64_t param;uint64_t *mnt_ids;@@ -73,12 +77,21 @@ static struct tcase { { .req_usage = 1, .size = MNT_ID_REQ_SIZE_VER0, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif
testcases/kernel/syscalls/listmount/listmount04.c static struct tcase { · line 94
Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-0.mnt_id = LSMT_ROOT, .mnt_ids = mnt_ids, .nr_mnt_ids =MNT_SIZE , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif
I tried to run it on VM with affected (new) libc and old kernel and it fails:
tst_test.c:2028: TINFO: Tested kernel: 6.12.38+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.38-1 (2025-07-16) x86_64 tst_kconfig.c:88: TINFO: Parsing kernel config '/boot/config-6.12.38+deb13-amd64'
tst_test.c:1846: TINFO: Overall timeout per run is 0h 00m 30s
listmount04.c:146: TPASS: request points to unaccessible memory : EFAULT (14)
listmount04.c:146: TPASS: mnt_ids points to unaccessible memory : EFAULT (14)
listmount04.c:146: TPASS: invalid flags : EINVAL (22)
listmount04.c:146: TPASS: insufficient mnt_id_req.size : EINVAL (22)
listmount04.c:146: TFAIL: invalid mnt_id_req.mnt_ns_fd bad file descriptor expected EBADF: EINVAL (22)
Usual "headers vs running kernel mismatch problem".
@Li, @Cyril Do we care about these incompatibilities? Could we just accept both? Or we don't care?
Obviously it works on new enough kernel (patch change is from 6.18):
tst_test.c:2028: TINFO: Tested kernel: 6.17.11+deb14-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.17.11-1 (2025-12-07) x86_64 tst_kconfig.c:88: TINFO: Parsing kernel config '/boot/config-6.17.11+deb14-amd64'
tst_test.c:1846: TINFO: Overall timeout per run is 0h 00m 30s
listmount04.c:146: TPASS: request points to unaccessible memory : EFAULT (14)
listmount04.c:146: TPASS: mnt_ids points to unaccessible memory : EFAULT (14)
listmount04.c:146: TPASS: invalid flags : EINVAL (22)
listmount04.c:146: TPASS: insufficient mnt_id_req.size : EINVAL (22)
listmount04.c:146: TPASS: invalid mnt_id_req.mnt_ns_fd bad file descriptor : EBADF (9) listmount04.c:146: TPASS: invalid mnt_id_req.param : EINVAL (22)
listmount04.c:146: TPASS: invalid mnt_id_req.mnt_id : EINVAL (22)
listmount04.c:146: TPASS: non-existant mnt_id : ENOENT (2)
Kind regards,
Petr
Quoted 12 lines
testcases/kernel/syscalls/listmount/listmount04.c +4
-0}, { .req_usage = 1,@@ -122,7 +135,11 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + req->mnt_ns_fd = tc->mnt_ns_fd; +#else req->spare = tc->spare; +#endif
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 18 lines
Quoted 18 lines
testcases/kernel/syscalls/listmount/listmount04.c +7
-0+uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id;uint64_t param;uint64_t *mnt_ids;@@ -73,12 +77,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids,
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c static struct tcase { · line 94
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-0.nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif
This is never going to work, how kernel interprets the value depends on solely on the running kernel verision not on headers that were present during the compilation.
What we need to do is to differentiate the expected errno based on running kernel version.
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 23 lines
Hi!
Quoted 22 lines
Quoted 22 lines
testcases/kernel/syscalls/listmount/listmount04.c +10
-0+uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id;uint64_t param;uint64_t *mnt_ids;@@ -73,12 +77,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids, .nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor",
Quoted 8 lines
Quoted 4 lines
testcases/kernel/syscalls/listmount/listmount04.c static struct tcase { · line 94
Quoted 4 lines
testcases/kernel/syscalls/listmount/listmount04.c +2
-0+#else .exp_errno = EINVAL, .msg = "invalid mnt_id_req.spare", +#endif This is never going to work, how kernel interprets the value depends on solely on the running kernel verision not on headers that were present during the compilation.
+1, I realized that myself as well.
Quoted 2 lines
What we need to do is to differentiate the expected errno based on running kernel version.
Other option would be just accept both errnos (as kernel developers seem to be not forcing us to be pedantic on kernel internals - recent swapon03.c rewrite requirement). But lets use tst_kvercmp() to not delay the fix with more discussion.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v3 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
In reply to Wei Gao via ltpKernel change from v6.18-rc7 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
--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
configure.ac +1 -0
@@ -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>])
testcases/kernel/syscalls/listmount/listmount04.c +25 -1
@@ -14,6 +14,7 @@#define _GNU_SOURCE +#include "config.h" #include "tst_test.h" #include "lapi/mount.h" #include "lapi/syscalls.h"
@@ -26,7 +27,11 @@ static uint64_t mnt_ids[MNT_SIZE]; static struct tcase { int req_usage; uint32_t size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id; uint64_t param; uint64_t *mnt_ids;
@@ -73,12 +78,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids, .nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif }, { .req_usage = 1,
@@ -122,7 +136,17 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; - req->spare = tc->spare; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) + req->mnt_ns_fd = tc->mnt_ns_fd; +else +tst_brk (TCONF ,"Skipping test, kernel version should > 6.18" ); +#else +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) +tst_brk (TCONF ,"Skipping test, kernel version should < 6.18" ); +else + req->spare = tc->spare; +#endif } TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Quoted 5 lines
Kernel change from v6.18-rc7 lead test case failure with following error message:
listmount04.c:128: TFAIL: invalid mnt_id_req.spare expected EINVAL: EBADF (9)testcases/kernel/syscalls/listmount/listmount04.c +0
-0.req_usage = 1,
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 143
Quoted 9 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-1@@ -122,7 +136,17 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; - req->spare = tc->spare; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) + req->mnt_ns_fd = tc->mnt_ns_fd; +else +tst_brk (TCONF ,"Skipping test, kernel version should > 6.18" );
nit: "should be >= " (missing "be" and "=").
OK, for insufficient kernel version only first test (which does not set .req_usage) will be run.
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 146
Quoted 3 lines
testcases/kernel/syscalls/listmount/listmount04.c +3
-0+#else +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) +tst_brk (TCONF ,"Skipping test, kernel version should < 6.18" );
nit: "should be" (missing "be").
Thanks!
Kind regards,
Petr
Quoted 4 lines
testcases/kernel/syscalls/listmount/listmount04.c +3
-0+ else + req->spare = tc->spare; +#endif }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v4 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
In reply to Wei Gao via ltpKernel change from v6.18-rc7 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
--- configure.ac | 1 + .../kernel/syscalls/listmount/listmount04.c | 26 ++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
v3->v4: fix grammatical errors
configure.ac +1 -0
@@ -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>])
testcases/kernel/syscalls/listmount/listmount04.c +25 -1
@@ -14,6 +14,7 @@#define _GNU_SOURCE +#include "config.h" #include "tst_test.h" #include "lapi/mount.h" #include "lapi/syscalls.h"
@@ -26,7 +27,11 @@ static uint64_t mnt_ids[MNT_SIZE]; static struct tcase { int req_usage; uint32_t size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id; uint64_t param; uint64_t *mnt_ids;
@@ -73,12 +78,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids, .nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif }, { .req_usage = 1,
@@ -122,7 +136,17 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; - req->spare = tc->spare; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) + req->mnt_ns_fd = tc->mnt_ns_fd; +else +tst_brk (TCONF ,"Skipping test, kernel version should be >= 6.18" ); +#else +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) +tst_brk (TCONF ,"Skipping test, kernel version should be < 6.18" ); +else + req->spare = tc->spare; +#endif } TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
Signature · 5 lines
2.51.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 47 lines
#define
_GNU_SOURCEtestcases/kernel/syscalls/listmount/listmount04.c +14
-0+#include "config.h" #include "tst_test.h" #include "lapi/mount.h" #include "lapi/syscalls.h" @@ -26,7 +27,11 @@ static uint64_t mnt_ids[MNT_SIZE]; static struct tcase { int req_usage; uint32_t size; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + uint32_t mnt_ns_fd; +#else uint32_t spare; +#endif uint64_t mnt_id; uint64_t param; uint64_t *mnt_ids;@@ -73,12 +78,21 @@ static struct tcase { { .req_usage = 1, .size =MNT_ID_REQ_SIZE_VER0 , +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .mnt_ns_fd = -1, +#else .spare = -1, +#endif .mnt_id =LSMT_ROOT , .mnt_ids = mnt_ids, .nr_mnt_ids = MNT_SIZE, +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD + .exp_errno =EBADF , + .msg = "invalid mnt_id_req.mnt_ns_fd bad file descriptor", +#else .exp_errno =EINVAL , .msg = "invalid mnt_id_req.spare", +#endif }, {testcases/kernel/syscalls/listmount/listmount04.c +1
-1.req_usage = 1,@@ -122,7 +136,17 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; - req->spare = tc->spare; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 149
Quoted 10 lines
testcases/kernel/syscalls/listmount/listmount04.c +10
-0+if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) + req->mnt_ns_fd = tc->mnt_ns_fd; +else +tst_brk (TCONF ,"Skipping test, kernel version should be >= 6.18" ); +#else +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) +tst_brk (TCONF ,"Skipping test, kernel version should be < 6.18" ); +else + req->spare = tc->spare; +#endif
I do not like this solution. Here we disable the test on newer kernel if it was compiled on older headers and vice versa.
There are actually two problems to be solved and they are independent of each other and we shouldn't mix these two.
First problem is that the mnt_ns_fd is not defined on older headers. That should be fixed by a fallback defintion in lapi/. The spare in lapi/mount.h in struct mnt_id_req should be renamed to mnt_ns_fd. And we should use that structure if mnt_id_req is not defined in system headers. I guess that we can use typedef for that and do something as:
struct mnt_id_req_fallback {
uint32_t size;
...
};#if !defined(HAVE_STRUCT_MNT_ID_REQ) || !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD typedef struct mnt_id_req_fallback mnt_id_req
#else
typedef struct mnd_id_req mnt_id_req
#endif
And then use mnt_id_req in test with the guarantee that the mnt_ns_fd is always there.
The second problem is the expected errno. That should be just set once based on the kernel version in the test setup().
Quoted 6 lines
testcases/kernel/syscalls/listmount/listmount04.c +0
-0} TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,Signature · 1 line
2.51.0
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
...
Quoted 11 lines
Quoted 11 lines
testcases/kernel/syscalls/listmount/listmount04.c +6
-1@@ -122,7 +136,17 @@ static void run(unsigned int n) req->mnt_id = tc->mnt_id; req->param = tc->param; req->size = tc->size; - req->spare = tc->spare; +#ifdef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD +if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) + req->mnt_ns_fd = tc->mnt_ns_fd; +else +tst_brk (TCONF ,"Skipping test, kernel version should be >= 6.18" ); +#else
Quoted 8 lines
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 149
Quoted 5 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-0+if ((tst_kvercmp (6 ,18 ,0 )) >=0 ) +tst_brk (TCONF ,"Skipping test, kernel version should be < 6.18" ); +else + req->spare = tc->spare; +#endif I do not like this solution. Here we disable the test on newer kernel if it was compiled on older headers and vice versa.
Thanks for catching this up. I had a feeling something is wrong but was not sure what.
Quoted 8 lines
There are actually two problems to be solved and they are independent of each other and we shouldn't mix these two.
First problem is that the
mnt_ns_fdis not defined on older headers. That should be fixed by a fallback defintion in lapi/. The spare inlapi/mount.hin structmnt_id_reqshould be renamed tomnt_ns_fd. And we should use that structure ifmnt_id_reqis not defined in system headers. I guess that we can use typedef for that and do something as:
OK, I did not realize that struct size is actually the same, only struct member has changed so that we can happily pass that to any kernel version.
Quoted 11 lines
struct mnt_id_req_fallback { uint32_t size; ... };#if !defined(HAVE_STRUCT_MNT_ID_REQ) || !HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD typedef struct
mnt_id_req_fallbackmnt_id_req
#else
typedef structmnd_id_reqmnt_id_req
#endif
Quoted 5 lines
And then use
mnt_id_reqin test with the guarantee that themnt_ns_fdis always there.The second problem is the expected errno. That should be just set once based on the kernel version in the test
setup().
+1. I was also thinking about moving this to setup to prevent repeated detecting but was not sure how to do it in elegant way as errno is in the struct. I guess you mean just to store result of tst_kvercmp(6, 18, 0), but even that is not enough. The cleanest way looks to me to add another struct member int exp_errno_old:
static bool old_kernel = true;
static struct tcase {
...
int exp_errno;
int exp_errno_old;
}static void setup()
{
if ((tst_kvercmp(6, 18, 0)) < 0)
old_kernel = false;
}static void run(unsigned int n)
{
...
int exp_errno = (tc->exp_errno_old && old_kernel ? tc->exp_errno_old : tc->exp_errno);
TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
tc->nr_mnt_ids, tc->flags), exp_errno,
"%s", tc->msg);
}Also when looking in the code I'd personally factor out tc->req_usage to make it
obvious it's not called by first tcases member.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
In reply to Wei Gao via ltpKernel change from v6.18-rc7 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
--- configure.ac | 1 + include/lapi/mount.h | 10 +++++++--- .../kernel/syscalls/listmount/listmount04.c | 16 +++++++++++++--- 3 files changed, 21 insertions(+), 6 deletions(-)
v4->v5: Update base solution of Cyril
configure.ac +1 -0
@@ -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>])
include/lapi/mount.h +7 -3
@@ -45,14 +45,18 @@# define MS_NOSYMFOLLOW 256#endif -#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 +typedef struct mnt_id_req_fallback mnt_id_req ; +#else +typedef struct mnt_id_req mnt_id_req ;#endif #ifndef HAVE_STRUCT_STATMOUNT
testcases/kernel/syscalls/listmount/listmount04.c +13 -3
@@ -14,13 +14,14 @@#define _GNU_SOURCE +#include "config.h" #include "tst_test.h" #include "lapi/mount.h" #include "lapi/syscalls.h" #define MNT_SIZE 32 -static struct mnt_id_req *request; +static mnt_id_req *request;static uint64_t mnt_ids[MNT_SIZE ]; static struct tcase {
@@ -113,7 +114,7 @@ static struct tcase {static void run (unsigned int n) {struct tcase *tc = &tcases[n]; -struct mnt_id_req *req =NULL ; +mnt_id_req *req =NULL ;memset (mnt_ids,0 ,sizeof (mnt_ids));
@@ -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->spare; } TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
@@ -130,8 +131,17 @@ static void run(unsigned int n) "%s", tc->msg); } +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)" ; + } +} +static struct tst_test test = { .test = run, + .setup = setup, .tcnt =ARRAY_SIZE (tcases), .min_kver ="6.11" , .bufs = (struct tst_buffers []) {
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei, all,
...
include/lapi/mount.h line 56
Quoted 12 lines
include/lapi/mount.h +4
-3-#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.
https://github.com/pevik/ltp/actions/runs/20166087670/job/57889711762
(CI does not work, therefore I pushed you patchset.)
Quoted 4 lines
include/lapi/mount.h +3
-0+typedef struct mnt_id_req_fallback mnt_id_req ; +#else +typedef struct mnt_id_req mnt_id_req ;#endif
...
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 138
Quoted 5 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-0+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/
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 15 lines
include/lapi/mount.h line 56
Quoted 12 lines
include/lapi/mount.h +4
-3-#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) ?
Quoted 7 lines
Also, this patchset introduces compilation error on old systems:
In file included from listmount03.c:13:0:
listmount.h:20:4: error: 'structmnt_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.
Quoted 18 lines
https://github.com/pevik/ltp/actions/runs/20166087670/job/57889711762
(CI does not work, therefore I pushed you patchset.)
Quoted 4 lines
include/lapi/mount.h +3
-0+typedef struct mnt_id_req_fallback mnt_id_req ; +#else +typedef struct mnt_id_req mnt_id_req ;#endif ...
testcases/kernel/syscalls/listmount/listmount04.c static void run(unsigned int n) · line 138
Quoted 5 lines
testcases/kernel/syscalls/listmount/listmount04.c +5
-0+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.
Quoted 2 lines
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;
...
}static void setup(void)
{
if (tst_kvercmp(6, 18, 0) >= 0)
kver = AFTER_6_18;
else
kver = BEFORE_6_18;
}Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 18 lines
Hi!
Quoted 16 lines
Review
Quoted 12 lines
(quoted diff) +4
-3-#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_FDShouldn'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:
Quoted 8 lines
Quoted 5 lines
In file included from listmount03.c:13:0:
listmount.h:20:4: error: 'structmnt_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_idtoo 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.
Quoted 50 lines
Quoted 18 lines
https://github.com/pevik/ltp/actions/runs/20166087670/job/57889711762
(CI does not work, therefore I pushed you patchset.)
Quoted 4 lines
(quoted diff) +3
-0+typedef struct mnt_id_req_fallback mnt_id_req; +#else +typedef struct mnt_id_req mnt_id_req; #endif...
Review
Quoted 5 lines
(quoted diff) +5
-0+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.
Quoted 2 lines
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_181
#defineAFTER_6_182...
{ .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, },
Quoted 8 lines
...
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.
Quoted 10 lines
... }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>])
lapi/mount.h +1 -1
@@ -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 ;
kernel/syscalls/listmount/listmount.h +5 -5
@@ -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); }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 22 lines
Quoted 21 lines
Hi!
Quoted 20 lines
Review
Quoted 12 lines
(quoted diff) +4
-3-#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_FDShouldn'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: 'structmnt_id_req' has no member named 'mnt_id'
.mnt_id =mnt_id,
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Obviously some definition is wrong.
That looks like we need configure check for
mnt_idtoo 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
configure.ac +3 -3
@@ -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>])
lapi/mount.h +1 -1
@@ -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 ;
kernel/syscalls/listmount/listmount.h +5 -5
@@ -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); }
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 92 lines · Petr Vorel
Quoted 22 lines
Quoted 21 lines
Hi!
Quoted 20 lines
Review
Quoted 12 lines
(quoted diff) +4
-3-#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_FDShouldn'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: 'structmnt_id_req' has no member named 'mnt_id'
.mnt_id =mnt_id,Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Obviously some definition is wrong.
That looks like we need configure check for
mnt_idtoo 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.hneeds to be updated.Below is diff (without handling different errno).
Kind regards,
Petrconfigure.ac +3
-3@@ -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>])lapi/mount.h +1
-1@@ -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 ;kernel/syscalls/listmount/listmount.h +1
-1@@ -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 = {
kernel/syscalls/listmount/listmount.h line 24
Quoted 10 lines
kernel/syscalls/listmount/listmount.h +4
-4- .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.
Quoted 1 line
kernel/syscalls/listmount/listmount.h +0
-0}
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
...
Quoted 13 lines
Quoted 12 lines
static inline
ssize_tlistmount(uint64_tmnt_id,uint64_tlast_mnt_id,kernel/syscalls/listmount/listmount.h +4
-5uint64_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;
Quoted 4 lines
Quoted 1 line
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.
Sure, just remove "struct" is way better, thanks!
Kind regards,
Petr
Quoted 1 line
Quoted 1 line
}
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v6 1/1 listmount04.c: Update case support mnt_id_req.mnt_ns_fd
In reply to Wei Gao via ltpKernel change from v6.18-rc7 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
--- configure.ac | 2 +- include/lapi/mount.h | 10 +++-- .../kernel/syscalls/listmount/listmount.h | 2 +- .../kernel/syscalls/listmount/listmount04.c | 37 +++++++++++++++++-- .../kernel/syscalls/statmount/statmount.h | 2 +- 5 files changed, 44 insertions(+), 9 deletions(-)
configure.ac +1 -1
@@ -262,7 +262,7 @@ 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>])
include/lapi/mount.h +7 -3
@@ -45,14 +45,18 @@# define MS_NOSYMFOLLOW 256#endif -#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; }; + +#ifndef HAVE_STRUCT_MNT_ID_REQ_MNT_NS_FD +typedef struct mnt_id_req_fallback mnt_id_req ; +#else +typedef struct mnt_id_req mnt_id_req ;#endif #ifndef HAVE_STRUCT_STATMOUNT
testcases/kernel/syscalls/listmount/listmount.h +1 -1
@@ -15,7 +15,7 @@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 = { +mnt_id_req req = { .size =MNT_ID_REQ_SIZE_VER0 , .mnt_id = mnt_id, .param = last_mnt_id,
testcases/kernel/syscalls/listmount/listmount04.c +34 -3
@@ -14,14 +14,18 @@#define _GNU_SOURCE +#include "config.h" #include "tst_test.h" #include "lapi/mount.h" #include "lapi/syscalls.h" #define MNT_SIZE 32 +#define BEFORE_6_18 1 +#define AFTER_6_18 2 -static struct mnt_id_req *request; +static mnt_id_req *request;static uint64_t mnt_ids[MNT_SIZE ]; +static int kver; static struct tcase { int req_usage;
@@ -34,6 +38,7 @@ static struct tcase {uint64_t flags;int exp_errno;char *msg; +int kver; } tcases[] = { { .req_usage = 0,
@@ -79,6 +84,18 @@ static struct tcase { .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_ns_fd", + .kver = AFTER_6_18, }, { .req_usage = 1,
@@ -113,7 +130,12 @@ static struct tcase {static void run (unsigned int n) {struct tcase *tc = &tcases[n]; -struct mnt_id_req *req =NULL ; +mnt_id_req *req =NULL ; + +if (tc->kver && tc->kver != kver) { +tst_res (TCONF ,"Skip the case that is not suitable for the current kernel version" ); +return ; + }memset (mnt_ids,0 ,sizeof (mnt_ids));
@@ -122,7 +144,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->spare; } TST_EXP_FAIL(tst_syscall(__NR_listmount, req, tc->mnt_ids,
@@ -130,8 +152,17 @@ static void run(unsigned int n) "%s", tc->msg); } +static void setup (void ) +{ +if (tst_kvercmp (6 ,18 ,0 ) >=0 ) + kver =AFTER_6_18 ; +else + kver =BEFORE_6_18 ; +} +static struct tst_test test = { .test = run, + .setup = setup, .tcnt =ARRAY_SIZE (tcases), .min_kver ="6.11" , .bufs = (struct tst_buffers []) {
testcases/kernel/syscalls/statmount/statmount.h +1 -1
@@ -16,7 +16,7 @@static inline int statmount (uint64_t mnt_id,uint64_t mask,struct statmount *buf,size_t bufsize,unsigned int flags) { -struct mnt_id_req req = { +mnt_id_req req = { .size =MNT_ID_REQ_SIZE_VER0 , .mnt_id = mnt_id, .param = mask,
Signature · 5 lines
2.52.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
LGTM now.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Hi Wei,
Patch v6 generally looks good:
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
testcases/kernel/syscalls/listmount/listmount04.c static struct tcase { · line 136
Quoted 8 lines
static void run(unsigned int n)
{testcases/kernel/syscalls/listmount/listmount04.c +4
-1struct tcase *tc = &tcases[n]; -struct mnt_id_req *req =NULL ; +mnt_id_req *req =NULL ; + +if (tc->kver && tc->kver != kver) { +tst_res (TCONF ,"Skip the case that is not suitable for the current kernel version" );
I would shorten this message a bit "Test not suitable for current kernel version"
Because the information that the test is skipped is already in the TCONF flag.
Otherwise: Reviewed-by: Cyril Hrubis <[email protected]>
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 13 lines
Hi!
testcases/kernel/syscalls/listmount/listmount04.c static struct tcase { · line 136
Quoted 8 lines
static void run(unsigned int n)
{testcases/kernel/syscalls/listmount/listmount04.c +4
-1struct tcase *tc = &tcases[n]; -struct mnt_id_req *req =NULL ; +mnt_id_req *req =NULL ; + +if (tc->kver && tc->kver != kver) { +tst_res (TCONF ,"Skip the case that is not suitable for the current kernel version" );I would shorten this message a bit "Test not suitable for current kernel version"
Quoted 2 lines
Because the information that the test is skipped is already in the TCONF flag.
+1. I noticed that as well, just forget to point this out.
I modified the message and also rewrite commit message to get more info what was needed to do.
Thanks you all, finally we have CI fixed (+ compilation of the package on various distros) :).
Quoted 1 line
Otherwise: Reviewed-by: Cyril Hrubis <[email protected]>
@Cyril FYI: RBT should be on a separate line otherwise it's not added by patchwork when applying the patch.
Kind regards,
Petr
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp