Files
Astral/src/sys/syscalls/isatty.c
T
2022-09-22 14:36:55 -03:00

34 lines
509 B
C

#include <kernel/syscalls.h>
#include <kernel/fd.h>
#include <kernel/vfs.h>
#include <arch/cls.h>
#include <kernel/sched.h>
#include <arch/spinlock.h>
syscallret syscall_isatty(int ifd){
syscallret retv;
retv.ret = -1;
proc_t* proc = arch_getcls()->thread->proc;
fd_t* fd;
int ret = fd_access(&proc->fdtable, &fd, ifd);
if(ret){
retv.errno = ret;
return retv;
}
ret = vfs_isatty(fd->node);
retv.errno = ret;
retv.ret = ret ? 1 : 0;
fd_release(fd);
return retv;
}