Commit a72d8586 authored by Pavel Emelyanov's avatar Pavel Emelyanov

files: Collect fdinfo-s on per-pstree_item list

Later we'll be able to restore them without re-reading the fdinfo file again.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0e57ce29
......@@ -296,7 +296,7 @@ static int prepare_shared(void)
if (ret < 0)
break;
ret = prepare_fd_pid(pi->pid);
ret = prepare_fd_pid(pi->pid, pi->rst);
if (ret < 0)
break;
}
......
......@@ -327,7 +327,7 @@ int collect_reg_files(void)
return collect_remaps();
}
static int collect_fd(int pid, struct fdinfo_entry *e)
static int collect_fd(int pid, struct fdinfo_entry *e, struct list_head *fds)
{
int i;
struct fdinfo_list_entry *l, *le = &fdinfo_list[nr_fdinfo_list];
......@@ -357,14 +357,17 @@ static int collect_fd(int pid, struct fdinfo_entry *e)
break;
list_add_tail(&le->desc_list, &l->desc_list);
list_add_tail(&le->ps_list, fds);
return 0;
}
int prepare_fd_pid(int pid)
int prepare_fd_pid(int pid, struct rst_info *rst_info)
{
int fdinfo_fd, ret = 0;
u32 type = 0;
INIT_LIST_HEAD(&rst_info->fds);
fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
if (fdinfo_fd < 0) {
if (errno == ENOENT)
......@@ -380,7 +383,7 @@ int prepare_fd_pid(int pid)
if (ret <= 0)
break;
ret = collect_fd(pid, &e);
ret = collect_fd(pid, &e, &rst_info->fds);
if (ret < 0)
break;
}
......
......@@ -182,6 +182,7 @@ struct vma_area {
#define vma_area_len(vma_area) vma_entry_len(&((vma_area)->vma))
struct rst_info {
struct list_head fds;
};
struct pstree_item {
......
......@@ -29,6 +29,7 @@ enum fdinfo_states {
struct fdinfo_list_entry {
struct list_head desc_list;
struct list_head ps_list;
int pid;
futex_t real_pid;
struct fdinfo_entry fe;
......@@ -59,7 +60,8 @@ extern int restore_fown(int fd, fown_t *fown);
void show_saved_files(void);
extern int collect_reg_files(void);
extern int prepare_fds(int pid);
extern int prepare_fd_pid(int pid);
struct rst_info;
extern int prepare_fd_pid(int pid, struct rst_info *);
extern int prepare_shared_fdinfo(void);
extern int get_filemap_fd(int pid, struct vma_entry *vma_entry);
extern int prepare_fs(int pid);
......
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