[CRIU] [PATCH 5/9] tty: Rename helpers to reflect the type of peers

Cyrill Gorcunov gorcunov at openvz.org
Wed Oct 1 13:52:36 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 a208f263c9d4..9bca3098135e 100644
--- a/tty.c
+++ b/tty.c
@@ -199,7 +199,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;
 
@@ -395,19 +395,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);
@@ -417,7 +417,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)
@@ -477,7 +477,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) {
@@ -658,7 +658,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);
@@ -681,7 +681,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;
@@ -745,13 +745,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
@@ -774,7 +774,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;
@@ -800,14 +800,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;
 			}
@@ -896,7 +896,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)) {
@@ -1171,7 +1171,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