From 364e620ce9482e1a49912b805fd9de868b0a77ec Mon Sep 17 00:00:00 2001 From: Matheus Date: Fri, 23 Sep 2022 19:38:26 -0300 Subject: [PATCH] fcntl: F_DUPFD --- src/sys/syscalls/fcntl.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sys/syscalls/fcntl.c b/src/sys/syscalls/fcntl.c index 2f6cd0b1..fe2bc991 100644 --- a/src/sys/syscalls/fcntl.c +++ b/src/sys/syscalls/fcntl.c @@ -17,14 +17,18 @@ syscallret syscall_fcntl(int ifd, int cmd, uint64_t arg){ fd_t* fd = NULL; + proc_t* proc = arch_getcls()->thread->proc; + if(cmd != F_DUPFD){ - retv.errno = fd_access(&arch_getcls()->thread->proc->fdtable, &fd, ifd); + retv.errno = fd_access(&proc->fdtable, &fd, ifd); if(retv.errno) return retv; } - switch(cmd){ + case F_DUPFD: + retv.errno = fd_duplicate(&proc->fdtable, ifd, arg, 1, &retv.ret); + return retv; case F_GETFD: // no fd flags implemented case F_SETFD: retv.ret = 0;