[v2,02/14] files: Move prepare_ctl_tty() to criu/tty.c

Submitted by Kirill Tkhai on Dec. 28, 2017, 1:09 p.m.

Details

Message ID 151446654453.28132.18230884017371006647.stgit@localhost.localdomain
State New
Series "Introduce custom per-task service fds placement"
Headers show

Commit Message

Kirill Tkhai Dec. 28, 2017, 1:09 p.m.
Move the function and reduce its arguments number.
This is cleanup needed to keep all tty code together.

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

Patch hide | download patch | download mbox

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;