fd: new abstraction

This commit is contained in:
Matheus
2022-09-18 16:21:19 -03:00
parent 73a8584a72
commit 41d6e7230e
11 changed files with 216 additions and 151 deletions
+9 -13
View File
@@ -12,26 +12,22 @@ syscallret syscall_isatty(int ifd){
proc_t* proc = arch_getcls()->thread->proc;
fd_t* fd = proc->fds + ifd;
fd_t* fd;
int ret = fd_access(&proc->fdtable, &fd, ifd);
spinlock_acquire(&proc->fdlock);
if(proc->fdcount <= ifd || fd->node == NULL){
spinlock_release(&proc->fdlock);
retv.errno = EBADF;
return retv;
}
if(ret){
retv.errno = ret;
return retv;
}
spinlock_acquire(&fd->lock);
spinlock_release(&proc->fdlock);
int ret = vfs_isatty(fd->node);
ret = vfs_isatty(fd->node);
retv.errno = ret;
retv.ret = retv.errno == ENOTTY ? 0 : 1;
spinlock_release(&fd->lock);
fd_release(fd);
return retv;