From 7a91bc2921e3b5fff1d647d6dba0573d259fb95e Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Mon, 4 Dec 2023 02:15:47 -0800 Subject: [PATCH] caller.py: implement writev syscall --- src/openpower/decoder/isa/caller.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/openpower/decoder/isa/caller.py b/src/openpower/decoder/isa/caller.py index e2f997cb..556c9b10 100644 --- a/src/openpower/decoder/isa/caller.py +++ b/src/openpower/decoder/isa/caller.py @@ -1177,6 +1177,29 @@ class SyscallEmulator(openpower.syscalls.Dispatcher): except OSError as e: return -e.errno + def sys_writev(self, fd, iov, iovcnt, *rest): + IOV_MAX = 1024 + if iovcnt < 0 or iovcnt > IOV_MAX: + return -errno.EINVAL + struct_iovec = struct.Struct(" 0: + iov = self.__isacaller.mem.get_ctypes( + iov, struct_iovec.size * iovcnt, is_write=False) + iov = list(struct_iovec.iter_unpack(iov)) + else: + iov = [] + for i, iovec in enumerate(iov): + iov_base, iov_len = iovec + iov[i] = self.__isacaller.mem.get_ctypes( + iov_base, iov_len, is_write=False) + except (ValueError, MemException): + return -errno.EFAULT + try: + return os.writev(fd, iov) + except OSError as e: + return -e.errno + def sys_read(self, fd, buf, count, *rest): buf = self.__isacaller.mem.get_ctypes(buf, count, is_write=True) try: -- 2.30.2