kernel: usercopy functions

This commit is contained in:
Matheus
2024-06-09 19:31:26 -03:00
parent 429f56aced
commit 50b4b45d00
53 changed files with 712 additions and 260 deletions
+6 -2
View File
@@ -5,8 +5,9 @@
#include <kernel/net.h>
#include <kernel/alloc.h>
// TODO nosignal
syscallret_t syscall_sendmsg(context_t *, int fd, msghdr_t *umsghdr, int flags) {
__assert(flags == 0);
//__assert(flags == 0);
syscallret_t ret;
msghdr_t msghdr;
@@ -25,7 +26,10 @@ syscallret_t syscall_sendmsg(context_t *, int fd, msghdr_t *umsghdr, int flags)
uintmax_t iovoffset = 0;
for (int i = 0; i < msghdr.iovcount; ++i) {
memcpy((void *)((uintptr_t)buffer + iovoffset), msghdr.iov[i].addr, msghdr.iov[i].len);
ret.errno = usercopy_fromuser((void *)((uintptr_t)buffer + iovoffset), msghdr.iov[i].addr, msghdr.iov[i].len);
if (ret.errno)
goto cleanup;
iovoffset += msghdr.iov[i].len;
}