From: Jingxian He hejingxian@huawei.com
When the file mode and size larger than dump data, make the restoring process run success.
Conflict:NA Reference:https://gitee.com/src-openeuler/criu/pulls/21 Signed-off-by: Jingxian He hejingxian@huawei.com --- criu/config.c | 1 + criu/crtools.c | 1 + criu/files-reg.c | 8 +++++--- criu/include/cr_options.h | 1 + 4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/criu/config.c b/criu/config.c index 9c4d8ce..006753a 100644 --- a/criu/config.c +++ b/criu/config.c @@ -548,6 +548,7 @@ int parse_options(int argc, char **argv, bool *usage_error, BOOL_OPT("with-fd-cred", &opts.with_fd_cred), BOOL_OPT("dump-char-dev", &opts.dump_char_dev), BOOL_OPT("mask-exit-notify", &opts.mask_exit_notify), + BOOL_OPT("weak-file-check", &opts.weak_file_check), { }, };
diff --git a/criu/crtools.c b/criu/crtools.c index 8694ed0..239464a 100644 --- a/criu/crtools.c +++ b/criu/crtools.c @@ -452,6 +452,7 @@ usage: " as checkout assisted by kernel.\n" " --dump-char-dev Dump char dev files as normal file with repair cmd\n" " --mask-exit-notify Mask task exit notify during dump and restore\n" +" --weak-file-check Allow file size and mod larger than dumping value\n" "\n" "Check options:\n" " Without options, "criu check" checks availability of absolutely required\n" diff --git a/criu/files-reg.c b/criu/files-reg.c index ba78c67..e6ae042 100644 --- a/criu/files-reg.c +++ b/criu/files-reg.c @@ -2061,7 +2061,8 @@ static bool validate_file(const int fd, const struct stat *fd_status, { int result = 1;
- if (rfi->rfe->has_size && (fd_status->st_size != rfi->rfe->size)) { + if (rfi->rfe->has_size && ((!opts.weak_file_check && fd_status->st_size != rfi->rfe->size) || + (fd_status->st_size < rfi->rfe->size))) { pr_err("File %s has bad size %"PRIu64" (expect %"PRIu64")\n", rfi->path, fd_status->st_size, rfi->rfe->size); return false; @@ -2176,8 +2177,9 @@ ext: if (!validate_file(tmp, &st, rfi)) return -1;
- if (rfi->rfe->has_mode && (st.st_mode != rfi->rfe->mode)) { - pr_err("File %s has bad mode 0%o (expect 0%o)\n", + if (rfi->rfe->has_mode && ((!opts.weak_file_check && st.st_mode != rfi->rfe->mode) || + (st.st_mode < rfi->rfe->mode))) { + pr_err("%d File %s has bad mode 0%o (expect 0%o)\n", opts.weak_file_check, rfi->path, (int)st.st_mode, rfi->rfe->mode); return -1; diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h index 5b3ff86..fc7818c 100644 --- a/criu/include/cr_options.h +++ b/criu/include/cr_options.h @@ -182,6 +182,7 @@ struct cr_options { int with_fd_cred; int dump_char_dev; int mask_exit_notify; + int weak_file_check; };
extern struct cr_options opts;