[CRIU] [PATCH 07/11] tty: Rename helpers to reflect the type of peers

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


 - parse_index -> parse_pty_index since it's PTY specific
 - pty_is_master -> tty_is_master because it will test
   not only PTY peers but other types as well
 - pty_is_hung -> tty_is_hung for same reason

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

diff --git a/tty.c b/tty.c
index 72f0846f1eec..07cab3e5abaf 100644
--- a/tty.c
+++ b/tty.c
@@ -202,7 +202,7 @@ int tty_verify_active_pairs(void)
 	return 0;
 }
 
-static int parse_index(u32 id, int lfd, int major)
+static int parse_pty_index(u32 id, int lfd, int major)
 {
 	int index = -1;
 
@@ -398,19 +398,19 @@ static char *tty_type(int major)
 	return tty_unknown;
 }
 
-static bool pty_is_master(struct tty_info *info)
+static bool tty_is_master(struct tty_info *info)
 {
 	return info->major == TTYAUX_MAJOR;
 }
 
-static bool pty_is_hung(struct tty_info *info)
+static bool tty_is_hung(struct tty_info *info)
 {
 	return info->tie->termios == NULL;
 }
 
 static bool tty_has_active_pair(struct tty_info *info)
 {
-	int d = pty_is_master(info) ? -1 : + 1;
+	int d = tty_is_master(info) ? -1 : + 1;
 
 	return test_bit(info->tfe->tty_info_id + d,
 			tty_active_pairs);
@@ -420,7 +420,7 @@ 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,
-		pty_is_master(info), info->tie->sid, info->tie->pgrp, info->inherit);
+		tty_is_master(info), info->tie->sid, info->tie->pgrp, info->inherit);
 }
 
 static int restore_tty_params(int fd, struct tty_info *info)
@@ -480,7 +480,7 @@ static int pty_open_slaves(struct tty_info *info)
 	}
 
 	list_for_each_entry(slave, &info->sibling, sibling) {
-		BUG_ON(pty_is_master(slave));
+		BUG_ON(tty_is_master(slave));
 
 		fd = open(pts_name, slave->tfe->flags | O_NOCTTY);
 		if (fd < 0) {
@@ -661,7 +661,7 @@ static int tty_open(struct file_desc *d)
 	if (!info->create)
 		return receive_tty(info);
 
-	if (!pty_is_master(info))
+	if (!tty_is_master(info))
 		return pty_open_unpaired_slave(d, info);
 
 	return pty_open_ptmx(info);
@@ -684,7 +684,7 @@ static void tty_collect_fd(struct file_desc *d, struct fdinfo_list_entry *fle,
 	 * opened before them
 	 */
 
-	if (pty_is_master(container_of(d, struct tty_info, d)))
+	if (tty_is_master(container_of(d, struct tty_info, d)))
 		tgt = &ri->fds;
 	else
 		tgt = &ri->tty_slaves;
@@ -748,13 +748,13 @@ static int tty_find_restoring_task(struct tty_info *info)
 	 * rather non-usable anyway.
 	 */
 
-	if (pty_is_hung(info)) {
+	if (tty_is_hung(info)) {
 		pr_debug("Hungup terminal found id %x\n", info->tfe->id);
 		return 0;
 	}
 
 	if (info->tie->sid) {
-		if (!pty_is_master(info)) {
+		if (!tty_is_master(info)) {
 			if (tty_has_active_pair(info))
 				return 0;
 			else
@@ -777,7 +777,7 @@ static int tty_find_restoring_task(struct tty_info *info)
 
 		goto notask;
 	} else {
-		if (pty_is_master(info))
+		if (tty_is_master(info))
 			return 0;
 		if (tty_has_active_pair(info))
 			return 0;
@@ -803,14 +803,14 @@ static int tty_setup_orphan_slavery(void)
 		struct fdinfo_list_entry *a, *b;
 		bool has_leader = false;
 
-		if (pty_is_master(info))
+		if (tty_is_master(info))
 			continue;
 
 		a = file_master(&info->d);
 		m = info;
 
 		list_for_each_entry(peer, &info->sibling, sibling) {
-			if (pty_is_master(peer)) {
+			if (tty_is_master(peer)) {
 				has_leader = true;
 				break;
 			}
@@ -899,7 +899,7 @@ static int verify_info(struct tty_info *info)
 	 * or don't have them at all.
 	 */
 	if (term_opts_missing_any(info)) {
-		if (pty_is_master(info)) {
+		if (tty_is_master(info)) {
 			pr_err("Corrupted master peer %x\n", info->tfe->id);
 			return -1;
 		} else if (!term_opts_missing_all(info)) {
@@ -1174,7 +1174,7 @@ static int dump_one_pty(int lfd, u32 id, const struct fd_parms *p, int major, in
 	TtyFileEntry e = TTY_FILE_ENTRY__INIT;
 	int ret = 0, index;
 
-	index = parse_index(id, lfd, major);
+	index = parse_pty_index(id, lfd, major);
 	if (index < 0)
 		return -1;
 
-- 
1.9.3



More information about the CRIU mailing list