From deb971593f54253841e9e22abd3d46b69e1dda95 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig <hch@cloudius-systems.com> Date: Sat, 19 Jan 2013 13:54:05 +0100 Subject: [PATCH] implement vectored I/O (readv/writev) --- fs/vfs/main.c | 41 +++++++++++++++++++++++++++++++++++++++++ runtime.cc | 10 ---------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/fs/vfs/main.c b/fs/vfs/main.c index 43180d056..6ce5c402f 100755 --- a/fs/vfs/main.c +++ b/fs/vfs/main.c @@ -223,6 +223,47 @@ out_errno: return -1; } +ssize_t readv(int fd, const struct iovec *iov, int iovcnt) +{ + struct task *t = main_task; + file_t fp; + size_t bytes; + int error; + + error = EBADF; + if ((fp = task_getfp(t, fd)) == NULL) + goto out_errno; + + error = sys_read(fp, (struct iovec *)iov, iovcnt, &bytes); + if (error) + goto out_errno; + + return bytes; +out_errno: + errno = error; + return -1; +} + +ssize_t writev(int fd, const struct iovec *iov, int iovcnt) +{ + struct task *t = main_task; + file_t fp; + size_t bytes; + int error; + + error = EBADF; + if ((fp = task_getfp(t, fd)) == NULL) + goto out_errno; + + error = sys_write(fp, (struct iovec *)iov, iovcnt, &bytes); + if (error) + goto out_errno; + return bytes; +out_errno: + errno = error; + return -1; +} + #if 0 static int fs_ioctl(struct task *t, struct ioctl_msg *msg) diff --git a/runtime.cc b/runtime.cc index a886ea2b3..28d22c977 100644 --- a/runtime.cc +++ b/runtime.cc @@ -207,16 +207,6 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) UNIMPLEMENTED("poll"); } -ssize_t readv(int fd, const struct iovec *iov, int iovcnt) -{ - UNIMPLEMENTED("readv"); -} - -ssize_t writev(int fd, const struct iovec *iov, int iovcnt) -{ - UNIMPLEMENTED("writev"); -} - ssize_t preadv(int fd, const struct iovec *iov, int iovcnt, off_t offset) { UNIMPLEMENTED("preadv"); -- GitLab