[CRIU] [PATCH 7/9] tty: Rework tty_type to account minor number

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 1 13:52:38 PDT 2014


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

diff --git a/tty.c b/tty.c
index 1d9549bef209..43d3e5a24395 100644
--- a/tty.c
+++ b/tty.c
@@ -380,21 +380,18 @@ 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";
 	}
-
-	return tty_unknown;
+	return "unknown";
 }
 
 static bool tty_is_master(struct tty_info *info)
@@ -418,7 +415,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);
 }
 
@@ -1039,7 +1036,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