diff --git a/lib/format1/format1.c b/lib/format1/format1.c index c6480ac60..2c53df913 100644 --- a/lib/format1/format1.c +++ b/lib/format1/format1.c @@ -412,6 +412,7 @@ struct io_space *create_lvm1_format(const char *prefix, struct pool *mem, ios->pv_setup = _pv_setup; ios->pv_write = _pv_write; ios->vg_read = _vg_read; + ios->vg_setup = _vg_setup; ios->vg_write = _vg_write; ios->destroy = _destroy; diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c index 93c89fbf6..2c2eadf34 100644 --- a/lib/metadata/metadata.c +++ b/lib/metadata/metadata.c @@ -19,16 +19,19 @@ int _add_pv_to_vg(struct io_space *ios, struct volume_group *vg, struct physical_volume *pv = &pvl->pv; if (!pv) { - stack; + log_error("pv_list allocation for '%s' failed", name); return 0; } memset(pv, 0, sizeof(*pv)); - pv->dev = dev_cache_get(name, ios->filter); + if (!(pv->dev = dev_cache_get(name, ios->filter))) { + log_error("Physical volume '%s' not found.", name); + return 0; + } if (!(pv->vg_name = pool_strdup(ios->mem, vg->name))) { - stack; + log_error("vg->name allocation failed for '%s'", name); return 0; } @@ -52,7 +55,7 @@ int _add_pv_to_vg(struct io_space *ios, struct volume_group *vg, pv->pe_allocated = 0; if (!ios->pv_setup(ios, pv, vg)) { - log_err("Format specific setup of physical volume '%s' " + log_error("Format specific setup of physical volume '%s' " "failed.", name); return 0; } diff --git a/lib/mm/pool.c b/lib/mm/pool.c index 34d68cb8f..53cc8f7ee 100644 --- a/lib/mm/pool.c +++ b/lib/mm/pool.c @@ -93,7 +93,8 @@ void *pool_alloc_aligned(struct pool *p, size_t s, unsigned alignment) void pool_empty(struct pool *p) { - pool_free(p, p->chunk->begin); + if (p->chunk) + pool_free(p, p->chunk->begin); } void pool_free(struct pool *p, void *ptr) diff --git a/tools/lvm.c b/tools/lvm.c index 13169ce1e..30a1a83e9 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -122,7 +122,7 @@ int main(int argc, char **argv) if ((ret == ENO_SUCH_CMD) && (!alias)) ret = run_script(argc, argv); if (ret == ENO_SUCH_CMD) - log_error("No such command"); + log_error("No such command. Try 'help'."); out: fin(); @@ -810,14 +810,15 @@ static char *list_args(char *text, int state) static int shell(void) { - int argc; - char *input, *argv[MAX_ARGS]; + int argc, ret; + char *input = NULL, *args[MAX_ARGS], **argv; rl_readline_name = "lvm"; rl_attempted_completion_function = (CPPFunction *) lvm_completion; _interactive = 1; while (1) { + free(input); input = readline("lvm> "); /* EOF */ @@ -832,19 +833,30 @@ static int shell(void) add_history(input); + argv = args; + if (split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) { log_error("Too many arguments, sorry."); continue; } + if (!strcmp(argv[0], "lvm")) { + argv++; + argc--; + } + if (!argc) continue; - if (!strcmp(argv[0], "quit")) + if (!strcmp(argv[0], "quit")) { + log_error("Exiting."); break; + } - run_command(argc, argv); - free(input); + ret = run_command(argc, argv); + if (ret == ENO_SUCH_CMD) + log_error("No such command '%s'. Try 'help'.", + argv[0]); } free(input); diff --git a/tools/vgcreate.c b/tools/vgcreate.c index e64da5d40..a4093abd3 100644 --- a/tools/vgcreate.c +++ b/tools/vgcreate.c @@ -6,6 +6,7 @@ #include "tools.h" +/* FIXME Config file? */ #define DEFAULT_PV 128 #define DEFAULT_LV 128 #define DEFAULT_EXTENT 8192 @@ -13,6 +14,7 @@ int vgcreate(int argc, char **argv) { int max_lv, max_pv, extent_size; + char *vg_name; struct volume_group *vg; if (!argc) { @@ -26,12 +28,13 @@ int vgcreate(int argc, char **argv) return EINVALID_CMD_LINE; } + vg_name = argv[0]; max_lv = arg_int_value(maxlogicalvolumes_ARG, DEFAULT_LV); max_pv = arg_int_value(maxphysicalvolumes_ARG, DEFAULT_PV); extent_size = arg_int_value(physicalextentsize_ARG, DEFAULT_EXTENT); /* create the new vg */ - if (!vg_create(ios, argv[0], extent_size, max_pv, max_lv, + if (!vg_create(ios, vg_name, extent_size, max_pv, max_lv, argc - 1, argv + 1)) return ECMD_FAILED; @@ -39,8 +42,11 @@ int vgcreate(int argc, char **argv) if (ios->vg_write(ios, vg)) return ECMD_FAILED; + /* FIXME Create /dev/vg */ + /* FIXME Activate */ + log_print("Volume group %s successfully created and activated", - argv[0]); + vg_name); return 0; }