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
+12 -4
View File
@@ -5,19 +5,27 @@
#include <kernel/abi.h>
#include <arch/cpu.h>
syscallret_t syscall_mkdirat(context_t *, int dirfd, const char *upath, mode_t mode) {
syscallret_t syscall_mkdirat(context_t *, int dirfd, char *upath, mode_t mode) {
syscallret_t ret = {
.ret = -1
};
char *path = alloc(strlen(upath) + 1);
size_t pathlen;
ret.errno = usercopy_strlen(upath, &pathlen);
if (ret.errno)
return ret;
char *path = alloc(pathlen + 1);
if (path == NULL) {
ret.errno = ENOMEM;
return ret;
}
// TODO safe strcopy
strcpy(path, upath);
ret.errno = usercopy_fromuser(path, upath, pathlen);
if (ret.errno) {
free(path);
return ret;
}
vnode_t *dirnode = NULL;
file_t *file = NULL;