Re: [PATCH] libbb/loop: fix existence check for LOOP_CONFIGURE ioctl

Denys Vlasenko via busybox <[email protected]>
Newsgroups gmane.linux.busybox
Message-ID <CAK1hOcOiodoC0PG0hhi80OCCdAwM9H9BsmkFeKjxikL76uamXQ@mail.gmail.com>
Applied, thank you

On Tue, Jan 20, 2026 at 10:29 AM <[email protected]> wrote:
>
> The LOOP_CONFIGURE ioctl is supported in 5.8 kernels and up. To have
> backwards compatibility there is a config option CONFIG_TRY_LOOP_CONFIGURE
> that will check if the ioctl exists and if not fall back to old way of
> configuring loop devices.
>
> Normally errno will be set to EINVAL when this ioctl does not exist.
> However, when kernel config CONFIG_COMPAT is enabled, then compat_ioctl
> is called. In that case -ENOIOCTLCMD is returned by loop device driver
> and generic ioctl wrapper will set errno to ENOTTY. Because busybox
> does not expect this it will fail to mount loop devices in this case.
>
> This patch fixes the check for the existence of the ioctl LOOP_CONFIGURE
> by checking if errno is one of both: EINVAL or ENOTTY.
>
> Signed-off-by: Wouter Franken <[email protected]>
> Signed-off-by: Wouter Franken <[email protected]>
> ---
>  libbb/loop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libbb/loop.c b/libbb/loop.c
> index a0c5d02..b603d0d 100644
> --- a/libbb/loop.c
> +++ b/libbb/loop.c
> @@ -158,7 +158,7 @@ static int set_loopdev_params(int lfd,
>                 if (rc == 0)
>                         return rc; /* SUCCESS! */
>  # if ENABLE_TRY_LOOP_CONFIGURE
> -               if (errno != EINVAL)
> +               if (errno != EINVAL && errno != ENOTTY)
>                         return rc; /* error other than old kernel */
>                 /* Old kernel, fall through into old way to do it: */
>  # endif
> --
> 2.34.1
>
> _______________________________________________
> busybox mailing list
> [email protected]
> https://lists.busybox.net/mailman/listinfo/busybox
_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.