From 9815b8b06d71917e350221f77956cdd2a8d3ef97 Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 24 Oct 2022 15:35:33 -0300 Subject: [PATCH] fcntl: properly handle F_SETFL now --- src/sys/syscalls/fcntl.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/sys/syscalls/fcntl.c b/src/sys/syscalls/fcntl.c index fe2bc991..d09ffd86 100644 --- a/src/sys/syscalls/fcntl.c +++ b/src/sys/syscalls/fcntl.c @@ -36,7 +36,18 @@ syscallret syscall_fcntl(int ifd, int cmd, uint64_t arg){ case F_GETFL: retv.ret = fd->flags; break; - case F_SETFL: // no useful status flags implemented + case F_SETFL: + // mask away things that shouldn't be changed + arg &= ~(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_EXCL | O_NOCTTY | O_TRUNC); + + // and mask away from the flags the things that will be set + + fd->flags &= ~(O_APPEND | O_ASYNC | O_NOATIME | O_NONBLOCK); + + // finally set the flags + + fd->flags |= arg; + retv.ret = 0; break; default: