Commit ac3296c3 authored by Andrei Vagin's avatar Andrei Vagin Committed by Andrei Vagin

tty: allocate a separate tty info id for each external tty

Otherwise all external tty-s will share the same tty info,
what is obviously wrong.

v2: allocate a separate tty index range for externl terminals

Cc: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 37711ace
......@@ -136,7 +136,7 @@ static int self_stdin_fdid = -1;
* Pretty acceptable trade off in a sake of simplicity.
*/
#define MAX_TTYS 1024
#define MAX_TTYS 1088
/*
* Custom indices should be even numbers just in case if we
......@@ -147,8 +147,9 @@ static int self_stdin_fdid = -1;
#define CONSOLE_INDEX 1002
#define VT_INDEX 1004
#define CTTY_INDEX 1006
#define ETTY_INDEX 1008
#define STTY_INDEX 1010
#define ETTY_INDEX 1012
#define ETTY_INDEX_MAX 1076
#define INDEX_ERR (MAX_TTYS + 1)
static DECLARE_BITMAP(tty_bitmap, (MAX_TTYS << 1));
......@@ -189,6 +190,20 @@ static int pty_get_index(struct tty_info *ti)
return ti->tie->pty->index;
}
static int ext_fd_get_index(int fd, const struct fd_parms *p)
{
static int index;
index++;
if (index + ETTY_INDEX > ETTY_INDEX_MAX) {
pr_err("Too many external terminals\n");
return INDEX_ERR;
}
return index + ETTY_INDEX;
}
static int pty_open_ptmx(struct tty_info *info);
static struct tty_driver ptm_driver = {
......@@ -229,6 +244,7 @@ static struct tty_driver ext_driver = {
.name = "ext",
.index = ETTY_INDEX,
.open = open_ext_tty,
.fd_get_index = ext_fd_get_index,
};
static struct tty_driver serial_driver = {
......
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