2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-31 14:25:49 +00:00

rst: Rework remaps collection on generic collect routine

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov
2013-08-20 03:24:51 +04:00
parent 0543f49c3e
commit e03ab6b409

View File

@@ -165,29 +165,20 @@ static int open_remap_linked(struct reg_file_info *rfi,
return 0; return 0;
} }
static int collect_remaps(void) static int collect_one_remap(void *obj, ProtobufCMessage *msg)
{ {
int fd, ret = 0; int ret = -1;
RemapFilePathEntry *rfe;
fd = open_image(CR_FD_REMAP_FPATH, O_RSTR);
if (fd < 0)
return -1;
while (1) {
RemapFilePathEntry *rfe = NULL;
struct file_desc *fdesc; struct file_desc *fdesc;
struct reg_file_info *rfi; struct reg_file_info *rfi;
ret = pb_read_one_eof(fd, &rfe, PB_REMAP_FPATH); rfe = pb_msg(msg, RemapFilePathEntry);
if (ret <= 0)
break;
ret = -1;
fdesc = find_file_desc_raw(FD_TYPES__REG, rfe->orig_id); fdesc = find_file_desc_raw(FD_TYPES__REG, rfe->orig_id);
if (fdesc == NULL) { if (fdesc == NULL) {
pr_err("Remap for non existing file %#x\n", pr_err("Remap for non existing file %#x\n",
rfe->orig_id); rfe->orig_id);
goto tail; goto out;
} }
rfi = container_of(fdesc, struct reg_file_info, d); rfi = container_of(fdesc, struct reg_file_info, d);
@@ -197,13 +188,7 @@ static int collect_remaps(void)
ret = open_remap_ghost(rfi, rfe); ret = open_remap_ghost(rfi, rfe);
else else
ret = open_remap_linked(rfi, rfe); ret = open_remap_linked(rfi, rfe);
tail: out:
remap_file_path_entry__free_unpacked(rfe, NULL);
if (ret)
break;
}
close(fd);
return ret; return ret;
} }
@@ -593,7 +578,8 @@ int collect_reg_files(void)
ret = collect_image(CR_FD_REG_FILES, PB_REG_FILES, ret = collect_image(CR_FD_REG_FILES, PB_REG_FILES,
sizeof(struct reg_file_info), collect_one_regfile); sizeof(struct reg_file_info), collect_one_regfile);
if (!ret) if (!ret)
ret = collect_remaps(); ret = collect_image(CR_FD_REMAP_FPATH, PB_REMAP_FPATH,
0, collect_one_remap);
return ret; return ret;
} }