summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJoe Thornber <thornber@redhat.com>2002-01-15 17:37:23 +0000
committerJoe Thornber <thornber@redhat.com>2002-01-15 17:37:23 +0000
commitf2f2634990cfcd5c90279183d9106d5c8defb077 (patch)
treefed594c7ab9d88eafbad3e13da57842e383c1acb /tools
parent6198a4102c5b171604b1ee82bd4a513be5506ab3 (diff)
downloadlvm2-f2f2634990cfcd5c90279183d9106d5c8defb077.tar.gz
lvm2-f2f2634990cfcd5c90279183d9106d5c8defb077.tar.xz
lvm2-f2f2634990cfcd5c90279183d9106d5c8defb077.zip
o vgcfgrestore works ! (with the couple of examples I tried).
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.in1
-rw-r--r--tools/archive.c6
-rw-r--r--tools/lvm.c49
-rw-r--r--tools/stub.h1
-rw-r--r--tools/tools.h1
-rw-r--r--tools/vgcfgbackup.c2
6 files changed, 51 insertions, 9 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 9da2f41e..a0a4ab86 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -39,6 +39,7 @@ SOURCES=\
pvscan.c \
toollib.c \
vgcfgbackup.c \
+ vgcfgrestore.c \
vgchange.c \
vgck.c \
vgcreate.c \
diff --git a/tools/archive.c b/tools/archive.c
index 5ca151ac..cbdd7760 100644
--- a/tools/archive.c
+++ b/tools/archive.c
@@ -151,7 +151,7 @@ static int __backup(struct volume_group *vg)
log_verbose("Creating volume group backup %s", name);
- if (!(tf = text_format_create(vg->cmd, name))) {
+ if (!(tf = text_format_create(vg->cmd, name, the_um))) {
stack;
return 0;
}
@@ -207,7 +207,7 @@ static struct volume_group *_read_vg(struct cmd_context *cmd,
struct volume_group *vg;
struct format_instance *tf;
- if (!(tf = text_format_create(cmd, file))) {
+ if (!(tf = text_format_create(cmd, file, the_um))) {
log_error("Couldn't create text format object.");
return 0;
}
@@ -226,7 +226,7 @@ int backup_restore_from_file(const char *vg_name, const char *file)
/*
* Read in the volume group.
*/
- if (!(vg = _read_vg(vg->cmd, vg_name, file))) {
+ if (!(vg = _read_vg(fid->cmd, vg_name, file))) {
stack;
return 0;
}
diff --git a/tools/lvm.c b/tools/lvm.c
index 2559ad8d..d2364cbe 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -7,6 +7,8 @@
#include "tools.h"
#include "archive.h"
#include "defaults.h"
+#include "lvm1_label.h"
+#include "label.h"
#include "stub.h"
@@ -43,6 +45,9 @@ static struct command *_commands;
/* Exported LVM1 disk format */
struct format_instance *fid;
+/* Map of uuid -> device */
+struct uuid_map *the_um;
+
/* Export command being processed */
struct command *the_command;
@@ -54,6 +59,10 @@ static int _dump_filter;
static int _interactive;
static FILE *_log;
+/* lvm1 label handler */
+static struct labeller *_lvm1_label;
+
+
/*
* This structure only contains those options that
* can have a default and per command setting.
@@ -508,7 +517,7 @@ static int merge_synonym(int oldarg, int newarg)
if (arg_count(oldarg) && arg_count(newarg)) {
log_error("%s and %s are synonyms. Please only supply one.",
- the_args[oldarg].long_arg,
+ the_args[oldarg].long_arg,
the_args[newarg].long_arg);
return 0;
}
@@ -535,7 +544,7 @@ static int process_common_commands(struct command *com)
kill(getpid(), SIGSTOP);
if (arg_count(debug_ARG))
- _current_settings.debug = _LOG_FATAL +
+ _current_settings.debug = _LOG_FATAL +
(arg_count(debug_ARG) - 1);
if (arg_count(verbose_ARG))
@@ -880,6 +889,31 @@ static struct dev_filter *filter_setup(struct config_file *cf)
return f4;
}
+static int _init_uuid_map(struct dev_filter *filter)
+{
+ label_init();
+
+ /* add in the lvm1 labeller */
+ if (!(_lvm1_label = lvm1_labeller_create())) {
+ log_err("Couldn't create lvm1 label handler.");
+ return 0;
+ }
+
+ if (!(label_register_handler("lvm1", _lvm1_label))) {
+ log_err("Couldn't register lvm1 label handler.");
+ return 0;
+ }
+
+ return (the_um = uuid_map_create(filter)) ? 1 : 0;
+}
+
+static void _exit_uuid_map(void)
+{
+ uuid_map_destroy(the_um);
+ label_exit();
+ _lvm1_label->ops->destroy(_lvm1_label);
+}
+
static int _get_env_vars(void)
{
const char *e;
@@ -944,8 +978,8 @@ static int init(void)
__init_log(cmd->cf);
}
- _default_settings.umask = find_config_int(cmd->cf->root,
- "global/umask", '/',
+ _default_settings.umask = find_config_int(cmd->cf->root,
+ "global/umask", '/',
DEFAULT_UMASK);
if ((old_umask = umask((mode_t)_default_settings.umask)) !=
@@ -975,6 +1009,12 @@ static int init(void)
return 0;
}
+ /* the uuid map uses the filter */
+ if (!_init_uuid_map(cmd->filter)) {
+ log_err("Failed to set up the uuid map.");
+ return 0;
+ }
+
if (!(cmd->mem = pool_create(4 * 1024))) {
log_error("Command pool creation failed");
return 0;
@@ -1014,6 +1054,7 @@ static void fin(void)
__fin_commands();
dump_memory();
fin_log();
+ _exit_uuid_map();
if (_log)
fclose(_log);
diff --git a/tools/stub.h b/tools/stub.h
index fa6e6e3a..5bf2e78d 100644
--- a/tools/stub.h
+++ b/tools/stub.h
@@ -13,5 +13,4 @@ int vgexport(int argc, char **argv) {return 1;}
int vgimport(int argc, char **argv) {return 1;}
int vgmknodes(int argc, char **argv) {return 1;}
int vgsplit(int argc, char **argv) {return 1;}
-int vgcfgrestore(int argc, char **argv) {return 1;}
diff --git a/tools/tools.h b/tools/tools.h
index 9594d392..73006c29 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -100,6 +100,7 @@ struct command {
};
extern struct command *the_command;
+extern struct uuid_map *the_um;
void usage(const char *name);
diff --git a/tools/vgcfgbackup.c b/tools/vgcfgbackup.c
index f6f450be..d2ad0401 100644
--- a/tools/vgcfgbackup.c
+++ b/tools/vgcfgbackup.c
@@ -13,7 +13,7 @@ static int _backup_to_file(const char *file, struct volume_group *vg)
int r;
struct format_instance *tf;
- if (!(tf = text_format_create(vg->cmd, file))) {
+ if (!(tf = text_format_create(vg->cmd, file, the_um))) {
log_error("Couldn't create backup object.");
return 0;
}