mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +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:
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)
|
static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
||||||
{
|
{
|
||||||
struct fd_parms params = FD_PARMS_INIT;
|
struct fd_parms params = FD_PARMS_INIT;
|
||||||
int fd, ret;
|
int fd, ret = 0;
|
||||||
|
|
||||||
fd = open_proc(pid, "exe");
|
fd = open_proc(pid, "exe");
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
@@ -255,11 +255,10 @@ static int dump_task_exe_link(pid_t pid, MmEntry *mm)
|
|||||||
return -1;
|
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);
|
close(fd);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,11 +280,11 @@ static int dump_task_fs(pid_t pid, struct parasite_dump_misc *misc, struct cr_fd
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fe.cwd_id = fd_id_generate_special(&p.stat);
|
if (fd_id_generate_special(&p.stat, &fe.cwd_id)) {
|
||||||
|
ret = dump_one_reg_file(fd, fe.cwd_id, &p);
|
||||||
ret = dump_one_reg_file(fd, fe.cwd_id, &p);
|
if (ret < 0)
|
||||||
if (ret < 0)
|
return ret;
|
||||||
return ret;
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
@@ -299,11 +298,11 @@ static int dump_task_fs(pid_t pid, struct parasite_dump_misc *misc, struct cr_fd
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fe.root_id = fd_id_generate_special(&p.stat);
|
if (fd_id_generate_special(&p.stat, &fe.root_id)) {
|
||||||
|
ret = dump_one_reg_file(fd, fe.root_id, &p);
|
||||||
ret = dump_one_reg_file(fd, fe.root_id, &p);
|
if (ret < 0)
|
||||||
if (ret < 0)
|
return ret;
|
||||||
return ret;
|
}
|
||||||
|
|
||||||
close(fd);
|
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;
|
struct fd_parms p = FD_PARMS_INIT;
|
||||||
VmaEntry *vma = vma_area->e;
|
VmaEntry *vma = vma_area->e;
|
||||||
|
int ret = 0;
|
||||||
|
u32 id;
|
||||||
|
|
||||||
BUG_ON(!vma_area->st);
|
BUG_ON(!vma_area->st);
|
||||||
p.stat = *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;
|
p.flags = O_RDWR;
|
||||||
else
|
else
|
||||||
p.flags = O_RDONLY;
|
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)
|
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);
|
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)
|
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--;
|
tmp--;
|
||||||
}
|
}
|
||||||
|
|
||||||
rfe.id = *idp = fd_id_generate_special(NULL);
|
fd_id_generate_special(NULL, idp);
|
||||||
|
rfe.id = *idp;
|
||||||
rfe.flags = 0;
|
rfe.flags = 0;
|
||||||
rfe.pos = 0;
|
rfe.pos = 0;
|
||||||
rfe.fown = &fwn;
|
rfe.fown = &fwn;
|
||||||
|
@@ -14,7 +14,7 @@ struct fdinfo_entry;
|
|||||||
struct stat;
|
struct stat;
|
||||||
|
|
||||||
extern int fd_id_generate(pid_t pid, FdinfoEntry *fe, struct stat *st);
|
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);
|
extern void fd_id_show_tree(void);
|
||||||
|
|
||||||
#endif /* __CR_FILE_IDS_H__ */
|
#endif /* __CR_FILE_IDS_H__ */
|
||||||
|
@@ -581,7 +581,7 @@ int fix_external_unix_sockets(void)
|
|||||||
|
|
||||||
BUG_ON(sk->sd.already_dumped);
|
BUG_ON(sk->sd.already_dumped);
|
||||||
|
|
||||||
e.id = fd_id_generate_special(NULL);
|
fd_id_generate_special(NULL, &e.id);
|
||||||
e.ino = sk->sd.ino;
|
e.ino = sk->sd.ino;
|
||||||
e.type = SOCK_DGRAM;
|
e.type = SOCK_DGRAM;
|
||||||
e.state = TCP_LISTEN;
|
e.state = TCP_LISTEN;
|
||||||
|
Reference in New Issue
Block a user