[LTP] [PATCH v2] ioctl_loop01.c: Use proper device for partitioning
Wei Gao
wegao@suse.com
Tue Sep 2 05:12:21 CEST 2025
This is same patch used on ioctl09,the page cache of loop0 can cache old
version of the partition table which is then used by the partitioning
code. Fix the problem by calling parted against the loop device directly.
Link: https://lore.kernel.org/ltp/20250829141932.31997-1-jack@suse.cz/
Signed-off-by: Wei Gao <wegao@suse.com>
---
.../kernel/syscalls/ioctl/ioctl_loop01.c | 26 +++++--------------
1 file changed, 7 insertions(+), 19 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
index c9137bf1e..695aaeb0b 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_loop01.c
@@ -78,7 +78,13 @@ static void check_loop_value(int set_flag, int get_flag, int autoclear_field)
static void verify_ioctl_loop(void)
{
+ const char *const cmd_parted[] = {"parted", "-s", dev_path, "mklabel", "msdos", "mkpart",
+ "primary", "ext4", "1M", "10M", NULL};
+
+ tst_fill_file("test.img", 0, 1024 * 1024, 10);
tst_attach_device(dev_path, "test.img");
+ SAFE_CMD(cmd_parted, NULL, NULL);
+
attach_flag = 1;
TST_ASSERT_INT(partscan_path, 0);
@@ -92,34 +98,16 @@ static void verify_ioctl_loop(void)
tst_detach_device_by_fd(dev_path, dev_fd);
dev_fd = SAFE_OPEN(dev_path, O_RDWR);
+
attach_flag = 0;
}
static void setup(void)
{
- int ret;
- const char *const cmd_parted[] = {"parted", "-s", "test.img", "mklabel", "msdos", "mkpart",
- "primary", "ext4", "1M", "10M", NULL};
-
dev_num = tst_find_free_loopdev(dev_path, sizeof(dev_path));
if (dev_num < 0)
tst_brk(TBROK, "Failed to find free loop device");
- tst_fill_file("test.img", 0, 1024 * 1024, 10);
-
- ret = tst_cmd(cmd_parted, NULL, NULL, TST_CMD_PASS_RETVAL);
- switch (ret) {
- case 0:
- parted_sup = 1;
- break;
- case 255:
- tst_res(TCONF, "parted binary not installed or failed");
- break;
- default:
- tst_res(TCONF, "parted exited with %i", ret);
- break;
- }
-
sprintf(partscan_path, "/sys/block/loop%d/loop/partscan", dev_num);
sprintf(autoclear_path, "/sys/block/loop%d/loop/autoclear", dev_num);
sprintf(backing_path, "/sys/block/loop%d/loop/backing_file", dev_num);
--
2.51.0
More information about the ltp
mailing list