[CRIU] [PATCH] reg-files: skip size for O_APPEND|O_WRONLY files.

Ruslan Kuprieiev kupruser at gmail.com
Thu Mar 19 04:39:02 PDT 2015


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.

Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
---
 files-reg.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/files-reg.c b/files-reg.c
index a716a69..8115984 100644
--- a/files-reg.c
+++ b/files-reg.c
@@ -837,7 +837,9 @@ 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)) {
+	/* Skip size if file has O_APPEND and O_WRONLY flags(i.e. log file). */
+	if (S_ISREG(p->stat.st_mode) &&
+	    !((rfe.flags & O_APPEND) && (rfe.flags & O_WRONLY))) {
 		rfe.has_size = true;
 		rfe.size = p->stat.st_size;
 	}
-- 
2.1.0



More information about the CRIU mailing list