[CRIU] [PATCH 02/12] files: Move prepare_ctl_tty() to criu/tty.c

Kirill Tkhai ktkhai at virtuozzo.com
Tue Dec 26 18:46:03 MSK 2017


Move the function and reduce its arguments number.
This is cleanup needed to keep all tty code together.

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 criu/files.c         |   27 ---------------------------
 criu/include/files.h |    1 -
 criu/tty.c           |   31 ++++++++++++++++++++++++++++---
 3 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/criu/files.c b/criu/files.c
index 11b87e1fe..5aaaef104 100644
--- a/criu/files.c
+++ b/criu/files.c
@@ -884,33 +884,6 @@ int dup_fle(struct pstree_item *task, struct fdinfo_list_entry *ple,
 	return collect_fd(vpid(task), e, rsti(task), false);
 }
 
-int prepare_ctl_tty(int pid, struct rst_info *rst_info, u32 ctl_tty_id)
-{
-	FdinfoEntry *e;
-
-	if (!ctl_tty_id)
-		return 0;
-
-	pr_info("Requesting for ctl tty %#x into service fd\n", ctl_tty_id);
-
-	e = xmalloc(sizeof(*e));
-	if (!e)
-		return -1;
-
-	fdinfo_entry__init(e);
-
-	e->id		= ctl_tty_id;
-	e->fd		= reserve_service_fd(CTL_TTY_OFF);
-	e->type		= FD_TYPES__TTY;
-
-	if (collect_fd(pid, e, rst_info, true)) {
-		xfree(e);
-		return -1;
-	}
-
-	return 0;
-}
-
 int prepare_fd_pid(struct pstree_item *item)
 {
 	int ret = 0;
diff --git a/criu/include/files.h b/criu/include/files.h
index a6a3868eb..661a803e1 100644
--- a/criu/include/files.h
+++ b/criu/include/files.h
@@ -167,7 +167,6 @@ extern void show_saved_files(void);
 extern int add_fake_fds_masters(void);
 extern int prepare_fds(struct pstree_item *me);
 extern int prepare_fd_pid(struct pstree_item *me);
-extern int prepare_ctl_tty(int pid, struct rst_info *rst_info, u32 ctl_tty_id);
 extern int prepare_files(void);
 extern int restore_fs(struct pstree_item *);
 extern int prepare_fs_pid(struct pstree_item *);
diff --git a/criu/tty.c b/criu/tty.c
index e4cfd9d7b..f06c6cc60 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1229,6 +1229,33 @@ static struct pstree_item *find_first_sid(int sid)
 	return NULL;
 }
 
+static int prepare_ctl_tty(struct pstree_item *item, u32 ctl_tty_id)
+{
+	FdinfoEntry *e;
+
+	if (!ctl_tty_id)
+		return 0;
+
+	pr_info("Requesting for ctl tty %#x into service fd\n", ctl_tty_id);
+
+	e = xmalloc(sizeof(*e));
+	if (!e)
+		return -1;
+
+	fdinfo_entry__init(e);
+
+	e->id		= ctl_tty_id;
+	e->fd		= reserve_service_fd(CTL_TTY_OFF);
+	e->type		= FD_TYPES__TTY;
+
+	if (collect_fd(vpid(item), e, rsti(item), true)) {
+		xfree(e);
+		return -1;
+	}
+
+	return 0;
+}
+
 static int tty_find_restoring_task(struct tty_info *info)
 {
 	struct pstree_item *item;
@@ -1306,9 +1333,7 @@ static int tty_find_restoring_task(struct tty_info *info)
 		if (item && is_session_leader(item)) {
 			pr_info("Set a control terminal %#x to %d\n",
 				info->tfe->id, info->tie->sid);
-			return prepare_ctl_tty(vpid(item),
-					       rsti(item),
-					       info->tfe->id);
+			return prepare_ctl_tty(item, info->tfe->id);
 		}
 
 		goto notask;



More information about the CRIU mailing list