libsel4muslcsys: Implement sys_write wrapper
This wraps sys_writev the same way that sys_read is implemented.
diff --git a/libsel4muslcsys/src/sys_io.c b/libsel4muslcsys/src/sys_io.c
index bd94f4e..4544371 100644
--- a/libsel4muslcsys/src/sys_io.c
+++ b/libsel4muslcsys/src/sys_io.c
@@ -326,6 +326,17 @@
return ret;
}
+long sys_write(va_list ap)
+{
+
+ int fd = va_arg(ap, int);
+ void *buf = va_arg(ap, void *);
+ size_t count = va_arg(ap, size_t);
+ /* construct an iovec and call writev */
+ struct iovec iov = {.iov_base = buf, .iov_len = count };
+ return writev(fd, &iov, 1);
+}
+
long sys_readv(va_list ap)
{
int fd = va_arg(ap, int);
diff --git a/libsel4muslcsys/src/syscalls.h b/libsel4muslcsys/src/syscalls.h
index 1761c56..9101f8d 100644
--- a/libsel4muslcsys/src/syscalls.h
+++ b/libsel4muslcsys/src/syscalls.h
@@ -39,6 +39,7 @@
long sys_mmap2(va_list ap);
long sys_mmap(va_list ap);
long sys_mremap(va_list ap);
+long sys_write(va_list ap);
long sys_writev(va_list ap);
long sys_madvise(va_list ap);
diff --git a/libsel4muslcsys/src/vsyscall.c b/libsel4muslcsys/src/vsyscall.c
index 666e5ad..021948b 100644
--- a/libsel4muslcsys/src/vsyscall.c
+++ b/libsel4muslcsys/src/vsyscall.c
@@ -120,6 +120,9 @@
#endif
[__NR_set_tid_address] = boot_set_tid_address,
[__NR_writev] = boot_sys_writev,
+ /* We don't need a boot_sys_write variant as this implementation wraps
+ * whatever __NR_writev is set to. */
+ [__NR_write] = sys_write,
[__NR_sched_yield] = sys_sched_yield,
[__NR_exit] = sys_exit,
[__NR_rt_sigprocmask] = sys_rt_sigprocmask,