All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl
@ 2023-12-01 10:09 Martin Doucha
  2023-12-01 10:41 ` xuyang
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Doucha @ 2023-12-01 10:09 UTC (permalink / raw
  To: ltp

Loop device ioctl() returns EINVAL error if the command is not
supported. However, in compat mode, it'll return ENOTTY error
instead.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- Moved check from verify_ioctl_loop() to setup()

Tested on kernels 4.12 (ioctl not supported) and 5.3 (ioctl supported).

 testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop06.c b/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
index 6d009af6a..64800b4ee 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
@@ -109,8 +109,9 @@ static void setup(void)
 	unalign_value = pg_size - 1;
 
 	dev_fd = SAFE_OPEN(dev_path, O_RDWR);
+	ret = ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, 512);
 
-	if (ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, 512) && errno == EINVAL)
+	if (ret && (errno == EINVAL || errno == ENOTTY))
 		tst_brk(TCONF, "LOOP_SET_BLOCK_SIZE is not supported");
 
 	file_fd = SAFE_OPEN("test.img", O_RDWR);
-- 
2.42.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl
  2023-12-01 10:09 [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl Martin Doucha
@ 2023-12-01 10:41 ` xuyang
  2023-12-01 17:59   ` Petr Vorel
  0 siblings, 1 reply; 3+ messages in thread
From: xuyang @ 2023-12-01 10:41 UTC (permalink / raw
  To: mdoucha; +Cc: ltp

Hi Martin

LGTM

Best Regards
Yang Xu



---- Replied Message ----
| From | Martin Doucha<mdoucha@suse.cz> |
| Date | 12/01/2023 18:09 |
| To | ltp@lists.linux.it |
| Cc | |
| Subject | [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl |
Loop device ioctl() returns EINVAL error if the command is not
supported. However, in compat mode, it'll return ENOTTY error
instead.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- Moved check from verify_ioctl_loop() to setup()

Tested on kernels 4.12 (ioctl not supported) and 5.3 (ioctl supported).

testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop06.c b/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
index 6d009af6a..64800b4ee 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop06.c
@@ -109,8 +109,9 @@ static void setup(void)
     unalign_value = pg_size - 1;

     dev_fd = SAFE_OPEN(dev_path, O_RDWR);
+     ret = ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, 512);

-     if (ioctl(dev_fd, LOOP_SET_BLOCK_SIZE, 512) && errno == EINVAL)
+     if (ret && (errno == EINVAL || errno == ENOTTY))
          tst_brk(TCONF, "LOOP_SET_BLOCK_SIZE is not supported");

     file_fd = SAFE_OPEN("test.img", O_RDWR);
--
2.42.1


--
Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl
  2023-12-01 10:41 ` xuyang
@ 2023-12-01 17:59   ` Petr Vorel
  0 siblings, 0 replies; 3+ messages in thread
From: Petr Vorel @ 2023-12-01 17:59 UTC (permalink / raw
  To: xuyang; +Cc: ltp

Hi Martin, Xu,

merged, thank you!

Kind regards,
Petr

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-01 18:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-01 10:09 [LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl Martin Doucha
2023-12-01 10:41 ` xuyang
2023-12-01 17:59   ` Petr Vorel

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.