[CRIU] [PATCH 03/11] tty: Introduce dump_one_tty helper

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


Depending on tty major/minor numbers we will
need different dumping routines so choose one
here.

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

diff --git a/tty.c b/tty.c
index 309d28c3a024..770056934f28 100644
--- a/tty.c
+++ b/tty.c
@@ -1160,14 +1160,11 @@ out:
 	return ret;
 }
 
-static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p)
+static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p, int major, int minor)
 {
 	TtyFileEntry e = TTY_FILE_ENTRY__INIT;
-	int ret = 0, major, index;
+	int ret = 0, index;
 
-	pr_info("Dumping tty %d with id %#x\n", lfd, id);
-
-	major = major(p->stat.st_rdev);
 	index = parse_index(id, lfd, major);
 	if (index < 0)
 		return -1;
@@ -1205,9 +1202,33 @@ static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p)
 	return ret;
 }
 
+static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
+{
+	int major = major(p->stat.st_rdev);
+	int minor = minor(p->stat.st_rdev);
+
+	pr_info("Dumping tty (%d:%d) %d with id %#x\n",
+		major, minor, lfd, id);
+
+	switch (major) {
+	case TTYAUX_MAJOR:
+		if (minor == 0 || minor == 2)
+			return dump_one_pty(lfd, id, p, major, minor);
+		break;
+	case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
+	case UNIX98_PTY_SLAVE_MAJOR:
+		return dump_one_pty(lfd, id, p, major, minor);
+	default:
+		break;
+	}
+
+	pr_err("Unsupported tty (%d:%d) device\n", major, minor);
+	return -1;
+}
+
 const struct fdtype_ops tty_dump_ops = {
 	.type	= FD_TYPES__TTY,
-	.dump	= dump_one_pty,
+	.dump	= dump_one_tty,
 };
 
 int tty_prep_fds(void)
-- 
1.9.3



More information about the CRIU mailing list