Kernel: Implement TIOCSWINSZ for pseudo terminals
I have no idea how I had forgotten this
This commit is contained in:
parent
9caa3030ea
commit
69137cddab
|
@ -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<long> ioctl_impl(int, void*) override;
|
||||
|
||||
private:
|
||||
PseudoTerminalMaster(BAN::UniqPtr<VirtualRange>, mode_t, uid_t, gid_t);
|
||||
~PseudoTerminalMaster();
|
||||
|
@ -61,6 +63,8 @@ namespace Kernel
|
|||
protected:
|
||||
void putchar_impl(uint8_t ch) override;
|
||||
|
||||
BAN::ErrorOr<long> ioctl_impl(int, void*) override;
|
||||
|
||||
private:
|
||||
PseudoTerminalSlave(BAN::String&& name, uint32_t number, mode_t, uid_t, gid_t);
|
||||
~PseudoTerminalSlave();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <BAN/ScopeGuard.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/sysmacros.h>
|
||||
|
||||
namespace Kernel
|
||||
|
@ -139,6 +140,14 @@ namespace Kernel
|
|||
return buffer.size();
|
||||
}
|
||||
|
||||
BAN::ErrorOr<long> 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<long> PseudoTerminalSlave::ioctl_impl(int request, void* argument)
|
||||
{
|
||||
switch (request)
|
||||
{
|
||||
case TIOCSWINSZ:
|
||||
{
|
||||
const auto* winsize = static_cast<struct winsize*>(argument);
|
||||
m_width = winsize->ws_col;
|
||||
m_height = winsize->ws_row;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return TTY::ioctl_impl(request, argument);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue