mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
files: Make fd_id_generate_special return ID into pointer
Acked-by: Andrew Vagin <avagin@parallels.com> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
9857acc0a2
commit
8a827ba403
36
cr-dump.c
36
cr-dump.c
@ -244,7 +244,7 @@ static int collect_fds(pid_t pid, struct parasite_drain_fd *dfds)
|
||||
static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
||||
{
|
||||
struct fd_parms params = FD_PARMS_INIT;
|
||||
int fd, ret;
|
||||
int fd, ret = 0;
|
||||
|
||||
fd = open_proc(pid, "exe");
|
||||
if (fd < 0)
|
||||
@ -255,11 +255,10 @@ static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
||||
return -1;
|
||||
}
|
||||
|
||||
mm->exe_file_id = fd_id_generate_special(¶ms.stat);
|
||||
if (fd_id_generate_special(¶ms.stat, &mm->exe_file_id))
|
||||
ret = dump_one_reg_file(fd, mm->exe_file_id, ¶ms);
|
||||
|
||||
ret = dump_one_reg_file(fd, mm->exe_file_id, ¶ms);
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -281,11 +280,11 @@ static int dump_task_fs(pid_t pid, struct parasite_dump_misc *misc, struct cr_fd
|
||||
return -1;
|
||||
}
|
||||
|
||||
fe.cwd_id = fd_id_generate_special(&p.stat);
|
||||
|
||||
ret = dump_one_reg_file(fd, fe.cwd_id, &p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (fd_id_generate_special(&p.stat, &fe.cwd_id)) {
|
||||
ret = dump_one_reg_file(fd, fe.cwd_id, &p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
@ -299,11 +298,11 @@ static int dump_task_fs(pid_t pid, struct parasite_dump_misc *misc, struct cr_fd
|
||||
return -1;
|
||||
}
|
||||
|
||||
fe.root_id = fd_id_generate_special(&p.stat);
|
||||
|
||||
ret = dump_one_reg_file(fd, fe.root_id, &p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (fd_id_generate_special(&p.stat, &fe.root_id)) {
|
||||
ret = dump_one_reg_file(fd, fe.root_id, &p);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
|
||||
@ -348,6 +347,8 @@ static int dump_filemap(pid_t pid, struct vma_area *vma_area,
|
||||
{
|
||||
struct fd_parms p = FD_PARMS_INIT;
|
||||
VmaEntry *vma = vma_area->e;
|
||||
int ret = 0;
|
||||
u32 id;
|
||||
|
||||
BUG_ON(!vma_area->st);
|
||||
p.stat = *vma_area->st;
|
||||
@ -356,9 +357,12 @@ static int dump_filemap(pid_t pid, struct vma_area *vma_area,
|
||||
p.flags = O_RDWR;
|
||||
else
|
||||
p.flags = O_RDONLY;
|
||||
vma->shmid = fd_id_generate_special(&p.stat);
|
||||
|
||||
return dump_one_reg_file(vma_area->vm_file_fd, vma->shmid, &p);
|
||||
if (fd_id_generate_special(&p.stat, &id))
|
||||
ret = dump_one_reg_file(vma_area->vm_file_fd, id, &p);
|
||||
|
||||
vma->shmid = id;
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int check_sysvipc_map_dump(pid_t pid, VmaEntry *vma)
|
||||
|
@ -26,9 +26,10 @@ void fd_id_show_tree(void)
|
||||
kid_show_tree(&fd_tree);
|
||||
}
|
||||
|
||||
u32 fd_id_generate_special(struct stat *st)
|
||||
int fd_id_generate_special(struct stat *st, u32 *id)
|
||||
{
|
||||
return fd_tree.subid++;
|
||||
*id = fd_tree.subid++;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fd_id_generate(pid_t pid, FdinfoEntry *fe, struct stat *st)
|
||||
|
@ -382,7 +382,8 @@ static int create_link_remap(char *path, int len, int lfd, u32 *idp)
|
||||
tmp--;
|
||||
}
|
||||
|
||||
rfe.id = *idp = fd_id_generate_special(NULL);
|
||||
fd_id_generate_special(NULL, idp);
|
||||
rfe.id = *idp;
|
||||
rfe.flags = 0;
|
||||
rfe.pos = 0;
|
||||
rfe.fown = &fwn;
|
||||
|
@ -14,7 +14,7 @@ struct fdinfo_entry;
|
||||
struct stat;
|
||||
|
||||
extern int fd_id_generate(pid_t pid, FdinfoEntry *fe, struct stat *st);
|
||||
extern u32 fd_id_generate_special(struct stat *);
|
||||
extern int fd_id_generate_special(struct stat *, u32 *id);
|
||||
extern void fd_id_show_tree(void);
|
||||
|
||||
#endif /* __CR_FILE_IDS_H__ */
|
||||
|
Loading…
x
Reference in New Issue
Block a user