Skip to contentSkip to conversation

ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl

PATCH In review Martin Doucha 3 participants 3 messages Dec 1, 2023

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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.

---

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(-)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +2 -1
index 6d009af6a..64800b4ee 100644
@@ -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);
Signature · 5 lines
2.42.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#1 lore raw

Hi Martin

LGTM

Best Regards
Yang Xu

---- Replied Message ----

| From | Martin Doucha<[email protected]> |
| Date | 12/01/2023 18:09 |
| To | [email protected] |
| 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.

---

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(-)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +2 -1
index 6d009af6a..64800b4ee 100644
@@ -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

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#2 lore raw

Hi Martin, Xu,

merged, thank you!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp