Commit cbf0ba9f authored by Pavel Emelyanov's avatar Pavel Emelyanov

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent c03a4c58
...@@ -1600,9 +1600,10 @@ err: ...@@ -1600,9 +1600,10 @@ err:
close_safe(&pidns_proc); close_safe(&pidns_proc);
if (ret) if (ret) {
kill_inventory();
pr_err("Dumping FAILED.\n"); pr_err("Dumping FAILED.\n");
else } else
pr_info("Dumping finished successfully\n"); pr_info("Dumping finished successfully\n");
return ret; return ret;
......
...@@ -86,6 +86,12 @@ int write_img_inventory(void) ...@@ -86,6 +86,12 @@ int write_img_inventory(void)
return 0; 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) static void show_inventory(int fd, struct cr_options *o)
{ {
pb_show_vertical(fd, PB_INVENTORY); pb_show_vertical(fd, PB_INVENTORY);
......
...@@ -179,6 +179,7 @@ void show_rlimit(int fd, struct cr_options *o); ...@@ -179,6 +179,7 @@ void show_rlimit(int fd, struct cr_options *o);
int check_img_inventory(void); int check_img_inventory(void);
int write_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_data(unsigned long addr, unsigned char *data, size_t size);
extern void print_image_data(int fd, unsigned int length, int show); extern void print_image_data(int fd, unsigned int length, int show);
......
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