Commit 7ce496eb authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by Andrei Vagin

tty: Kill prepare_shared_tty

The routine in question just sets up the mutex to access
/dev/ptmx. This initialization can be done when we collect
a single tty.

✓ travis-ci: success for Sanitize initialization bits
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent a216fb1e
...@@ -1505,11 +1505,9 @@ static int restore_task_with_children(void *_arg) ...@@ -1505,11 +1505,9 @@ static int restore_task_with_children(void *_arg)
if (current->parent == NULL) { if (current->parent == NULL) {
int i; int i;
if (prepare_shared_tty())
goto err;
if (fdstore_init()) if (fdstore_init())
goto err; goto err;
if (join_namespaces()) { if (join_namespaces()) {
pr_perror("Join namespaces failed"); pr_perror("Join namespaces failed");
goto err; goto err;
......
...@@ -27,7 +27,6 @@ extern int dump_verify_tty_sids(void); ...@@ -27,7 +27,6 @@ extern int dump_verify_tty_sids(void);
extern struct collect_image_info tty_info_cinfo; extern struct collect_image_info tty_info_cinfo;
extern struct collect_image_info tty_cinfo; extern struct collect_image_info tty_cinfo;
extern struct collect_image_info tty_cdata; extern struct collect_image_info tty_cdata;
extern int prepare_shared_tty(void);
struct mount_info; struct mount_info;
extern int devpts_restore(struct mount_info *pm); extern int devpts_restore(struct mount_info *pm);
......
...@@ -326,8 +326,11 @@ static mutex_t *tty_mutex; ...@@ -326,8 +326,11 @@ static mutex_t *tty_mutex;
static bool tty_is_master(struct tty_info *info); static bool tty_is_master(struct tty_info *info);
int prepare_shared_tty(void) static int init_tty_mutex(void)
{ {
if (tty_mutex)
return 0;
tty_mutex = shmalloc(sizeof(*tty_mutex)); tty_mutex = shmalloc(sizeof(*tty_mutex));
if (!tty_mutex) { if (!tty_mutex) {
pr_err("Can't create ptmx index mutex\n"); pr_err("Can't create ptmx index mutex\n");
...@@ -1638,6 +1641,13 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i) ...@@ -1638,6 +1641,13 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
if (add_post_prepare_cb_once(prep_tty_restore, NULL)) if (add_post_prepare_cb_once(prep_tty_restore, NULL))
return -1; return -1;
/*
* Call it explicitly. Post-callbacks will be called after
* namespaces preparation, while the latter needs this mutex.
*/
if (init_tty_mutex())
return -1;
info->fdstore_id = -1; info->fdstore_id = -1;
list_add(&info->list, &all_ttys); list_add(&info->list, &all_ttys);
return file_desc_add(&info->d, info->tfe->id, &tty_desc_ops); return file_desc_add(&info->d, info->tfe->id, &tty_desc_ops);
......
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