From cbf0ba9f4880ab66b511003141aff0d32684a2d8 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 27 Mar 2013 16:16:25 +0400 Subject: [PATCH] inventory: Kill inventory.img file in case of failed dump This will result in more sane error in case restore is launched on such semi-complete images. Signed-off-by: Pavel Emelyanov --- cr-dump.c | 5 +++-- image.c | 6 ++++++ include/crtools.h | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cr-dump.c b/cr-dump.c index e5d092f2a..d309e8e0b 100644 --- a/cr-dump.c +++ b/cr-dump.c @@ -1600,9 +1600,10 @@ err: close_safe(&pidns_proc); - if (ret) + if (ret) { + kill_inventory(); pr_err("Dumping FAILED.\n"); - else + } else pr_info("Dumping finished successfully\n"); return ret; diff --git a/image.c b/image.c index 91b53d113..f92d4487b 100644 --- a/image.c +++ b/image.c @@ -86,6 +86,12 @@ int write_img_inventory(void) return 0; } +void kill_inventory(void) +{ + unlinkat(get_service_fd(IMG_FD_OFF), + fdset_template[CR_FD_INVENTORY].fmt, 0); +} + static void show_inventory(int fd, struct cr_options *o) { pb_show_vertical(fd, PB_INVENTORY); diff --git a/include/crtools.h b/include/crtools.h index 1548d7b6c..22e1dd637 100644 --- a/include/crtools.h +++ b/include/crtools.h @@ -179,6 +179,7 @@ void show_rlimit(int fd, struct cr_options *o); int check_img_inventory(void); int write_img_inventory(void); +void kill_inventory(void); extern void print_data(unsigned long addr, unsigned char *data, size_t size); extern void print_image_data(int fd, unsigned int length, int show);