syscalls: mkdir

This commit is contained in:
Matheus
2022-10-11 23:33:12 -03:00
parent ef6aae4a39
commit 6483a22952
2 changed files with 33 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
#include <kernel/syscalls.h>
#include <kernel/vfs.h>
#include <arch/cls.h>
#include <string.h>
#include <sys/types.h>
syscallret syscall_mkdir(const char* pathname, mode_t mode){
syscallret retv;
retv.ret = -1;
if(pathname > USER_SPACE_END){
retv.errno = 0;
return retv;
}
proc_t* proc = arch_getcls()->thread->proc;
char path[strlen(pathname)+1];
strcpy(path, pathname);
retv.errno = vfs_mkdir(path[0] == '/' ? proc->root : proc->cwd, path, mode);
if(retv.errno == 0)
retv.ret = 0;
return retv;
}