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

2026-01-25 Thread Denys Vlasenko via busybox
Applied, thank you

On Tue, Jan 20, 2026 at 10:29 AM  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 
> Signed-off-by: Wouter Franken 
> ---
>  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


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

2026-01-20 Thread wouter . franken_ext
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 
Signed-off-by: Wouter Franken 
---
 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


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

2025-02-06 Thread Wouter Franken
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 
Signed-off-by: Wouter Franken 
---
 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


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

2024-04-24 Thread Wouter Franken
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 
Signed-off-by: Wouter Franken 
---
 libbb/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbb/loop.c b/libbb/loop.c
index a0c5d0259..b603d0daa 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

-- This message and any attachments herein are confidential, intended solely 
for the addressees and are SoftAtHome’s ownership. Any unauthorized use or 
dissemination is prohibited. If you are not the intended addressee of this 
message, please cancel it immediately and inform the sender.
___
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox