From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53972) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwULZ-0006bC-FY for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwULV-0000mM-M3 for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:25 -0400 Received: from mail-lf0-x234.google.com ([2a00:1450:4010:c07::234]:34935) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwULV-0000ll-Ej for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:21 -0400 Received: by mail-lf0-x234.google.com with SMTP id l131so25244787lfl.2 for ; Tue, 18 Oct 2016 06:22:21 -0700 (PDT) From: riku.voipio@linaro.org Date: Tue, 18 Oct 2016 16:21:49 +0300 Message-Id: <1a607f6bd93f1c3635fa097029a983335f7949f8.1476796525.git.riku.voipio@linaro.org> In-Reply-To: References: Subject: [Qemu-devel] [PULL v2 21/22] linux-user: added support for pwritev() system call. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Dejan Jovicevic From: Dejan Jovicevic This system call performs the same task as the writev() 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. Because of this, the pwritev() implementation is based on the writev() implementation in linux-user mode. But, since pwritev() is implemented in the kernel as a 5-argument syscall, 5 arguments are needed to be handled as input and passed to the host syscall. The pos_l and pos_h argument of the safe_pwritev() are of type unsigned long, which can be of different sizes on different platforms. The input arguments are converted to the appropriate host size when passed to safe_pwritev(). Signed-off-by: Dejan Jovicevic Signed-off-by: Riku Voipio --- linux-user/syscall.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9cb2a8f..dfc483c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -921,6 +921,8 @@ safe_syscall3(ssize_t, readv, int, fd, const struct iovec *, iov, int, iovcnt) safe_syscall3(ssize_t, writev, int, fd, const struct iovec *, iov, int, iovcnt) safe_syscall5(ssize_t, preadv, int, fd, const struct iovec *, iov, int, iovcnt, unsigned long, pos_l, unsigned long, pos_h) +safe_syscall5(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, iovcnt, + unsigned long, pos_l, unsigned long, pos_h) safe_syscall3(int, connect, int, fd, const struct sockaddr *, addr, socklen_t, addrlen) safe_syscall6(ssize_t, sendto, int, fd, const void *, buf, size_t, len, @@ -10093,6 +10095,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } break; #endif +#if defined(TARGET_NR_pwritev) + case TARGET_NR_pwritev: + { + struct iovec *vec = lock_iovec(VERIFY_READ, arg2, arg3, 1); + if (vec != NULL) { + ret = get_errno(safe_pwritev(arg1, vec, arg3, arg4, arg5)); + unlock_iovec(vec, arg2, arg3, 0); + } else { + ret = -host_to_target_errno(errno); + } + } + break; +#endif case TARGET_NR_getsid: ret = get_errno(getsid(arg1)); break; -- 2.1.4