Commit 044011e5 authored by Ruslan Kuprieiev's avatar Ruslan Kuprieiev Committed by Pavel Emelyanov

reg-files: skip size for O_APPEND|O_WRONLY files, v2

This is common for log files, when a number of processes
are writing something into one file. Currently, if someone
wrote something to log since dump happened, on restore criu
will complain about "File has bad size" and refuse to restore.

If file is opened with O_APPEND|O_WRONLY flags it is going to
jump to the EOF anyway.

v2, use O_ACCMODE and separate helper
Signed-off-by: 's avatarRuslan Kuprieiev <rkuprieiev@cloudlinux.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c625b4fb
......@@ -791,6 +791,16 @@ static int check_path_remap(struct fd_link *link, const struct fd_parms *parms,
return 0;
}
static bool should_check_size(int flags)
{
/* Skip size if file has O_APPEND and O_WRONLY flags (e.g. log file). */
if (((flags & O_ACCMODE) == O_WRONLY) &&
(flags & O_APPEND))
return false;
return true;
}
int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
{
struct fd_link _link, *link;
......@@ -837,7 +847,7 @@ int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
rfe.fown = (FownEntry *)&p->fown;
rfe.name = &link->name[1];
if (S_ISREG(p->stat.st_mode)) {
if (S_ISREG(p->stat.st_mode) && should_check_size(rfe.flags)) {
rfe.has_size = true;
rfe.size = p->stat.st_size;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment