diff --git a/kernel/include/kernel/Terminal/PseudoTerminal.h b/kernel/include/kernel/Terminal/PseudoTerminal.h index 1eebefb3..731ecd45 100644 --- a/kernel/include/kernel/Terminal/PseudoTerminal.h +++ b/kernel/include/kernel/Terminal/PseudoTerminal.h @@ -30,6 +30,8 @@ namespace Kernel bool can_write_impl() const override { SpinLockGuard _(m_buffer_lock); return m_buffer_size < m_buffer->size(); } bool has_error_impl() const override { return false; } + BAN::ErrorOr ioctl_impl(int, void*) override; + private: PseudoTerminalMaster(BAN::UniqPtr, mode_t, uid_t, gid_t); ~PseudoTerminalMaster(); @@ -61,6 +63,8 @@ namespace Kernel protected: void putchar_impl(uint8_t ch) override; + BAN::ErrorOr ioctl_impl(int, void*) override; + private: PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t, uid_t, gid_t); ~PseudoTerminalSlave(); diff --git a/kernel/kernel/Terminal/PseudoTerminal.cpp b/kernel/kernel/Terminal/PseudoTerminal.cpp index 51b4b5d7..6f2428b4 100644 --- a/kernel/kernel/Terminal/PseudoTerminal.cpp +++ b/kernel/kernel/Terminal/PseudoTerminal.cpp @@ -4,6 +4,7 @@ #include +#include #include namespace Kernel @@ -139,6 +140,14 @@ namespace Kernel return buffer.size(); } + BAN::ErrorOr PseudoTerminalMaster::ioctl_impl(int request, void* argument) + { + auto slave = m_slave.lock(); + if (!slave) + return BAN::Error::from_errno(ENODEV); + return slave->ioctl(request, argument); + } + PseudoTerminalSlave::PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t mode, uid_t uid, gid_t gid) : TTY(mode, uid, gid) , m_name(BAN::move(name)) @@ -163,4 +172,20 @@ namespace Kernel master->putchar(ch); } + BAN::ErrorOr PseudoTerminalSlave::ioctl_impl(int request, void* argument) + { + switch (request) + { + case TIOCSWINSZ: + { + const auto* winsize = static_cast(argument); + m_width = winsize->ws_col; + m_height = winsize->ws_row; + return 0; + } + } + + return TTY::ioctl_impl(request, argument); + } + }