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
+3 -4
View File
@@ -14,7 +14,6 @@ syscallret_t syscall_waitpid(context_t *context, pid_t pid, int *status, int opt
.ret = -1
};
// TODO address check
__assert((options & ~KNOWN_FLAGS) == 0);
// TODO implement these
__assert(pid == -1 || pid > 0);
@@ -94,10 +93,11 @@ syscallret_t syscall_waitpid(context_t *context, pid_t pid, int *status, int opt
proc->child = iterator->sibling;
}
// TODO memory safe operation
if (status) {
int statustmp = iterator->status;
*status = statustmp;
ret.errno = usercopy_touser(status, &statustmp, sizeof(statustmp));
} else {
ret.errno = 0;
}
MUTEX_RELEASE(&proc->mutex);
@@ -125,7 +125,6 @@ syscallret_t syscall_waitpid(context_t *context, pid_t pid, int *status, int opt
}
ret.ret = iterator->pid;
ret.errno = 0;
__assert(iterator);
// process will no longer be referenced by the child list