syscalls: isatty

This commit is contained in:
Matheus
2023-07-04 20:19:15 -03:00
parent 51446cdd37
commit 04a5aa4bc6
8 changed files with 59 additions and 11 deletions
+25
View File
@@ -0,0 +1,25 @@
#include <kernel/syscalls.h>
#include <kernel/vfs.h>
#include <kernel/file.h>
syscallret_t syscall_isatty(context_t *context, int fd) {
syscallret_t ret = {
.ret = -1
};
file_t *file = fd_get(fd);
if (file == NULL) {
ret.errno = EBADF;
return ret;
}
// mlibc expects isatty to return 1 if a terminal and 0 if not.
int e = VOP_ISATTY(file->vnode);
ret.errno = e;
ret.ret = e ? 0 : 1;
fd_release(file);
return ret;
}