mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-28 04:48:16 +00:00
files: Add new master to file_desc if owners of existing fles have no permissions
Iterate over fake_master_head and add a fake fake fle of root_item, which becomes new master and have permissions to restore file_desc. Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
f03848309c
commit
373f9327f9
@ -375,6 +375,11 @@ static int root_prepare_shared(void)
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
/* This func may add new files, so it must be called before post prepare */
|
||||
ret = add_fake_fds_masters();
|
||||
if (ret)
|
||||
goto err;
|
||||
|
||||
ret = run_post_prepare();
|
||||
if (ret)
|
||||
goto err;
|
||||
|
31
criu/files.c
31
criu/files.c
@ -1893,3 +1893,34 @@ int prepare_files(void)
|
||||
init_fdesc_hash();
|
||||
return collect_image(&files_cinfo);
|
||||
}
|
||||
|
||||
int add_fake_fds_masters(void)
|
||||
{
|
||||
struct fdinfo_list_entry *fle;
|
||||
struct file_desc *fdesc, *tmp;
|
||||
FdinfoEntry *fe;
|
||||
int fd;
|
||||
|
||||
list_for_each_entry_safe(fdesc, tmp, &fake_master_head, fake_master_list) {
|
||||
fle = list_first_entry(&fdesc->fd_info_head,
|
||||
struct fdinfo_list_entry, desc_list);
|
||||
/*
|
||||
* All masters are created in root_item for now.
|
||||
* Distribute them over pstree if someone reports,
|
||||
* their number is too big, or you want support
|
||||
* file->user_ns.
|
||||
*/
|
||||
fd = find_unused_fd(root_item, -1);
|
||||
fe = dup_fdinfo(fle->fe, fd, fle->fe->flags);
|
||||
if (!fe)
|
||||
goto err;
|
||||
|
||||
if (collect_fd(vpid(root_item), fe, rsti(root_item), true))
|
||||
goto err;
|
||||
}
|
||||
BUG_ON(!list_empty(&fake_master_head));
|
||||
return 0;
|
||||
err:
|
||||
pr_err("Can't prepare fds masters\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -164,6 +164,7 @@ extern int rst_file_params(int fd, FownEntry *fown, int flags);
|
||||
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user