]> sourceware.org Git - lvm2.git/commitdiff
archive: support interruption
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 26 Feb 2021 00:23:50 +0000 (01:23 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Tue, 2 Mar 2021 21:54:40 +0000 (22:54 +0100)
When lvm2 calls archive() or backup() it can be useful to allow handling
break signal so the command can be interrupted at some consistent point.

Signal is accepted during processing these calls - and can be evaluated
later during even lengthy processing loops.

So now user can interrupt lengthy lvremove().

lib/format_text/archiver.c

index cb8fc07de3fea6191b55d3a36aaf0a06cb0829af..932f97da312719b3d4d0448f993191fc3cccb301 100644 (file)
@@ -17,6 +17,7 @@
 #include "lib/format_text/archiver.h"
 #include "lib/format_text/format-text.h"
 #include "lib/misc/lvm-string.h"
+#include "lib/misc/lvm-signal.h"
 #include "lib/cache/lvmcache.h"
 #include "lib/mm/memlock.h"
 #include "lib/commands/toolcontext.h"
@@ -155,7 +156,13 @@ static int _archive(struct volume_group *vg, int compulsory)
 
 int archive(struct volume_group *vg)
 {
-       return _archive(vg, 1);
+       int r;
+
+       sigint_allow();
+       r  = _archive(vg, 1);
+       sigint_restore();
+
+       return r;
 }
 
 int archive_display(struct cmd_context *cmd, const char *vg_name)
@@ -218,6 +225,7 @@ static int _backup(struct volume_group *vg)
 {
        char name[PATH_MAX];
        char *desc;
+       int r;
 
        if (!(desc = _build_desc(vg->cmd->mem, vg->cmd->cmd_line, 0)))
                return_0;
@@ -229,7 +237,11 @@ static int _backup(struct volume_group *vg)
                return 0;
        }
 
-       return backup_to_file(name, desc, vg);
+       sigint_allow();
+       r = backup_to_file(name, desc, vg);
+       sigint_restore();
+
+       return r;
 }
 
 int backup_locally(struct volume_group *vg)
This page took 0.038636 seconds and 5 git commands to generate.