[CRIU] [PATCH 06/11] tty: Split tty indices into range

Cyrill Gorcunov gorcunov at openvz.org
Mon Sep 29 09:25:32 PDT 2014


To carry console device we need own index,
so split initial 1024 ptys into 768 for
ptys and 256 for the rest of various ttys
(at moment for console only but in future
we might need more types here).

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 tty.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/tty.c b/tty.c
index d50636051603..72f0846f1eec 100644
--- a/tty.c
+++ b/tty.c
@@ -110,9 +110,13 @@ static LIST_HEAD(all_ttys);
  * This particular bitmap requires 256 bytes of memory.
  * Pretty acceptable trade off in a sake of simplicity.
  */
-#define MAX_TTYS 1024
-static DECLARE_BITMAP(tty_bitmap, (MAX_TTYS << 1));
-static DECLARE_BITMAP(tty_active_pairs, (MAX_TTYS << 1));
+#define MAX_TTYS	1024
+#define MAX_PTYS	768
+#define CONSOLE_START	(MAX_PTYS + 2)
+#define MAX_TTYS_ID	(MAX_TTYS << 1)
+
+static DECLARE_BITMAP(tty_bitmap, MAX_TTYS_ID);
+static DECLARE_BITMAP(tty_active_pairs, MAX_TTYS_ID);
 
 /*
  * /dev/ptmx is a shared resource between all tasks
@@ -231,7 +235,7 @@ static int parse_index(u32 id, int lfd, int major)
 	}
 	}
 
-	if (index > MAX_TTYS) {
+	if (index > MAX_PTYS) {
 		pr_err("Index %d on tty %x is too big\n", index, id);
 		return -1;
 	}
@@ -908,7 +912,7 @@ static int verify_info(struct tty_info *info)
 	    verify_termios(info->tfe->id, info->tie->termios))
 		return -1;
 
-	if (info->tie->termios && info->tfe->tty_info_id > (MAX_TTYS << 1))
+	if (info->tie->termios && info->tfe->tty_info_id > MAX_TTYS_ID)
 		return -1;
 
 	return 0;
-- 
1.9.3



More information about the CRIU mailing list