On Wed, Apr 18, 2018 at 11:04:21AM +0800, Fam Zheng wrote: > diff --git a/block/file-posix.c b/block/file-posix.c > index 3794c0007a..45ad543481 100644 > --- a/block/file-posix.c > +++ b/block/file-posix.c > @@ -100,6 +100,7 @@ > #ifdef CONFIG_XFS > #include <xfs/xfs.h> > #endif > +#include <sys/syscall.h>
Is sys/syscall.h available on all systems? I wasn't able to find it in
the POSIX specs.
>
> //#define DEBUG_BLOCK
>
> @@ -185,6 +186,8 @@ typedef struct RawPosixAIOData {
> #define aio_ioctl_cmd aio_nbytes /* for QEMU_AIO_IOCTL */
> off_t aio_offset;
> int aio_type;
> + int fd2;
> + off_t offset2;
Is there a reason for abandoning the aio_* field naming convention?
> } RawPosixAIOData;
>
> #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
> @@ -1421,6 +1424,48 @@ static ssize_t
> handle_aiocb_write_zeroes(RawPosixAIOData *aiocb)
> return -ENOTSUP;
> }
>
> +#ifdef __NR_copy_file_range
> +#define HAS_COPY_FILE_RANGE
> +#endif
> +
> +#ifdef HAS_COPY_FILE_RANGE
> +static off_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
> + off_t *out_off, size_t len, unsigned int flags)
> +{
> + return syscall(__NR_copy_file_range, in_fd, in_off, out_fd,
> + out_off, len, flags);
> +}
> +#endif
Further #ifdefs can be avoided by providing an implementation here:
#else
static off_t copy_file_range(int in_fd, off_t *in_off, int out_fd,
off_t *out_off, size_t len, unsigned int flags)
{
errno = ENOSYS;
return -1;
}
#endif /* !HAS_COPY_FILE_RANGE */
signature.asc
Description: PGP signature
