mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 18:05:07 +00:00
Add TIOCGWINSZ ioctl so userland can determine terminal geometry.
(Don't) use this to implement short-form output in ls. I'm too tired to make a nice column formatting algorithm. I just wanted something concise when I type "ls".
This commit is contained in:
parent
f5a83c4d8a
commit
ac7a60225e
11 changed files with 208 additions and 63 deletions
|
@ -109,6 +109,7 @@ int TTY::ioctl(Process& process, unsigned request, unsigned arg)
|
|||
{
|
||||
pid_t pgid;
|
||||
Unix::termios* tp;
|
||||
Unix::winsize* ws;
|
||||
|
||||
if (process.tty() != this)
|
||||
return -ENOTTY;
|
||||
|
@ -136,7 +137,20 @@ int TTY::ioctl(Process& process, unsigned request, unsigned arg)
|
|||
return -EFAULT;
|
||||
set_termios(*tp);
|
||||
return 0;
|
||||
case TIOCGWINSZ:
|
||||
ws = reinterpret_cast<Unix::winsize*>(arg);
|
||||
if (!process.validate_write(ws, sizeof(Unix::winsize)))
|
||||
return -EFAULT;
|
||||
ws->ws_row = m_rows;
|
||||
ws->ws_col = m_columns;
|
||||
return 0;
|
||||
}
|
||||
ASSERT_NOT_REACHED();
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
void TTY::set_size(unsigned short columns, unsigned short rows)
|
||||
{
|
||||
m_rows = rows;
|
||||
m_columns = columns;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue