Commit 978cecd6 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Make termios and winsize being optional params

The dangling slave peers might have no data associate
with them if master peer is closed and link is hanging
up. Thus make this parameters optional to not blow the
image with data which never will be used.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 52a2c9fd
......@@ -47,9 +47,9 @@ message tty_info_entry {
*/
required uint32 rdev = 8;
required termios_entry termios = 9;
required termios_entry termios_locked = 10;
required winsize_entry winsize = 11;
optional termios_entry termios = 9;
optional termios_entry termios_locked = 10;
optional winsize_entry winsize = 11;
/*
* These are optional fields which presense depends on
......
......@@ -412,20 +412,26 @@ static int restore_tty_params(int fd, struct tty_info *info)
* never be extended.
*/
if (info->tie->termios_locked) {
memzero(&t, sizeof(t));
termios_copy(&t, info->tie->termios_locked);
if (ioctl(fd, TIOCSLCKTRMIOS, &t) < 0)
goto err;
}
if (info->tie->termios) {
memzero(&t, sizeof(t));
termios_copy(&t, info->tie->termios);
if (ioctl(fd, TCSETS, &t) < 0)
goto err;
}
if (info->tie->winsize) {
memzero(&w, sizeof(w));
winsize_copy(&w, info->tie->winsize);
if (ioctl(fd, TIOCSWINSZ, &w) < 0)
goto err;
}
return 0;
err:
......@@ -632,7 +638,7 @@ static int tty_setup_slavery(void)
static int veirfy_termios(u32 id, TermiosEntry *e)
{
if (e->n_c_cc < TERMIOS_NCC) {
if (e && e->n_c_cc < TERMIOS_NCC) {
pr_err("pty ID %#x n_c_cc (%d) has wrong value\n",
id, (int)e->n_c_cc);
return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment