[CRIU] [PATCH] image: Don't unlink image we're dumping into

Pavel Emelyanov xemul at parallels.com
Thu Feb 13 04:55:40 PST 2014


We want to write into empty image files, so we
unlink them before dumping into. Let's O_TRUNC
it instead.

Signed-off-by: Pavel Emelyanov <xemul at parallels.com>
---
 image.c         | 8 --------
 include/image.h | 2 +-
 2 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/image.c b/image.c
index b4495e1..630ac9b 100644
--- a/image.c
+++ b/image.c
@@ -192,14 +192,6 @@ int open_image_at(int dfd, int type, unsigned long flags, ...)
 	vsnprintf(path, PATH_MAX, fdset_template[type].fmt, args);
 	va_end(args);
 
-	if (flags & O_EXCL) {
-		ret = unlinkat(dfd, path, 0);
-		if (ret && errno != ENOENT) {
-			pr_perror("Unable to unlink %s", path);
-			goto err;
-		}
-	}
-
 	ret = openat(dfd, path, flags, CR_FD_PERM);
 	if (ret < 0) {
 		pr_perror("Unable to open %s", path);
diff --git a/include/image.h b/include/image.h
index 32ee0af..af69de9 100644
--- a/include/image.h
+++ b/include/image.h
@@ -65,7 +65,7 @@
 extern bool fdinfo_per_id;
 extern bool ns_per_id;
 
-#define O_DUMP	(O_RDWR | O_CREAT | O_EXCL)
+#define O_DUMP	(O_RDWR | O_CREAT | O_TRUNC)
 #define O_SHOW	(O_RDONLY)
 #define O_RSTR	(O_RDONLY)
 
-- 
1.8.4.2


More information about the CRIU mailing list