[PATCH] Use correct type for ioctl(FIGETBSZ) emulation

Bastian Blank posted 1 patch 2 weeks, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/s7ingr72rgtvch2poxlwyc25lkxp7hh5c273ubvmz4tdskjttz@7dzfvylkgwsh
Maintainers: Laurent Vivier <laurent@vivier.eu>
linux-user/ioctls.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] Use correct type for ioctl(FIGETBSZ) emulation
Posted by Bastian Blank 2 weeks, 3 days ago
The FIGETBSZ ioctl get's "int *" (pointer to 32bit integer) as argument,
not "long *" as specified in qemu.  Using the correct type makes the
emulation work.

Signed-off-by: Bastian Blank <waldi@debian.org>
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3185
---
 linux-user/ioctls.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 3b41128..c87ce61 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -145,7 +145,7 @@
      IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
 #endif
 
-     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))
+     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_INT))
 #ifdef CONFIG_FIEMAP
      IOCTL_SPECIAL(FS_IOC_FIEMAP, IOC_W | IOC_R, do_ioctl_fs_ioc_fiemap,
                    MK_PTR(MK_STRUCT(STRUCT_fiemap)))
-- 
2.51.0
Re: [PATCH] Use correct type for ioctl(FIGETBSZ) emulation
Posted by Peter Maydell 2 weeks, 3 days ago
On Tue, 28 Oct 2025 at 11:29, Bastian Blank <waldi@debian.org> wrote:
>
> The FIGETBSZ ioctl get's "int *" (pointer to 32bit integer) as argument,
> not "long *" as specified in qemu.  Using the correct type makes the
> emulation work.

We could also note:

This ioctl does not seem to be documented. However the kernel
implementation has always used "int *".

thanks
-- PMM
Re: [PATCH] Use correct type for ioctl(FIGETBSZ) emulation
Posted by Michael Tokarev 2 weeks, 3 days ago
On 10/28/25 14:29, Bastian Blank wrote:
> The FIGETBSZ ioctl get's "int *" (pointer to 32bit integer) as argument,
> not "long *" as specified in qemu.  Using the correct type makes the
> emulation work.
> 
> Signed-off-by: Bastian Blank <waldi@debian.org>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3185

Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>

(Adding Laurent to Cc:)

While applying, it'd be nice to include "linux-user: " prefix to
the subject.  And the thing should definitely be picked up for the
stable series (Cc'd).

This bug has been with us since the day linux-user was implemented,
in 2003.

I can pick this one up to qemu-trivial tree, if no one objects.

Thanks,

/mjt

>   linux-user/ioctls.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
> index 3b41128..c87ce61 100644
> --- a/linux-user/ioctls.h
> +++ b/linux-user/ioctls.h
> @@ -145,7 +145,7 @@
>        IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
>   #endif
>   
> -     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))
> +     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_INT))
>   #ifdef CONFIG_FIEMAP
>        IOCTL_SPECIAL(FS_IOC_FIEMAP, IOC_W | IOC_R, do_ioctl_fs_ioc_fiemap,
>                      MK_PTR(MK_STRUCT(STRUCT_fiemap)))
Re: [PATCH] Use correct type for ioctl(FIGETBSZ) emulation
Posted by Helge Deller 2 weeks, 3 days ago
On 10/28/25 12:29, Bastian Blank wrote:
> The FIGETBSZ ioctl get's "int *" (pointer to 32bit integer) as argument,
> not "long *" as specified in qemu.  Using the correct type makes the
> emulation work.
> 
> Signed-off-by: Bastian Blank <waldi@debian.org>
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3185
> ---
>   linux-user/ioctls.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
> index 3b41128..c87ce61 100644
> --- a/linux-user/ioctls.h
> +++ b/linux-user/ioctls.h
> @@ -145,7 +145,7 @@
>        IOCTL(FITRIM, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_fstrim_range)))
>   #endif
>   
> -     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_LONG))
> +     IOCTL(FIGETBSZ, IOC_R, MK_PTR(TYPE_INT))

Looks good.
Reviewed-by: Helge Deller <deller@gmx.de>

Can you check FIBMAP as well? I think it needs the same patch...

Helge
Re: [PATCH] Use correct type for ioctl(FIGETBSZ) emulation
Posted by Bastian Blank 2 weeks, 3 days ago
On Tue, Oct 28, 2025 at 12:35:35PM +0100, Helge Deller wrote:
> Can you check FIBMAP as well? I think it needs the same patch...

You are right, it does need the same.  However that is now untested from
my side.

Bastian

-- 
We do not colonize.  We conquer.  We rule.  There is no other way for us.
		-- Rojan, "By Any Other Name", stardate 4657.5