summaryrefslogtreecommitdiffstats
path: root/tools/vgcfgbackup.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-11-18 14:04:08 +0000
committerAlasdair Kergon <agk@redhat.com>2002-11-18 14:04:08 +0000
commit5a52dca9c26ade9f233abcf5213300560d7a13a9 (patch)
tree9afbc621c07148c96a1ba1878a262dbd8aec613a /tools/vgcfgbackup.c
parentd1d9800ef1c7ec38a5f72b8e2586f927ab68188c (diff)
downloadlvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.tar.gz
lvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.tar.xz
lvm2-5a52dca9c26ade9f233abcf5213300560d7a13a9.zip
Some new features.
Diffstat (limited to 'tools/vgcfgbackup.c')
-rw-r--r--tools/vgcfgbackup.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index a7801589..46f90ec6 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -6,44 +6,29 @@
#include "tools.h"
-#include <stdio.h>
-
-static int _backup_to_file(const char *file, struct volume_group *vg)
-{
- int r;
- struct format_instance *tf;
- void *context;
-
- if (!(context = create_text_context(vg->cmd->fmtt, file,
- vg->cmd->cmd_line)) ||
- !(tf = vg->cmd->fmtt->ops->create_instance(vg->cmd->fmtt, NULL,
- context))) {
- log_error("Couldn't create backup object.");
- return 0;
- }
-
- if (!(r = tf->fmt->ops->vg_write(tf, vg, context)) ||
- !(r = tf->fmt->ops->vg_commit(tf, vg, context)))
- stack;
-
- tf->fmt->ops->destroy_instance(tf);
- return r;
-}
-
-static int vg_backup_single(struct cmd_context *cmd, const char *vg_name)
+static int vg_backup_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg, int consistent,
+ void *handle)
{
- struct volume_group *vg;
-
- log_verbose("Checking for volume group \"%s\"", vg_name);
- if (!(vg = vg_read(cmd, vg_name))) {
+ if (!vg) {
log_error("Volume group \"%s\" not found", vg_name);
return ECMD_FAILED;
}
+ if (!consistent)
+ log_error("Warning: Volume group \"%s\" inconsistent", vg_name);
+
if (arg_count(cmd, file_ARG)) {
- _backup_to_file(arg_value(cmd, file_ARG), vg);
+ backup_to_file(arg_value(cmd, file_ARG), vg->cmd->cmd_line, vg);
} else {
+ if (!consistent) {
+ log_error("No backup taken: specify filename with -f "
+ "to backup an inconsistent VG");
+ stack;
+ return ECMD_FAILED;
+ }
+
/* just use the normal backup code */
backup_enable(1); /* force a backup */
if (!backup(vg)) {
@@ -58,8 +43,6 @@ static int vg_backup_single(struct cmd_context *cmd, const char *vg_name)
int vgcfgbackup(struct cmd_context *cmd, int argc, char **argv)
{
- if (!driver_is_loaded())
- return ECMD_FAILED;
-
- return process_each_vg(cmd, argc, argv, LCK_VG_READ, &vg_backup_single);
+ return process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, NULL,
+ &vg_backup_single);
}