Kernel: Fix multiple bugs with terminal

This commit is contained in:
2023-07-13 13:09:52 +03:00
parent 2576bdbd14
commit 3748f0304f
4 changed files with 18 additions and 21 deletions

View File

@@ -167,7 +167,7 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_gettermios(::termios* termios)
{
LockGuard _(m_lock);
if (m_tty == nullptr)
if (!m_tty)
return BAN::Error::from_errno(ENOTTY);
Kernel::termios ktermios = m_tty->get_termios();
@@ -183,7 +183,7 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_settermios(const ::termios* termios)
{
LockGuard _(m_lock);
if (m_tty == nullptr)
if (!m_tty)
return BAN::Error::from_errno(ENOTTY);
Kernel::termios ktermios;
@@ -748,15 +748,17 @@ namespace Kernel
BAN::ErrorOr<long> Process::sys_termid(char* buffer) const
{
LockGuard _(m_lock);
if (m_tty == nullptr)
if (!m_tty)
buffer[0] = '\0';
ASSERT(minor(m_tty->rdev()) < 10);
strcpy(buffer, "/dev/tty1");
buffer[8] += minor(m_tty->rdev());
else
{
ASSERT(minor(m_tty->rdev()) < 10);
strcpy(buffer, "/dev/tty0");
buffer[8] += minor(m_tty->rdev());
}
return 0;
}
BAN::ErrorOr<long> Process::sys_clock_gettime(clockid_t clock_id, timespec* tp) const
{
switch (clock_id)