Commit 8a946000 authored by Kirill Tkhai's avatar Kirill Tkhai Committed by Andrei Vagin

files: Move prepare_ctl_tty() to criu/tty.c

Move the function and reduce its arguments number.
This is cleanup needed to keep all tty code together.
Signed-off-by: 's avatarKirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e4c25f2b
......@@ -835,33 +835,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;
......
......@@ -158,7 +158,6 @@ extern void show_saved_files(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 *);
......
......@@ -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 && vpid(item) == item->sid) {
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment