sfds: Kill SELF_STDIN_OFF via fdstore

Place stdin in fdstore. Kill SELF_STDIN_OFF.

v4: New

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
This commit is contained in:
Kirill Tkhai 2018-01-10 17:00:39 +03:00 committed by Andrei Vagin
parent 847e585f68
commit d5bece6678
4 changed files with 6 additions and 12 deletions

View file

@ -1323,7 +1323,6 @@ int prepare_fds(struct pstree_item *me)
if (rsti(me)->fdt)
futex_inc_and_wake(&rsti(me)->fdt->fdt_lock);
out:
tty_fini_fds();
return ret;
}

View file

@ -10,7 +10,6 @@ enum sfd_type {
IMG_FD_OFF,
PROC_FD_OFF, /* fd with /proc for all proc_ calls */
PROC_PID_FD_OFF,
SELF_STDIN_OFF,
CR_PROC_FD_OFF, /* some other's proc fd.
* For dump -- target ns' proc
* For restore -- CRIU ns' proc

View file

@ -32,7 +32,6 @@ struct mount_info;
extern int devpts_restore(struct mount_info *pm);
extern int tty_prep_fds(void);
extern void tty_fini_fds(void);
extern int devpts_check_bindmount(struct mount_info *m);

View file

@ -125,6 +125,7 @@ struct tty_dump_info {
static bool stdin_isatty = false;
static LIST_HEAD(collected_ttys);
static LIST_HEAD(all_ttys);
static int self_stdin_fdid = -1;
/*
* Usually an application has not that many ttys opened.
@ -1000,9 +1001,9 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave)
return -1;
}
fd = dup(get_service_fd(SELF_STDIN_OFF));
fd = fdstore_get(self_stdin_fdid);
if (fd < 0) {
pr_perror("Can't dup SELF_STDIN_OFF");
pr_err("Can't get self_stdin_fdid\n");
return -1;
}
@ -2330,19 +2331,15 @@ int tty_prep_fds(void)
else
stdin_isatty = true;
if (install_service_fd(SELF_STDIN_OFF, STDIN_FILENO) < 0) {
pr_err("Can't dup stdin to SELF_STDIN_OFF\n");
self_stdin_fdid = fdstore_add(STDIN_FILENO);
if (self_stdin_fdid < 0) {
pr_err("Can't place stdin fd to fdstore\n");
return -1;
}
return 0;
}
void tty_fini_fds(void)
{
close_service_fd(SELF_STDIN_OFF);
}
static int open_pty(void *arg, int flags)
{
int dfd = (unsigned long) arg;