From: Jingxian He hejingxian@huawei.com
Some special char dev cannot work in child processes, we make dump fail when the special char dev fd is in child processes. In the char dev repair process, user may need recover fd. We should make thre repair process running after the char dev fd is reopened as dumped fd.
Conflict:NA Reference:https://gitee.com/src-openeuler/criu/pulls/21 Signed-off-by: Jingxian He hejingxian@huawei.com --- criu/files.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/criu/files.c b/criu/files.c index 10c9661..3bb68c7 100644 --- a/criu/files.c +++ b/criu/files.c @@ -1275,6 +1275,7 @@ static int open_fd(struct fdinfo_list_entry *fle) struct file_desc *d = fle->desc; struct fdinfo_list_entry *flem; int new_fd = -1, ret; + struct chrfile_info *ci;
pr_info("open file flags:%x\n", fle->fe->flags); flem = file_master(d); @@ -1335,6 +1336,17 @@ static int open_fd(struct fdinfo_list_entry *fle) if (ret != -1 && new_fd >= 0) { if (setup_and_serve_out(fle, new_fd) < 0) return -1; + if (d->ops->type == FD_TYPES__CHR) { + ci = container_of(d, struct chrfile_info, d); + if (ci->cfe->repair) { + ret = ioctl(fle->fe->fd, IOCTL_CMD_REPAIR , ci->cfe->index); + pr_info("repair ioctl return: %d, index: %d\n", ret, ci->cfe->index); + if (ret) { + close(fle->fe->fd); + return -1; + } + } + } } out: if (ret == 0) @@ -1859,19 +1871,9 @@ static int chrfile_open(struct file_desc *d, int *new_fd) return -1; }
- if (ci->cfe->repair) { - ret = ioctl(fd, IOCTL_CMD_REPAIR , ci->cfe->index); - pr_info("repair ioctl return: %d, index: %d\n", ret, ci->cfe->index); - if (ret) - goto err; - } - *new_fd = fd; ret = 0;
- return ret; -err: - close(fd); return ret; }