Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@parallels.com>2015-05-29 14:45:00 +0300
committerPavel Emelyanov <xemul@parallels.com>2015-05-30 00:31:52 +0300
commitc9c41ddfa90dffffbba8b043b6f4ce7971b87fc3 (patch)
treeca0c1466c39390d1c18cb7c9d78d829cbce22282
parent5e55b71b93e452373fb9945ead5154a35c8d184c (diff)
img: Remove empty lazy images after dump
If dump doesn't generate data into some image file the respective file is not created at all as it used to be in 1.5. This brings potential problem -- if the file with the image name exists during dump (e.g. a dump file left from previous, maybe unsuccessful, dump) then restore would pick this file and read bad/wrong/fake data from it. To return the proper behavior back the file with the name of empty image should be removed. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
-rw-r--r--image.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/image.c b/image.c
index bb0edaa04..dc9d6a189 100644
--- a/image.c
+++ b/image.c
@@ -369,9 +369,15 @@ int open_image_lazy(struct cr_img *img)
void close_image(struct cr_img *img)
{
- if (lazy_image(img))
+ if (lazy_image(img)) {
+ /*
+ * Remove the image file if it's there so that
+ * subsequent restore doesn't read wrong or fake
+ * data from it.
+ */
+ unlinkat(get_service_fd(IMG_FD_OFF), img->path, 0);
xfree(img->path);
- else if (!empty_image(img))
+ } else if (!empty_image(img))
bclose(&img->_x);
xfree(img);