diff --git a/src/kernel/emulation/linux/CMakeLists.txt b/src/kernel/emulation/linux/CMakeLists.txt index 4a8334f1c..734f34a75 100644 --- a/src/kernel/emulation/linux/CMakeLists.txt +++ b/src/kernel/emulation/linux/CMakeLists.txt @@ -18,6 +18,8 @@ set(emulation_sources unistd/read.c unistd/pread.c unistd/pwrite.c + unistd/readv.c + unistd/writev.c mman.c unistd/fsync.c unistd/sync.c diff --git a/src/kernel/emulation/linux/syscalls.c b/src/kernel/emulation/linux/syscalls.c index 63e07f159..7d7c66c72 100644 --- a/src/kernel/emulation/linux/syscalls.c +++ b/src/kernel/emulation/linux/syscalls.c @@ -28,6 +28,8 @@ #include "unistd/lseek.h" #include "unistd/ftruncate.h" #include "unistd/readlink.h" +#include "unistd/readv.h" +#include "unistd/writev.h" #include "signal/kill.h" #include "signal/sigaltstack.h" #include "signal/sigaction.h" @@ -74,6 +76,8 @@ void* __bsd_syscall_table[512] = { [97] = sys_socket, [98] = sys_connect, [116] = sys_gettimeofday, + [120] = sys_readv, + [121] = sys_writev, [123] = sys_fchown, [124] = sys_fchmod, [147] = sys_setsid, @@ -102,6 +106,8 @@ void* __bsd_syscall_table[512] = { [398] = sys_open_nocancel, [399] = sys_close_nocancel, [408] = sys_fsync_nocancel, + [411] = sys_readv_nocancel, + [412] = sys_writev_nocancel, [414] = sys_pread_nocancel, [415] = sys_pwrite_nocancel, }; diff --git a/src/kernel/emulation/linux/unistd/readv.c b/src/kernel/emulation/linux/unistd/readv.c new file mode 100644 index 000000000..35068cb99 --- /dev/null +++ b/src/kernel/emulation/linux/unistd/readv.c @@ -0,0 +1,21 @@ +#include "readv.h" +#include "../base.h" +#include "../errno.h" +#include + +long sys_readv(int fd, struct iovec* iovp, unsigned int len) +{ + return sys_readv_nocancel(fd, iovp, len); +} + +long sys_readv_nocancel(int fd, struct iovec* iovp, unsigned int len) +{ + int ret; + + ret = LINUX_SYSCALL3(__NR_readv, fd, iovp, len); + if (ret < 0) + return errno_linux_to_bsd(ret); + + return ret; +} + diff --git a/src/kernel/emulation/linux/unistd/readv.h b/src/kernel/emulation/linux/unistd/readv.h new file mode 100644 index 000000000..765bc39f1 --- /dev/null +++ b/src/kernel/emulation/linux/unistd/readv.h @@ -0,0 +1,9 @@ +#ifndef LINUX_READV_H +#define LINUX_READV_H + +struct iovec; +long sys_readv(int fd, struct iovec* iovp, unsigned int len); +long sys_readv_nocancel(int fd, struct iovec* iovp, unsigned int len); + +#endif + diff --git a/src/kernel/emulation/linux/unistd/writev.c b/src/kernel/emulation/linux/unistd/writev.c new file mode 100644 index 000000000..6cfd5880d --- /dev/null +++ b/src/kernel/emulation/linux/unistd/writev.c @@ -0,0 +1,21 @@ +#include "writev.h" +#include "../base.h" +#include "../errno.h" +#include + +long sys_writev(int fd, struct iovec* iovp, unsigned int len) +{ + return sys_writev_nocancel(fd, iovp, len); +} + +long sys_writev_nocancel(int fd, struct iovec* iovp, unsigned int len) +{ + int ret; + + ret = LINUX_SYSCALL3(__NR_writev, fd, iovp, len); + if (ret < 0) + return errno_linux_to_bsd(ret); + + return ret; +} + diff --git a/src/kernel/emulation/linux/unistd/writev.h b/src/kernel/emulation/linux/unistd/writev.h new file mode 100644 index 000000000..84f182546 --- /dev/null +++ b/src/kernel/emulation/linux/unistd/writev.h @@ -0,0 +1,9 @@ +#ifndef LINUX_WRITEV_H +#define LINUX_WRITEV_H + +struct iovec; +long sys_writev(int fd, struct iovec* iovp, unsigned int len); +long sys_writev_nocancel(int fd, struct iovec* iovp, unsigned int len); + +#endif +