kernel+libc: Implement isatty()
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
parent
7328cfe734
commit
69f9701097
@ -81,6 +81,11 @@ namespace VFS
|
||||
return err(ENOTTY);
|
||||
}
|
||||
|
||||
virtual Result<u64> isatty() const
|
||||
{
|
||||
return err(ENOTTY);
|
||||
}
|
||||
|
||||
// Directory-specific methods
|
||||
virtual Result<SharedPtr<Inode>> find(const char* name) const = 0;
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "memory/MemoryManager.h"
|
||||
#include "thread/Scheduler.h"
|
||||
#include "video/TextConsole.h"
|
||||
#include <bits/ioctl-defs.h>
|
||||
#include <bits/termios.h>
|
||||
#include <luna/Buffer.h>
|
||||
#include <luna/CString.h>
|
||||
|
@ -22,5 +22,10 @@ class ConsoleDevice : public Device
|
||||
return "console";
|
||||
}
|
||||
|
||||
Result<u64> isatty() const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual ~ConsoleDevice() = default;
|
||||
};
|
||||
|
@ -14,6 +14,11 @@ class Device
|
||||
return err(ENOTTY);
|
||||
}
|
||||
|
||||
virtual Result<u64> isatty() const
|
||||
{
|
||||
return err(ENOTTY);
|
||||
}
|
||||
|
||||
virtual usize size() const
|
||||
{
|
||||
return 0;
|
||||
|
@ -276,6 +276,11 @@ namespace TmpFS
|
||||
return m_device->ioctl(request, arg);
|
||||
}
|
||||
|
||||
Result<u64> isatty() const override
|
||||
{
|
||||
return m_device->isatty();
|
||||
}
|
||||
|
||||
bool blocking() const override
|
||||
{
|
||||
return m_device->blocking();
|
||||
|
@ -157,6 +157,16 @@ Result<u64> sys_ioctl(Registers*, SyscallArgs args)
|
||||
return descriptor.inode->ioctl(request, arg);
|
||||
}
|
||||
|
||||
Result<u64> sys_isatty(Registers*, SyscallArgs args)
|
||||
{
|
||||
int fd = (int)args[0];
|
||||
|
||||
Thread* current = Scheduler::current();
|
||||
auto& descriptor = *TRY(current->resolve_fd(fd));
|
||||
|
||||
return descriptor.inode->isatty();
|
||||
}
|
||||
|
||||
Result<u64> sys_dup2(Registers*, SyscallArgs args)
|
||||
{
|
||||
int oldfd = (int)args[0];
|
||||
|
@ -168,6 +168,9 @@ extern "C"
|
||||
/* Check for a file's accessibility relative to a file descriptor. */
|
||||
int faccessat(int dirfd, const char* path, int amode, int flags);
|
||||
|
||||
/* Check whether a file descriptor refers to a terminal device. */
|
||||
int isatty(int fd);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -467,4 +467,15 @@ extern "C"
|
||||
long rc = syscall(SYS_faccessat, dirfd, path, amode, flags);
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int isatty(int fd)
|
||||
{
|
||||
long rc = syscall(SYS_isatty, fd);
|
||||
if (rc < 0)
|
||||
{
|
||||
errno = -rc;
|
||||
return 0;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
_e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) _e(ioctl) \
|
||||
_e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) _e(mount) \
|
||||
_e(umount) _e(pstat) _e(getrusage) _e(symlinkat) _e(readlinkat) _e(umask) _e(linkat) _e(faccessat) \
|
||||
_e(pivot_root) _e(sigreturn) _e(sigaction) _e(kill) _e(sigprocmask) _e(setpgid)
|
||||
_e(pivot_root) _e(sigreturn) _e(sigaction) _e(kill) _e(sigprocmask) _e(setpgid) _e(isatty)
|
||||
|
||||
enum Syscalls
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user