summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/format1/format1.c10
-rw-r--r--lib/format1/format1.h2
-rw-r--r--lib/metadata/metadata.c2
-rw-r--r--tools/lvactivate.c95
-rw-r--r--tools/lvchange.c12
-rw-r--r--tools/lvcreate.c14
-rw-r--r--tools/lvdisplay.c4
-rw-r--r--tools/lvextend.c10
-rw-r--r--tools/lvm.c38
-rw-r--r--tools/lvreduce.c6
-rw-r--r--tools/lvremove.c6
-rw-r--r--tools/lvscan.c4
-rw-r--r--tools/pvchange.c10
-rw-r--r--tools/pvcreate.c8
-rw-r--r--tools/pvdisplay.c4
-rw-r--r--tools/pvscan.c4
-rw-r--r--tools/toollib.c22
-rw-r--r--tools/toollib.h4
-rw-r--r--tools/tools.h3
-rw-r--r--tools/vgchange.c8
-rw-r--r--tools/vgck.c2
-rw-r--r--tools/vgcreate.c8
-rw-r--r--tools/vgextend.c6
-rw-r--r--tools/vgreduce.c6
-rw-r--r--tools/vgremove.c4
-rw-r--r--tools/vgrename.c10
-rw-r--r--tools/vgscan.c6
27 files changed, 110 insertions, 198 deletions
diff --git a/lib/format1/format1.c b/lib/format1/format1.c
index eaa8407e..2eef659f 100644
--- a/lib/format1/format1.c
+++ b/lib/format1/format1.c
@@ -92,7 +92,7 @@ static struct volume_group *_vg_read(struct format_instance *fi,
{
struct pool *mem = pool_create(1024 * 10);
struct list pvs;
- struct volume_group *vg;
+ struct volume_group *vg = NULL;
list_init(&pvs);
if (!mem) {
@@ -105,13 +105,17 @@ static struct volume_group *_vg_read(struct format_instance *fi,
if (!read_pvs_in_vg(vg_name, fi->cmd->filter, mem, &pvs)) {
stack;
- return NULL;
+ goto bad;
}
- if (!(vg = _build_vg(fi->cmd->mem, &pvs)))
+ if (!(vg = _build_vg(fi->cmd->mem, &pvs))) {
stack;
+ goto bad;
+ }
+
vg->cmd = fi->cmd;
+ bad:
pool_destroy(mem);
return vg;
}
diff --git a/lib/format1/format1.h b/lib/format1/format1.h
index 625612b9..a79a3fe8 100644
--- a/lib/format1/format1.h
+++ b/lib/format1/format1.h
@@ -9,6 +9,6 @@
#include "metadata.h"
-struct filter_instance *create_lvm1_format(struct cmd_context *cmd);
+struct format_instance *create_lvm1_format(struct cmd_context *cmd);
#endif
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index ee502358..4ad5ab2e 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -116,7 +116,7 @@ int vg_extend(struct format_instance *fi,
return 1;
}
-const char *strip_prefix(const char *vg_name, const char *dev_dir)
+const char *strip_dir(const char *vg_name, const char *dev_dir)
{
int len = strlen(dev_dir);
if (!strncmp(vg_name, dev_dir, len))
diff --git a/tools/lvactivate.c b/tools/lvactivate.c
deleted file mode 100644
index 2b74d4f3..00000000
--- a/tools/lvactivate.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2001 Sistina Software
- *
- * LVM is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * LVM is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with LVM; see the file COPYING. If not, write to
- * the Free Software Foundation, 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- *
- */
-
-#include "tools.h"
-
-int lvactivate(int argc, char **argv)
-{
- int p;
-
- struct device *pv_dev;
-
- char *lv_name;
- char *pv_name;
-
- struct physical_volume *pv = NULL;
- struct logical_volume *lv = NULL;
-
- if (argc < 2) {
- log_error("please enter logical volume & physical volume(s)");
- return EINVALID_CMD_LINE;
- }
-
- lv_name = argv[0];
- argc--;
- argv++;
-
- while (argc--) {
- pv_name = argv[argc];
- if (!(pv_dev = dev_cache_get(pv_name))) {
- log_error("device \"%s\" not found", pv_name);
- return -1;
- }
-
- if (!(pv = pv_read(ios, pv_dev))) {
- return -1;
- }
-
- if (pv->status & ALLOCATED_PV) {
- if (!(pv->pe = pv_read_pe(pv_name, pv)))
- goto pvdisplay_device_out;
- if (!(lvs = pv_read_lvs(pv))) {
- log_error("Failed to read LVs on %s",
- pv->pv_name);
- goto pvdisplay_device_out;
- }
- } else
- log_print("no logical volume on physical volume %s",
- pv_name);
-
- for (p = 0; p < pv->pe_total; p++) {
- int l = pv->pe[p].lv_num;
- int le = pv->pe[p].le_num;
- long pe_size_guess = lvs[l - 1].lv_size /
- lvs[l - 1].lv_allocated_le;
-
- if (l && !strcmp(lv, lvs[l - 1].lv_name))
- printf("%012ld %ld linear %s %012ld\n",
- pe_size_guess * le,
- pe_size_guess,
- pv_name, get_pe_offset(p, pv));
- }
-
- if (pv)
- dbg_free(pv->pe);
- dbg_free(pv);
- dbg_free(lvs);
- }
-
- return 0;
-
- pvdisplay_device_out:
- if (pv)
- dbg_free(pv->pe);
- dbg_free(pv);
- dbg_free(lvs);
-
- return -1;
-}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 7a87b899..3838e397 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -64,12 +64,12 @@ static int lvchange_single(char *lv_name)
/* FIXME Common code here - Add to a foreach? */
/* does VG exist? */
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
return ECMD_FAILED;
}
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -153,7 +153,7 @@ static int lvchange_permission(struct logical_volume *lv)
}
log_very_verbose("Updating logical volume %s on disk(s)", lv->name);
- if (!ios->vg_write(ios, lv->vg))
+ if (!fid->ops->vg_write(fid, lv->vg))
return 0;
log_very_verbose("Updating permissions for %s in kernel", lv->name);
@@ -189,7 +189,7 @@ static int lvchange_availability(struct logical_volume *lv)
}
log_very_verbose("Updating logical volume %s on disk(s)", lv->name);
- if (!ios->vg_write(ios, lv->vg))
+ if (!fid->ops->vg_write(fid, lv->vg))
return 0;
log_very_verbose("Updating %s in kernel", lv->name);
@@ -243,7 +243,7 @@ static int lvchange_contiguous(struct logical_volume *lv)
log_verbose("Updating logical volume %s on disk(s)", lv->name);
- if (!ios->vg_write(ios, lv->vg))
+ if (!fid->ops->vg_write(fid, lv->vg))
return 0;
return 1;
@@ -273,7 +273,7 @@ static int lvchange_readahead(struct logical_volume *lv)
log_verbose("Updating logical volume %s on disk(s)", lv->name);
- if (!ios->vg_write(ios, lv->vg))
+ if (!fid->ops->vg_write(fid, lv->vg))
return 0;
return 1;
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index d93faaaf..641144d7 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -87,14 +87,14 @@ int lvcreate(int argc, char **argv)
/* If VG not on command line, try -n arg and then environment */
if (!argc) {
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
log_error("Please provide a volume group name");
return EINVALID_CMD_LINE;
}
} else {
/* Ensure lv_name doesn't contain a different VG! */
if (strchr(lv_name, '/')) {
- if (!(vg_name = extract_vgname(ios, lv_name)))
+ if (!(vg_name = extract_vgname(fid, lv_name)))
return EINVALID_CMD_LINE;
if (strcmp(vg_name, argv[0])) {
log_error("Inconsistent volume group names "
@@ -112,7 +112,7 @@ int lvcreate(int argc, char **argv)
/* does VG exist? */
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -131,7 +131,7 @@ int lvcreate(int argc, char **argv)
if (argc) {
/* Build up list of PVs */
- if (!(pvh = pool_alloc(ios->mem, sizeof (struct list)))) {
+ if (!(pvh = pool_alloc(fid->cmd->mem, sizeof (struct list)))) {
log_error("pvh list allocation failed");
return ECMD_FAILED;
}
@@ -225,7 +225,7 @@ int lvcreate(int argc, char **argv)
log_verbose("Creating logical volume %s", lv_name);
- if (!(lv = lv_create(ios, lv_name, status, stripes, stripesize,
+ if (!(lv = lv_create(lv_name, status, stripes, stripesize,
extents, vg, pvh)))
return ECMD_FAILED;
@@ -235,7 +235,7 @@ int lvcreate(int argc, char **argv)
}
/* store vg on disk(s) */
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
if (!lv_activate(lv))
@@ -250,7 +250,7 @@ int lvcreate(int argc, char **argv)
log_verbose("Zeroing start of logical volume %s", lv_name);
- /* FIXME get dev = dev_cache_get(lv_name, ios->filter); */
+ /* FIXME get dev = dev_cache_get(lv_name, fid->cmd->filter); */
/* FIXME Add fsync! */
if (!(dev_write(dev, 0, sizeof (buf), &buf) == sizeof (buf))) {
log_error("Initialisation of %s failed", dev_name(dev));
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index 8130a33d..43b38974 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -56,12 +56,12 @@ int lvdisplay_single(char *lv_name)
struct logical_volume *lv;
/* does VG exist? */
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
return ECMD_FAILED;
}
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
diff --git a/tools/lvextend.c b/tools/lvextend.c
index 090d55ff..84aa372e 100644
--- a/tools/lvextend.c
+++ b/tools/lvextend.c
@@ -62,7 +62,7 @@ int lvextend(int argc, char **argv)
argv++;
argc--;
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
log_error("Please provide a volume group name");
return EINVALID_CMD_LINE;
}
@@ -72,7 +72,7 @@ int lvextend(int argc, char **argv)
/* does VG exist? */
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -100,7 +100,7 @@ int lvextend(int argc, char **argv)
if (argc) {
/* Build up list of PVs */
- if (!(pvh = pool_alloc(ios->mem, sizeof (struct list)))) {
+ if (!(pvh = pool_alloc(fid->cmd->mem, sizeof (struct list)))) {
log_error("pvh list allocation failed");
return ECMD_FAILED;
}
@@ -162,13 +162,13 @@ int lvextend(int argc, char **argv)
display_size(extents * vg->extent_size / 2, SIZE_SHORT)));
dbg_free(dummy);
- lv_extend(ios, lv, extents - lv->le_count, pvh);
+ lv_extend(lv, extents - lv->le_count, pvh);
/* where parm is always *increase* not actual */
/********* FIXME Suspend lv ***********/
/* store vg on disk(s) */
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
/* FIXME Ensure it always displays errors? */
diff --git a/tools/lvm.c b/tools/lvm.c
index 90da2f4f..461067e0 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -59,10 +59,11 @@ static int _array_size;
static int _num_commands;
static struct command *_commands;
-/* Exported */
-struct io_space *ios;
+/* Exported LVM1 disk format */
+struct format_instance *fid;
+
+struct cmd_context *cmd;
-static struct dev_filter *_filter;
/* Whether or not to dump persistent filter state */
static int dump_filter;
static struct config_file *_cf;
@@ -561,7 +562,7 @@ static int run_command(int argc, char **argv)
/*
* free off any memory the command used.
*/
- pool_empty(ios->mem);
+ pool_empty(cmd->mem);
if (ret == EINVALID_CMD_LINE && !_interactive)
usage(com->name);
@@ -602,11 +603,6 @@ struct config_file *active_config_file(void)
return _cf;
}
-struct dev_filter *active_filter(void)
-{
- return _filter;
-}
-
static void __init_log(struct config_file *cf)
{
char *open_mode = "a";
@@ -732,10 +728,14 @@ static int init(void)
int ret = 0;
const char *e = getenv("LVM_CONFIG_FILE");
struct stat info;
- struct pool *ios_pool;
+
+ if (!(cmd = dbg_malloc(sizeof(*cmd)))) {
+ log_error("Failed to allocate command context");
+ goto out;
+ }
/* FIXME: Override from config file. (Append trailing slash if reqd) */
- char *prefix = "/dev/";
+ cmd->dev_dir = "/dev/";
if (!(_cf = create_config_file())) {
stack;
@@ -763,17 +763,17 @@ static int init(void)
goto out;
}
- if (!(_filter = filter_setup())) {
+ if (!(cmd->filter = filter_setup())) {
log_error("Failed to set up internal device filters");
goto out;
}
- if (!(ios_pool = pool_create(4 * 1024))) {
- log_error("ios pool creation failed");
+ if (!(cmd->mem = pool_create(4 * 1024))) {
+ log_error("Command pool creation failed");
goto out;
}
- if (!(ios = create_lvm1_format(prefix, ios_pool, _filter))) {
+ if (!(fid = create_lvm1_format(cmd))) {
goto out;
}
@@ -796,12 +796,14 @@ static void __fin_commands(void)
static void fin(void)
{
if (dump_filter)
- persistent_filter_dump(_filter);
+ persistent_filter_dump(cmd->filter);
- ios->destroy(ios);
- _filter->destroy(_filter);
+ fid->ops->destroy(fid);
+ cmd->filter->destroy(cmd->filter);
+ pool_destroy(cmd->mem);
dev_cache_exit();
destroy_config_file(_cf);
+ dbg_free(cmd);
__fin_commands();
dump_memory();
fin_log();
diff --git a/tools/lvreduce.c b/tools/lvreduce.c
index 48aaf3f2..caa12221 100644
--- a/tools/lvreduce.c
+++ b/tools/lvreduce.c
@@ -61,7 +61,7 @@ int lvreduce(int argc, char **argv)
argv++;
argc--;
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
log_error("Please provide a volume group name");
return EINVALID_CMD_LINE;
}
@@ -71,7 +71,7 @@ int lvreduce(int argc, char **argv)
/* does VG exist? */
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -180,7 +180,7 @@ int lvreduce(int argc, char **argv)
/********* FIXME Suspend lv ***********/
/* store vg on disk(s) */
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
/* FIXME Ensure it always displays errors? */
diff --git a/tools/lvremove.c b/tools/lvremove.c
index 20caaa2d..4fc6ea59 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -49,12 +49,12 @@ int lvremove_single(char *lv_name)
struct logical_volume *lv;
/* does VG exist? */
- if (!(vg_name = extract_vgname(ios, lv_name))) {
+ if (!(vg_name = extract_vgname(fid, lv_name))) {
return ECMD_FAILED;
}
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -110,7 +110,7 @@ int lvremove_single(char *lv_name)
**********/
/* store it on disks */
- if (ios->vg_write(ios, vg))
+ if (fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
/******** FIXME
diff --git a/tools/lvscan.c b/tools/lvscan.c
index cb17881d..962389c9 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -72,7 +72,7 @@ static int lvscan_single(const char *vg_name)
struct list *lvh;
log_verbose("Checking for volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s not found", vg_name);
return ECMD_FAILED;
}
@@ -112,7 +112,7 @@ static int lvscan_single(const char *vg_name)
display_size(lv->size / 2, SIZE_SHORT);
log_print("%s%s '%s%s/%s' [%s]%s%s", active_str, snapshot_str,
- ios->prefix, vg->name, lv->name, dummy,
+ fid->cmd->dev_dir, vg->name, lv->name, dummy,
(lv->status & ALLOC_STRICT) ? " strict" : "",
(lv->status & ALLOC_CONTIGUOUS) ? " contiguous" : "");
diff --git a/tools/pvchange.c b/tools/pvchange.c
index 94dae99a..29bad00b 100644
--- a/tools/pvchange.c
+++ b/tools/pvchange.c
@@ -52,7 +52,7 @@ int pvchange(int argc, char **argv)
log_verbose("Using physical volume(s) on command line");
for (; opt < argc; opt++) {
pv_name = argv[opt];
- if (!(pv = ios->pv_read(ios, pv_name))) {
+ if (!(pv = fid->ops->pv_read(fid, pv_name))) {
log_error("Failed to read physical volume %s",
pv_name);
continue;
@@ -62,7 +62,7 @@ int pvchange(int argc, char **argv)
}
} else {
log_verbose("Scanning for physical volume names");
- if (!(pvs = ios->get_pvs(ios))) {
+ if (!(pvs = fid->ops->get_pvs(fid))) {
return ECMD_FAILED;
}
@@ -98,7 +98,7 @@ int pvchange_single(struct physical_volume *pv)
if (*pv->vg_name) {
log_verbose("Finding volume group of physical volume %s",
pv_name);
- if (!(vg = ios->vg_read(ios, pv->vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, pv->vg_name))) {
log_error("Unable to find volume group of %s", pv_name);
return 0;
}
@@ -137,13 +137,13 @@ int pvchange_single(struct physical_volume *pv)
log_verbose("Updating physical volume %s", pv_name);
if (*pv->vg_name) {
- if (!(ios->vg_write(ios,vg))) {
+ if (!(fid->ops->vg_write(fid,vg))) {
log_error("Failed to store physical volume %s in "
"volume group %s", pv_name, vg->name);
return 0;
}
} else {
- if (!(ios->pv_write(ios, pv))) {
+ if (!(fid->ops->pv_write(fid, pv))) {
log_error("Failed to store physical volume %s",
pv_name);
return 0;
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 47a23998..380c9a83 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -36,7 +36,7 @@ static int pvcreate_check(const char *name)
return 0;
/* is there a pv here already */
- if (!(pv = ios->pv_read(ios, name)))
+ if (!(pv = fid->ops->pv_read(fid, name)))
return 1;
/* orphan ? */
@@ -86,7 +86,7 @@ static void pvcreate_single(const char *pv_name)
if (!pvcreate_check(pv_name))
return;
- if (!(pv = pv_create(ios, pv_name))) {
+ if (!(pv = pv_create(fid, pv_name))) {
log_err("Failed to setup physical volume %s", pv_name);
return;
}
@@ -95,7 +95,7 @@ static void pvcreate_single(const char *pv_name)
pv_name, pv->size);
log_verbose("Writing physical volume data to disk %s", pv_name);
- if (!(ios->pv_write(ios, pv))) {
+ if (!(fid->ops->pv_write(fid, pv))) {
log_error("Failed to write physical volume %s", pv_name);
return;
}
@@ -119,7 +119,7 @@ int pvcreate(int argc, char **argv)
for (i = 0; i < argc; i++) {
pvcreate_single(argv[i]);
- pool_empty(ios->mem);
+ pool_empty(fid->cmd->mem);
}
return 0;
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index c8cff098..783d9ffb 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -38,7 +38,7 @@ int pvdisplay(int argc, char **argv)
log_very_verbose("Using physical volume(s) on command line");
for (; opt < argc; opt++) {
- if (!(pv = ios->pv_read(ios, argv[opt]))) {
+ if (!(pv = fid->ops->pv_read(fid, argv[opt]))) {
log_error("Failed to read physical volume %s",
argv[opt]);
continue;
@@ -47,7 +47,7 @@ int pvdisplay(int argc, char **argv)
}
} else {
log_verbose("Scanning for physical volume names");
- if (!(pvs = ios->get_pvs(ios)))
+ if (!(pvs = fid->ops->get_pvs(fid)))
return ECMD_FAILED;
list_iterate(pvh, pvs)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 93d5c328..89fbb04c 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -54,10 +54,10 @@ int pvscan(int argc, char **argv)
"of exported volume group(s)" : "in no volume group");
log_verbose("Wiping cache of LVM-capable devices");
- persistent_filter_wipe(ios->filter);
+ persistent_filter_wipe(fid->cmd->filter);
log_verbose("Walking through all physical volumes");
- if (!(pvs = ios->get_pvs(ios)))
+ if (!(pvs = fid->ops->get_pvs(fid)))
return ECMD_FAILED;
/* eliminate exported/new if required */
diff --git a/tools/toollib.c b/tools/toollib.c
index f84e0cc3..ad53faf6 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -104,7 +104,7 @@ int process_each_vg(int argc, char **argv,
ret_max = ret;
} else {
log_verbose("Finding all volume group(s)");
- if (!(vgs_list = ios->get_vgs(ios))) {
+ if (!(vgs_list = fid->ops->get_vgs(fid))) {
log_error("No volume groups found");
return ECMD_FAILED;
}
@@ -165,16 +165,17 @@ int is_valid_chars(char *n)
return 1;
}
-char *extract_vgname(struct io_space *ios, char *lv_name)
+char *extract_vgname(struct format_instance *fi, char *lv_name)
{
char *vg_name = lv_name;
char *st;
+ char *dev_dir = fi->cmd->dev_dir;
/* Path supplied? */
if (vg_name && strchr(vg_name, '/')) {
/* Strip prefix (optional) */
- if (!strncmp(vg_name, ios->prefix, strlen(ios->prefix)))
- vg_name += strlen(ios->prefix);
+ if (!strncmp(vg_name, dev_dir, strlen(dev_dir)))
+ vg_name += strlen(dev_dir);
/* Require exactly one slash */
/* FIXME But allow for consecutive slashes */
@@ -183,7 +184,7 @@ char *extract_vgname(struct io_space *ios, char *lv_name)
return 0;
}
- vg_name = pool_strdup(ios->mem, vg_name);
+ vg_name = pool_strdup(fid->cmd->mem, vg_name);
if (!vg_name) {
log_error("Allocation of vg_name failed");
return 0;
@@ -193,7 +194,7 @@ char *extract_vgname(struct io_space *ios, char *lv_name)
return vg_name;
}
- if (!(vg_name = default_vgname(ios))) {
+ if (!(vg_name = default_vgname(fid))) {
if (lv_name)
log_error("Path required for Logical Volume %s", lv_name);
return 0;
@@ -202,9 +203,10 @@ char *extract_vgname(struct io_space *ios, char *lv_name)
return vg_name;
}
-char *default_vgname(struct io_space *ios)
+char *default_vgname(struct format_instance *fi)
{
char *vg_path;
+ char *dev_dir = fi->cmd->dev_dir;
/* Take default VG from environment? */
vg_path = getenv("LVM_VG_NAME");
@@ -212,8 +214,8 @@ char *default_vgname(struct io_space *ios)
return 0;
/* Strip prefix (optional) */
- if (!strncmp(vg_path, ios->prefix, strlen(ios->prefix)))
- vg_path += strlen(ios->prefix);
+ if (!strncmp(vg_path, dev_dir, strlen(dev_dir)))
+ vg_path += strlen(dev_dir);
if (strchr(vg_path, '/')) {
log_error("Environment Volume Group in LVM_VG_NAME invalid: %s",
@@ -221,6 +223,6 @@ char *default_vgname(struct io_space *ios)
return 0;
}
- return pool_strdup(ios->mem, vg_path);
+ return pool_strdup(fid->cmd->mem, vg_path);
}
diff --git a/tools/toollib.h b/tools/toollib.h
index cb6dba9c..dd35dbd6 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -34,7 +34,7 @@ int process_each_pv(int argc, char **argv, struct volume_group *vg,
int is_valid_chars(char *n);
-char *default_vgname(struct io_space *ios);
-char *extract_vgname(struct io_space *ios, char *lv_name);
+char *default_vgname(struct format_instance *fi);
+char *extract_vgname(struct format_instance *fi, char *lv_name);
#endif
diff --git a/tools/tools.h b/tools/tools.h
index 9ac189f5..c019dab4 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -123,8 +123,7 @@ static inline int arg_count_increment(int a)
}
struct config_file *active_config_file(void);
-struct dev_filter *active_filter(void);
-extern struct io_space *ios;
+extern struct format_instance *fid;
#endif
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 49a69d24..692ab51d 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -51,7 +51,7 @@ static int vgchange_single(const char *vg_name)
{
struct volume_group *vg;
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Unable to find volume group %s", vg_name);
return ECMD_FAILED;
}
@@ -112,7 +112,7 @@ void vgchange_available(struct volume_group *vg)
&= ~ACTIVE;
}
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return;
if (available && (lv_open = activate_lvs_in_vg(vg)))
@@ -148,7 +148,7 @@ void vgchange_allocation(struct volume_group *vg)
else
vg->status &= ~EXTENDABLE_VG;
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return;
log_print("Volume group %s successfully changed", vg->name);
@@ -202,7 +202,7 @@ void vgchange_logicalvolume(struct volume_group *vg)
vg->max_lv = max_lv;
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return;
log_print("Volume group %s successfully changed", vg->name);
diff --git a/tools/vgck.c b/tools/vgck.c
index 86cee39e..70d6e323 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -33,7 +33,7 @@ static int vgck_single(const char *vg_name)
log_verbose("Checking volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s not found", vg_name);
return ECMD_FAILED;
}
diff --git a/tools/vgcreate.c b/tools/vgcreate.c
index e97127f0..2b6d5c9e 100644
--- a/tools/vgcreate.c
+++ b/tools/vgcreate.c
@@ -62,8 +62,8 @@ int vgcreate(int argc, char **argv)
}
/* Strip prefix if present */
- if (!strncmp(vg_name, ios->prefix, strlen(ios->prefix)))
- vg_name += strlen(ios->prefix);
+ if (!strncmp(vg_name, fid->cmd->dev_dir, strlen(fid->cmd->dev_dir)))
+ vg_name += strlen(fid->cmd->dev_dir);
if (!is_valid_chars(vg_name)) {
log_error("New volume group name '%s' has invalid characters",
@@ -72,7 +72,7 @@ int vgcreate(int argc, char **argv)
}
/* create the new vg */
- if (!(vg = vg_create(ios, vg_name, extent_size, max_pv, max_lv,
+ if (!(vg = vg_create(fid, vg_name, extent_size, max_pv, max_lv,
argc - 1, argv + 1)))
return ECMD_FAILED;
@@ -85,7 +85,7 @@ int vgcreate(int argc, char **argv)
vg->max_pv);
/* store vg on disk(s) */
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
/* FIXME Create /dev/vg */
diff --git a/tools/vgextend.c b/tools/vgextend.c
index 3b449bd2..0c3d1006 100644
--- a/tools/vgextend.c
+++ b/tools/vgextend.c
@@ -41,7 +41,7 @@ int vgextend(int argc, char **argv)
argv++;
log_verbose("Checking for volume group '%s'", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group '%s' not found.", vg_name);
return ECMD_FAILED;
}
@@ -64,7 +64,7 @@ int vgextend(int argc, char **argv)
**********/
/* extend vg */
- if (!vg_extend(ios, vg, argc, argv))
+ if (!vg_extend(fid, vg, argc, argv))
return ECMD_FAILED;
/* ret > 0 */
@@ -72,7 +72,7 @@ int vgextend(int argc, char **argv)
"physical volumes", vg_name, argc);
/* store vg on disk(s) */
- if (!ios->vg_write(ios, vg))
+ if (!fid->ops->vg_write(fid, vg))
return ECMD_FAILED;
/********* FIXME
diff --git a/tools/vgreduce.c b/tools/vgreduce.c
index 5bfdbbc9..468cff1b 100644
--- a/tools/vgreduce.c
+++ b/tools/vgreduce.c
@@ -49,7 +49,7 @@ int vgreduce(int argc, char **argv)
argc--;
log_verbose("Finding volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -114,13 +114,13 @@ static int vgreduce_single(struct volume_group *vg, struct physical_volume *pv)
*pv->vg_name = '\0';
vg->pv_count--;
- if (!(ios->vg_write(ios, vg))) {
+ if (!(fid->ops->vg_write(fid, vg))) {
log_error("Removal of physical volume %s from %s failed",
name, vg->name);
return ECMD_FAILED;
}
- if (!ios->pv_write(ios, pv)) {
+ if (!fid->ops->pv_write(fid, pv)) {
log_error("Failed to clear metadata from physical volume %s "
"after removal from %s", name, vg->name);
return ECMD_FAILED;
diff --git a/tools/vgremove.c b/tools/vgremove.c
index eec50db7..944685cc 100644
--- a/tools/vgremove.c
+++ b/tools/vgremove.c
@@ -35,7 +35,7 @@ static int vgremove_single(const char *vg_name)
int ret = 0;
log_verbose("Checking for volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s doesn't exist", vg_name);
return ECMD_FAILED;
}
@@ -64,7 +64,7 @@ static int vgremove_single(const char *vg_name)
log_verbose("Removing physical volume %s from volume group %s",
dev_name(pv->dev), vg_name);
*pv->vg_name = '\0';
- if (!(ios->pv_write(ios, pv))) {
+ if (!(fid->ops->pv_write(fid, pv))) {
log_error("Failed to remove physical volume %s from "
"volume group %s", dev_name(pv->dev),
vg_name);
diff --git a/tools/vgrename.c b/tools/vgrename.c
index c9711695..37af8b0a 100644
--- a/tools/vgrename.c
+++ b/tools/vgrename.c
@@ -40,7 +40,7 @@ int vgrename(int argc, char **argv)
vg_name_old = argv[0];
vg_name_new = argv[1];
- prefix = ios->prefix;
+ prefix = fid->cmd->dev_dir;
length = strlen(prefix);
/* If present, strip prefix */
@@ -68,7 +68,7 @@ int vgrename(int argc, char **argv)
}
log_verbose("Checking for existing volume group %s", vg_name_old);
- if (!(vg_old = ios->vg_read(ios, vg_name_old))) {
+ if (!(vg_old = fid->ops->vg_read(fid, vg_name_old))) {
log_error("Volume group %s doesn't exist", vg_name_old);
return ECMD_FAILED;
}
@@ -82,7 +82,7 @@ int vgrename(int argc, char **argv)
}
log_verbose("Checking for new volume group %s", vg_name_new);
- if ((vg_new = ios->vg_read(ios, vg_name_new))) {
+ if ((vg_new = fid->ops->vg_read(fid, vg_name_new))) {
log_error("New volume group %s already exists", vg_name_new);
return ECMD_FAILED;
}
@@ -114,7 +114,7 @@ int vgrename(int argc, char **argv)
/* store it on disks */
log_verbose("Writing out updated volume group");
- if (!(ios->vg_write(ios, vg_old))) {
+ if (!(fid->ops->vg_write(fid, vg_old))) {
return ECMD_FAILED;
}
@@ -141,7 +141,7 @@ char *lv_change_vgname(char *vg_name, char *lv_name)
** check if lv_name includes a path
if ((lv_name_ptr = strrchr(lv_name, '/'))) {
lv_name_ptr++;
- sprintf(lv_name_buf, "%s%s/%s%c", ios->prefix, vg_name,
+ sprintf(lv_name_buf, "%s%s/%s%c", fid->cmd->dev_dir, vg_name,
lv_name_ptr, 0);}
else
strncpy(lv_name_buf, lv_name, NAME_LEN - 1); return lv_name_buf;}
diff --git a/tools/vgscan.c b/tools/vgscan.c
index a205be71..b7435bbe 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -30,7 +30,7 @@ int vgscan(int argc, char **argv)
}
log_verbose("Wiping cache of LVM-capable devices");
- persistent_filter_wipe(ios->filter);
+ persistent_filter_wipe(fid->cmd->filter);
log_print("Reading all physical volumes (this may take a while...)");
@@ -42,7 +42,7 @@ static int vgscan_single(const char *vg_name)
struct volume_group *vg;
log_verbose("Checking for volume group %s", vg_name);
- if (!(vg = ios->vg_read(ios, vg_name))) {
+ if (!(vg = fid->ops->vg_read(fid, vg_name))) {
log_error("Volume group %s not found", vg_name);
return ECMD_FAILED;
}
@@ -52,7 +52,7 @@ static int vgscan_single(const char *vg_name)
if (!(vg->status & ACTIVE)) {
vg->status |= ACTIVE;
- if (!(ios->vg_write(ios, vg))) {
+ if (!(fid->ops->vg_write(fid, vg))) {
log_error("Failed to activate volume group %s",
vg_name);
return ECMD_FAILED;