[PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd

Damien Zammit posted 4 patches 1 week, 3 days ago
Maintainers: Stefan Berger <stefanb@linux.vnet.ibm.com>, Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, "Alex Bennée" <alex.bennee@linaro.org>, Thomas Huth <thuth@redhat.com>
There is a newer version of this series
[PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd
Posted by Damien Zammit 1 week, 3 days ago
glibc already has this as non-static on __GNU__ systems.
Also, add the missing sys/ioctl.h header for the same platform.

Signed-off-by: Damien Zammit <damien@zamaudio.com>
---
 block/file-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index 6265d2e248..5e4fdba49b 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -116,6 +116,10 @@
 #include <sys/ioctl.h>
 #endif
 
+#ifdef __GNU__
+#include <sys/ioctl.h>
+#endif
+
 /* OS X does not have O_DSYNC */
 #ifndef O_DSYNC
 #ifdef O_SYNC
@@ -2113,7 +2117,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
 }
 
 #ifndef HAVE_COPY_FILE_RANGE
-#ifndef EMSCRIPTEN
+#if !defined(EMSCRIPTEN) && !defined(__GNU__)
 static
 #endif
 ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
-- 
2.51.0
Re: [PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd
Posted by Paolo Bonzini 1 week, 3 days ago
On 1/30/26 04:20, Damien Zammit wrote:
> glibc already has this as non-static on __GNU__ systems.
>
>  #ifndef HAVE_COPY_FILE_RANGE
> -#ifndef EMSCRIPTEN
> +#if !defined(EMSCRIPTEN) && !defined(__GNU__)
>   static
>   #endif
>   ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,

Do I understand it correctly that it has the prototype but not the function?

Thanks,

Paolo
Re: [PATCH v3 4/4 qemu] Avoid static definition of copy_file_range on GNU/Hurd
Posted by Paolo Bonzini 1 week, 3 days ago
On 1/30/26 04:20, Damien Zammit wrote:
> glibc already has this as non-static on __GNU__ systems.
> Also, add the missing sys/ioctl.h header for the same platform.

Please just move the inclusion of sys/ioctl.h outside all #ifdefs, i.e.

...
#include <sys/ioctl.h>

#if defined(__APPLE__) && (__MACH__)
#if defined(HAVE_HOST_BLOCK_DEVICE)
#include <paths.h>
#include <sys/param.h>
...

and remove all the #includes for it after the first.

Thanks,

Paolo

> Signed-off-by: Damien Zammit <damien@zamaudio.com>
> ---
>   block/file-posix.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index 6265d2e248..5e4fdba49b 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -116,6 +116,10 @@
>   #include <sys/ioctl.h>
>   #endif
>   
> +#ifdef __GNU__
> +#include <sys/ioctl.h>
> +#endif
> +
>   /* OS X does not have O_DSYNC */
>   #ifndef O_DSYNC
>   #ifdef O_SYNC
> @@ -2113,7 +2117,7 @@ static int handle_aiocb_write_zeroes_unmap(void *opaque)
>   }
>   
>   #ifndef HAVE_COPY_FILE_RANGE
> -#ifndef EMSCRIPTEN
> +#if !defined(EMSCRIPTEN) && !defined(__GNU__)
>   static
>   #endif
>   ssize_t copy_file_range(int in_fd, off_t *in_off, int out_fd,