mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-11-01 06:58:22 +00:00
fd: new abstraction
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user