[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() syst
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PATCH 2/3] linux-user: added support for preadv() system call. |
Date: |
Thu, 6 Oct 2016 15:14:31 +0100 |
On 6 October 2016 at 14:59, Dejan Jovicevic <address@hidden> wrote:
> This system call performs the same task as the readv system call,
> with the exception of having the fourth argument, offset, which
> specifes the file offset at which the input operation is to be performed.
>
> This implementation is based on the existing readv implementation.
>
> Signed-off-by: Dejan Jovicevic <address@hidden>
> ---
> linux-user/syscall.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 0815f30..10b2552 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -9894,6 +9894,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
> arg1,
> }
> }
> break;
> +#if defined(TARGET_NR_preadv) && defined(CONFIG_PREADV)
> + case TARGET_NR_preadv:
> + {
> + struct iovec *vec = lock_iovec(VERIFY_WRITE, arg2, arg3, 0);
> + if (vec != NULL) {
> + ret = get_errno(preadv(arg1, vec, arg3, arg4));
> + unlock_iovec(vec, arg2, arg3, 1);
> + } else {
> + ret = -host_to_target_errno(errno);
> + }
> + }
> + break;
> +#endif
preadv is an "interruptible syscall", meaning that it can
return EINTR if a signal occurs while it is blocking. This
means that in QEMU we need to implement it via the
safe_syscall() wrapper (see the long explanatory comment
in linux-user/qemu.h). The same applies to pwritev. See
the implementations of TARGET_NR_readv and TARGET_NR_writev
for an example of how to do this; basically you just need
a safe_syscall4() line to define safe_preadv(), and then
use it instead of direct preadv(). As a side-benefit you'll
then be able to drop the configure patch since we don't
go via libc.
thanks
-- PMM