mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 06:28:22 +00:00
kernel: usercopy functions
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user