diff --git a/src/add-ons/kernel/drivers/common/console.cpp b/src/add-ons/kernel/drivers/common/console.cpp index fa601e6773..99901f45a8 100644 --- a/src/add-ons/kernel/drivers/common/console.cpp +++ b/src/add-ons/kernel/drivers/common/console.cpp @@ -15,6 +15,7 @@ #include #include +#include #define DEVICE_NAME "console" @@ -705,6 +706,16 @@ console_write(void *cookie, off_t pos, const void *buffer, size_t *_length) static status_t console_ioctl(void *cookie, uint32 op, void *buffer, size_t length) { + struct console_desc *console = (struct console_desc *)cookie; + + if (op == TIOCGWINSZ) { + struct winsize size; + size.ws_xpixel = size.ws_col = console->columns; + size.ws_ypixel = size.ws_row = console->lines; + + return user_memcpy(buffer, &size, sizeof(struct winsize)); + } + return B_BAD_VALUE; } diff --git a/src/tests/kernel/consoled/consoled.cpp b/src/tests/kernel/consoled/consoled.cpp index c0cf724152..b1225e96c4 100644 --- a/src/tests/kernel/consoled/consoled.cpp +++ b/src/tests/kernel/consoled/consoled.cpp @@ -210,6 +210,7 @@ start_console(struct console *con) } else { // set default mode struct termios termios; + struct winsize size; if (tcgetattr(con->tty_slave_fd, &termios) == 0) { termios.c_iflag = ICRNL; @@ -218,6 +219,11 @@ start_console(struct console *con) tcsetattr(con->tty_slave_fd, TCSANOW, &termios); } + + if (ioctl(con->console_fd, TIOCGWINSZ, &size, sizeof(struct winsize)) == 0) { + // we got the window size from the console + ioctl(con->tty_slave_fd, TIOCSWINSZ, &size, sizeof(struct winsize)); + } } break; }