mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 05:58:22 +00:00
kernel: usercopy functions
This commit is contained in:
@@ -5,25 +5,32 @@
|
||||
#include <arch/cpu.h>
|
||||
#include <string.h>
|
||||
|
||||
syscallret_t syscall_unlinkat(context_t *, int dirfd, const char *upath, int flags) {
|
||||
syscallret_t syscall_unlinkat(context_t *, int dirfd, char *upath, int flags) {
|
||||
syscallret_t ret = {
|
||||
.ret = -1
|
||||
};
|
||||
|
||||
size_t pathlen = strlen(upath) + 1;
|
||||
char *path = alloc(pathlen);
|
||||
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;
|
||||
|
||||
char *component = alloc(pathlen);
|
||||
char *component = alloc(pathlen + 1);
|
||||
if (component == NULL) {
|
||||
ret.errno = ENOMEM;
|
||||
goto cleanup;
|
||||
|
||||
Reference in New Issue
Block a user