diff --git a/src/arch/x86_64/syscall.asm b/src/arch/x86_64/syscall.asm index 13970fbf..8e5993b7 100644 --- a/src/arch/x86_64/syscall.asm +++ b/src/arch/x86_64/syscall.asm @@ -41,7 +41,8 @@ extern syscall_listen extern syscall_connect extern syscall_accept extern syscall_nanosleep -func_count equ 40 +extern syscall_fchmod +func_count equ 41 func_table: @@ -85,6 +86,7 @@ func_table: dq syscall_connect dq syscall_accept dq syscall_nanosleep + dq syscall_fchmod section .text global asm_syscall_entry diff --git a/src/sys/syscalls/fchmod.c b/src/sys/syscalls/fchmod.c new file mode 100644 index 00000000..b519b6e1 --- /dev/null +++ b/src/sys/syscalls/fchmod.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include +#include +#include + +syscallret syscall_fchmod(int ifd, mode_t mode){ + syscallret retv; + retv.ret = -1; + + proc_t* proc = arch_getcls()->thread->proc; + + fd_t* fd; + + int err = fd_access(&proc->fdtable, &fd, ifd); + + if(err){ + retv.errno = err; + return retv; + } + + retv.errno = vfs_chmod(fd->node, mode); + + fd_release(fd); + + retv.ret = retv.errno ? -1 : 0; + + return retv; + +}