* [LTP] [PATCH v2] syscalls/ioctl_loop05: Ensure do zero offset when using -i parameter
@ 2020-05-12 5:11 Yang Xu
2020-05-12 9:58 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Yang Xu @ 2020-05-12 5:11 UTC (permalink / raw)
To: ltp
Currently, we use return instead of zero_offset. I debug this code
(early return, ext4 filesystem)as below:
---------------------------------------
TEST(ioctl(dev_fd, LOOP_SET_DIRECT_IO, 1));
if (TST_RET == 0) {
tst_res(TPASS, "LOOP_SET_DIRECT_IO succeeded unexpectedly");
SAFE_IOCTL(dev_fd, LOOP_SET_DIRECT_IO, 0);
}
return;
---------------------------------------
this case will be broke when using i parameter,
ioctl_loop05.c:62: BROK: ioctl(3,LOOP_SET_DIRECT_IO,...) failed: EINVAL (22)
It seems the last test affected this test, so I move zero status to the
beginning of the test to avoid unknown error.
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
---
testcases/kernel/syscalls/ioctl/ioctl_loop05.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c
index 6cf701f47..c9138be95 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop05.c
@@ -5,7 +5,7 @@
*
* This is a basic ioctl test about loopdevice.
*
- * It is designed to test LOOP_SET_DIRECT_IO can updata a live
+ * It is designed to test LOOP_SET_DIRECT_IO can update a live
* loop device dio mode. It needs the backing file also supports
* dio mode and the lo_offset is aligned with the logical block size.
*
@@ -57,6 +57,11 @@ static void verify_ioctl_loop(void)
struct loop_info loopinfo;
memset(&loopinfo, 0, sizeof(loopinfo));
+ /*
+ * Setting loopdevice with zero loop_info struct, so we can avoid unknown
+ * error when using -i parameter.
+ */
+ TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo), TST_RETVAL_EQ0);
tst_res(TINFO, "Without setting lo_offset or sizelimit");
SAFE_IOCTL(dev_fd, LOOP_SET_DIRECT_IO, 1);
@@ -91,9 +96,6 @@ static void verify_ioctl_loop(void)
tst_res(TPASS | TTERRNO, "LOOP_SET_DIRECT_IO failed as expected");
else
tst_res(TFAIL | TTERRNO, "LOOP_SET_DIRECT_IO failed expected EINVAL got");
-
- loopinfo.lo_offset = 0;
- TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo), TST_RETVAL_EQ0);
}
static void setup(void)
--
2.23.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [LTP] [PATCH v2] syscalls/ioctl_loop05: Ensure do zero offset when using -i parameter
2020-05-12 5:11 [LTP] [PATCH v2] syscalls/ioctl_loop05: Ensure do zero offset when using -i parameter Yang Xu
@ 2020-05-12 9:58 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2020-05-12 9:58 UTC (permalink / raw)
To: ltp
Hi!
> memset(&loopinfo, 0, sizeof(loopinfo));
> + /*
> + * Setting loopdevice with zero loop_info struct, so we can avoid unknown
> + * error when using -i parameter.
> + */
> + TST_RETRY_FUNC(ioctl(dev_fd, LOOP_SET_STATUS, &loopinfo), TST_RETVAL_EQ0);
I've merged the patch without the comment, the commit message is
descriptive enough.
Thanks.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-12 9:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-12 5:11 [LTP] [PATCH v2] syscalls/ioctl_loop05: Ensure do zero offset when using -i parameter Yang Xu
2020-05-12 9:58 ` Cyril Hrubis
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.