[CRIU] [PATCH 02/11] tty: Move tty_type() and is_pty() to tty.c

Pavel Emelyanov xemul at parallels.com
Wed Feb 18 07:26:50 PST 2015


Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 include/tty.h | 31 +------------------------------
 tty.c         | 30 ++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/include/tty.h b/include/tty.h
index bb01d90..c547a69 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -27,41 +27,12 @@ enum {
 
 extern const struct fdtype_ops tty_dump_ops;
 
-static inline int tty_type(int major, int minor)
-{
-	switch (major) {
-	case TTYAUX_MAJOR:
-		if (minor == 0 || minor == 2)
-			return TTY_TYPE_PTM;
-		else if (minor == 1)
-			return TTY_TYPE_CONSOLE;
-		break;
-	case TTY_MAJOR:
-		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
-			/*
-			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
-			 * for consoles (virtual terminals, VT in terms
-			 * of kernel).
-			 */
-			return TTY_TYPE_VT;
-	case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
-		return TTY_TYPE_PTM;
-	case UNIX98_PTY_SLAVE_MAJOR:
-		return TTY_TYPE_PTS;
-	}
-	return TTY_TYPE_UNKNOWN;
-}
-
+int tty_type(int major, int minor);
 static inline int is_tty(int major, int minor)
 {
 	return tty_type(major, minor) != TTY_TYPE_UNKNOWN;
 }
 
-static inline int is_pty(int type)
-{
-	return (type == TTY_TYPE_PTM || type == TTY_TYPE_PTS);
-}
-
 extern int dump_verify_tty_sids(void);
 extern struct collect_image_info tty_info_cinfo;
 extern struct collect_image_info tty_cinfo;
diff --git a/tty.c b/tty.c
index f3afc9c..bca23f4 100644
--- a/tty.c
+++ b/tty.c
@@ -130,6 +130,36 @@ static LIST_HEAD(all_ttys);
 static DECLARE_BITMAP(tty_bitmap, (MAX_TTYS << 1));
 static DECLARE_BITMAP(tty_active_pairs, (MAX_TTYS << 1));
 
+int tty_type(int major, int minor)
+{
+	switch (major) {
+	case TTYAUX_MAJOR:
+		if (minor == 0 || minor == 2)
+			return TTY_TYPE_PTM;
+		else if (minor == 1)
+			return TTY_TYPE_CONSOLE;
+		break;
+	case TTY_MAJOR:
+		if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
+			/*
+			 * Minors [MIN_NR_CONSOLES; MAX_NR_CONSOLES] stand
+			 * for consoles (virtual terminals, VT in terms
+			 * of kernel).
+			 */
+			return TTY_TYPE_VT;
+	case UNIX98_PTY_MASTER_MAJOR ... (UNIX98_PTY_MASTER_MAJOR + UNIX98_PTY_MAJOR_COUNT - 1):
+		return TTY_TYPE_PTM;
+	case UNIX98_PTY_SLAVE_MAJOR:
+		return TTY_TYPE_PTS;
+	}
+	return TTY_TYPE_UNKNOWN;
+}
+
+static inline int is_pty(int type)
+{
+	return (type == TTY_TYPE_PTM || type == TTY_TYPE_PTS);
+}
+
 /*
  * /dev/ptmx is a shared resource between all tasks
  * so we need to serialize access to it.
-- 
1.8.4.2




More information about the CRIU mailing list