[CRIU] [PATCH 09/11] tty: Rework tty_type to account minor number

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


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

diff --git a/tty.c b/tty.c
index 13b313718f8b..f84dcfc9119c 100644
--- a/tty.c
+++ b/tty.c
@@ -383,21 +383,20 @@ static int tty_restore_ctl_terminal(struct file_desc *d, int fd)
 	return ret;
 }
 
-static char *tty_type(int major)
+static char *tty_type(int major, int minor)
 {
-	static char *tty_types[] = {
-		[UNIX98_PTY_SLAVE_MAJOR]	= "pts",
-		[TTYAUX_MAJOR]			= "ptmx",
-	};
-	static char tty_unknown[]		= "unknown";
-
 	switch (major) {
+	case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
+		return "ptmx";
 	case UNIX98_PTY_SLAVE_MAJOR:
+		return "pts";
 	case TTYAUX_MAJOR:
-		return tty_types[major];
+		if (minor == 0 || minor == 2)
+			return "ptmx";
+		else if (minor == 1)
+			return "console";
 	}
-
-	return tty_unknown;
+	return "unknown";
 }
 
 static bool tty_is_master(struct tty_info *info)
@@ -421,7 +420,7 @@ static bool tty_has_active_pair(struct tty_info *info)
 static void tty_show_pty_info(char *prefix, struct tty_info *info)
 {
 	pr_info("%s type %s id %#x index %d (master %d sid %d pgrp %d inherit %d)\n",
-		prefix, tty_type(info->major), info->tfe->id, info->tie->pty->index,
+		prefix, tty_type(info->major, info->minor), info->tfe->id, info->tie->pty->index,
 		tty_is_master(info), info->tie->sid, info->tie->pgrp, info->inherit);
 }
 
@@ -1042,7 +1041,7 @@ int dump_verify_tty_sids(void)
 				if (!opts.shell_job) {
 					pr_err("Found dangling tty with sid %d pgid %d (%s) on peer fd %d.\n",
 					       dinfo->sid, dinfo->pgrp,
-					       tty_type(dinfo->major),
+					       tty_type(dinfo->major, dinfo->minor),
 					       dinfo->fd);
 					/*
 					 * First thing people do with criu is dump smth
-- 
1.9.3



More information about the CRIU mailing list