[LTP] [PATCH v2] ioctl_loop06: Check for unsupported LOOP_SET_BLOCK_SIZE ioctl

xuyang xuyang_jy_0410@163.com
Fri Dec 1 11:41:49 CET 2023


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


More information about the ltp mailing list