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
+3 -1
View File
@@ -26,7 +26,8 @@ extern syscall_ioctl
extern syscall_chdir
extern syscall_fstatat
extern syscall_pipe2
func_count equ 25
extern syscall_mkdir
func_count equ 26
func_table:
@@ -55,6 +56,7 @@ func_table:
dq syscall_chdir
dq syscall_fstatat
dq syscall_pipe2
dq syscall_mkdir
section .text
global asm_syscall_entry
+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;
}