[LTP] [PATCH] syscalls/ioctl_loop0[23]: TCONF when LOOP_CHANGE_FD is not supported

Petr Vorel pvorel@suse.cz
Fri Nov 6 09:58:15 CET 2026


Hi Avinesh,

> LOOP_CHANGE_FD was removed by d4fabede1da0 ("loop: remove support for
> swapping loop fds") n v7.4-rc1 and it fails with EOPNOTSUPP.

> ioctl_loop02.c:85: TFAIL: LOOP_CHANGE_FD failed: EOPNOTSUPP (95)
> ioctl_loop02.c:97: TFAIL: LOOP_CHANGE_FD failed expected EINVAL got: EOPNOTSUPP (95)

> ioctl_loop03.c:34: TFAIL: LOOP_CHANGE_FD failed expected EINVAL got: EOPNOTSUPP (95)

> Report TCONF for these checks.

Thanks, merged!

> -	TEST(ioctl(dev_fd, LOOP_CHANGE_FD, file_fd_invalid));
> -	if (TST_RET) {
> -		if (TST_ERR == EINVAL)
> -			tst_res(TPASS | TTERRNO, "LOOP_CHANGE_FD failed as expected");
> -		else
> -			tst_res(TFAIL | TTERRNO, "LOOP_CHANGE_FD failed expected EINVAL got");
> -	} else {
> -		tst_res(TFAIL, "LOOP_CHANGE_FD succeeded");
> +		TEST(ioctl(dev_fd, LOOP_CHANGE_FD, file_change_fd));
> +		if (TST_RET) {
> +			tst_res(TFAIL | TTERRNO, "LOOP_CHANGE_FD failed");
> +		} else {
> +			tst_res(TPASS, "LOOP_CHANGE_FD succeeded");
> +			TST_ASSERT_INT(loop_ro_path, 1);
> +			TST_ASSERT_STR(backing_path, backing_file_change_path);
> +		}
> +
> +		TEST(ioctl(dev_fd, LOOP_CHANGE_FD, file_fd_invalid));
> +		if (TST_RET) {
> +			if (TST_ERR == EINVAL)
> +				tst_res(TPASS | TTERRNO, "LOOP_CHANGE_FD failed as expected");
> +			else
> +				tst_res(TFAIL | TTERRNO, "LOOP_CHANGE_FD failed expected EINVAL got");
> +		} else {
> +			tst_res(TFAIL, "LOOP_CHANGE_FD succeeded");
> +		}
>  	}

>  	SAFE_CLOSE(file_fd);
> @@ -134,6 +140,13 @@ static void setup(void)
>  		tst_res(TINFO | TERRNO, "LOOP_CONFIGURE is not supported");
>  		loop_configure_sup = 0;
>  	}
> +
> +	ret = ioctl(dev_fd, LOOP_CHANGE_FD, -1);
> +	if (ret && errno == EOPNOTSUPP) {
> +		tst_res(TINFO | TERRNO, "LOOP_CHANGE_FD is not supported");
I dared to remove this TINFO | TERRNO message. Since there is only one errno,
it's not important to print it, later TCONF is enough.

Kind regards,
Petr

> +		loop_change_fd_sup = 0;
> +	}


More information about the ltp mailing list