Kernel/LibC: Implement SYS_ISATTY and isatty()
This commit is contained in:
parent
6346d1b6c7
commit
aec5a09caf
|
@ -162,6 +162,8 @@ namespace Kernel
|
||||||
BAN::ErrorOr<long> sys_smo_delete(SharedMemoryObjectManager::Key);
|
BAN::ErrorOr<long> sys_smo_delete(SharedMemoryObjectManager::Key);
|
||||||
BAN::ErrorOr<long> sys_smo_map(SharedMemoryObjectManager::Key);
|
BAN::ErrorOr<long> sys_smo_map(SharedMemoryObjectManager::Key);
|
||||||
|
|
||||||
|
BAN::ErrorOr<long> sys_isatty(int fildes);
|
||||||
|
|
||||||
BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags);
|
BAN::ErrorOr<long> sys_tty_ctrl(int fildes, int command, int flags);
|
||||||
|
|
||||||
BAN::ErrorOr<long> sys_signal(int, void (*)(int));
|
BAN::ErrorOr<long> sys_signal(int, void (*)(int));
|
||||||
|
|
|
@ -1433,6 +1433,15 @@ namespace Kernel
|
||||||
return m_mapped_regions.back()->vaddr();
|
return m_mapped_regions.back()->vaddr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BAN::ErrorOr<long> Process::sys_isatty(int fildes)
|
||||||
|
{
|
||||||
|
LockGuard _(m_process_lock);
|
||||||
|
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
|
||||||
|
if (!inode->is_tty())
|
||||||
|
return BAN::Error::from_errno(ENOTTY);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
BAN::ErrorOr<long> Process::sys_tty_ctrl(int fildes, int command, int flags)
|
BAN::ErrorOr<long> Process::sys_tty_ctrl(int fildes, int command, int flags)
|
||||||
{
|
{
|
||||||
LockGuard _(m_process_lock);
|
LockGuard _(m_process_lock);
|
||||||
|
|
|
@ -77,6 +77,7 @@ __BEGIN_DECLS
|
||||||
O(SYS_SMO_CREATE, smo_create) \
|
O(SYS_SMO_CREATE, smo_create) \
|
||||||
O(SYS_SMO_DELETE, smo_delete) \
|
O(SYS_SMO_DELETE, smo_delete) \
|
||||||
O(SYS_SMO_MAP, smo_map) \
|
O(SYS_SMO_MAP, smo_map) \
|
||||||
|
O(SYS_ISATTY, isatty) \
|
||||||
|
|
||||||
enum Syscall
|
enum Syscall
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,6 +114,11 @@ int dup2(int fildes, int fildes2)
|
||||||
return syscall(SYS_DUP2, fildes, fildes2);
|
return syscall(SYS_DUP2, fildes, fildes2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isatty(int fildes)
|
||||||
|
{
|
||||||
|
return syscall(SYS_ISATTY, fildes) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
int execl(const char* pathname, const char* arg0, ...)
|
int execl(const char* pathname, const char* arg0, ...)
|
||||||
{
|
{
|
||||||
if (arg0 == nullptr)
|
if (arg0 == nullptr)
|
||||||
|
|
Loading…
Reference in New Issue