qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v2 2/2] linux-user: added support for pwritev() syst


From: Dejan Jovicevic
Subject: [Qemu-devel] [PATCH v2 2/2] linux-user: added support for pwritev() system call.
Date: Thu, 6 Oct 2016 17:49:20 +0200

v1 -> v2:
        - Using safe_pwritev() instead of calling preadv() directly.

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.

This implementation is based on the existing writev implementation.

Signed-off-by: Dejan Jovicevic <address@hidden>
---
 linux-user/syscall.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c7619f6..f34e255 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -910,6 +910,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_syscall4(ssize_t, preadv, int, fd, const struct iovec *, iov, int, iovcnt,
               off_t, offset)
+safe_syscall4(ssize_t, pwritev, int, fd, const struct iovec *, iov, int, 
iovcnt,
+              off_t, offset)
 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,
@@ -9909,6 +9911,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));
+                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;
-- 
1.9.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]