summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-12-12 20:55:49 +0000
committerAlasdair Kergon <agk@redhat.com>2002-12-12 20:55:49 +0000
commit4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701 (patch)
tree2c0968a82423acbddbc610bfea5518b212429f91 /tools
parenteb537fa130c9c9fca9c10319b2b955d800ba3742 (diff)
downloadlvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.tar.gz
lvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.tar.xz
lvm2-4c64ed4ced7dcd3a98a63da1cd3a6f2f1f2d1701.zip
New column-based reporting tools: lvs, pvs & vgs.
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.in5
-rw-r--r--tools/args.h9
-rw-r--r--tools/commands.h174
-rw-r--r--tools/lvcreate.c12
-rw-r--r--tools/lvdisplay.c15
-rw-r--r--tools/lvm.c14
-rw-r--r--tools/lvmdiskscan.c21
-rw-r--r--tools/lvresize.c23
-rw-r--r--tools/lvscan.c9
-rw-r--r--tools/pvcreate.c4
-rw-r--r--tools/pvdisplay.c66
-rw-r--r--tools/pvscan.c41
-rw-r--r--tools/report.c235
-rw-r--r--tools/toollib.c65
-rw-r--r--tools/toollib.h13
-rw-r--r--tools/tools.h14
-rw-r--r--tools/vgck.c1
-rw-r--r--tools/vgconvert.c2
-rw-r--r--tools/vgdisplay.c17
19 files changed, 597 insertions, 143 deletions
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 42ae8aef..604e942b 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -39,6 +39,7 @@ SOURCES=\
pvdisplay.c \
pvremove.c \
pvscan.c \
+ report.c \
toollib.c \
vgcfgbackup.c \
vgcfgrestore.c \
@@ -67,8 +68,8 @@ lvm: $(OBJECTS) $(top_srcdir)/lib/liblvm.a
$(CC) -o lvm $(OBJECTS) $(LD_FLAGS) -L$(top_srcdir)/lib \
-L$(DESTDIR)/lib -llvm -ldevmapper $(LIBS) -ldl -rdynamic
-.commands: commands.h cmdnames.h
- $(CC) -E -P cmdnames.h | grep -v help > .commands
+.commands: commands.h cmdnames.h Makefile
+ $(CC) -E -P cmdnames.h | egrep -v '(help|version)' > .commands
install: $(TARGETS)
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm \
diff --git a/tools/args.h b/tools/args.h
index d859f16a..06d5a0a2 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -17,6 +17,12 @@ arg(metadatasize_ARG, '\0', "metadatasize", size_mb_arg)
arg(restorefile_ARG, '\0', "restorefile", string_arg)
arg(labelsector_ARG, '\0', "labelsector", int_arg)
arg(driverloaded_ARG, '\0', "driverloaded", yes_no_arg)
+arg(aligned_ARG, '\0', "aligned", NULL)
+arg(unbuffered_ARG, '\0', "unbuffered", NULL)
+arg(noheadings_ARG, '\0', "noheadings", NULL)
+arg(segments_ARG, '\0', "segments", NULL)
+arg(units_ARG, '\0', "units", string_arg)
+arg(nosuffix_ARG, '\0', "nosuffix", NULL)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg)
@@ -32,6 +38,7 @@ arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL)
arg(blockdevice_ARG, 'b', "blockdevice", NULL)
arg(chunksize_ARG, 'c', "chunksize", size_kb_arg)
arg(colon_ARG, 'c', "colon", NULL)
+arg(columns_ARG, 'C', "columns", NULL)
arg(contiguous_ARG, 'C', "contiguous", yes_no_arg)
arg(debug_ARG, 'd', "debug", NULL)
arg(disk_ARG, 'D', "disk", NULL)
@@ -61,6 +68,7 @@ arg(oldpath_ARG, 'n', "oldpath", NULL)
arg(nofsck_ARG, 'n', "nofsck", NULL)
arg(novolumegroup_ARG, 'n', "novolumegroup", NULL)
arg(options_ARG, 'o', "options", string_arg)
+arg(sort_ARG, 'O', "sort", string_arg)
arg(permission_ARG, 'p', "permission", permission_arg)
arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg)
arg(partial_ARG, 'P', "partial", NULL)
@@ -68,6 +76,7 @@ arg(physicalvolume_ARG, 'P', "physicalvolume", NULL)
arg(readahead_ARG, 'r', "readahead", int_arg)
arg(reset_ARG, 'R', "reset", NULL)
arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg)
+arg(separator_ARG, 's', "separator", string_arg)
arg(stdin_ARG, 's', "stdin", NULL)
arg(snapshot_ARG, 's', "snapshot", NULL)
arg(short_ARG, 's', "short", NULL)
diff --git a/tools/commands.h b/tools/commands.h
index 5e984b42..2923f91d 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -62,6 +62,7 @@ xx(lvchange,
"\t[-r|--readahead ReadAheadSectors]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
autobackup_ARG, available_ARG, contiguous_ARG,
@@ -118,11 +119,34 @@ xx(lvdisplay,
"\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[-m|--maps]\n"
+ "\t[--nosuffix]\n"
"\t[-P|--partial] " "\n"
+ "\t[--units hsbkmgtHKMGT]\n"
"\t[-v|--verbose]\n"
- "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
+ "\t[--version]" "\n"
+ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n"
+ "\n"
+ "lvdisplay --columns|-C\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
+ "\t[--noheadings]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[-P|--partial] " "\n"
+ "\t[--segments]\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
+ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
- colon_ARG, disk_ARG, ignorelockingfailure_ARG, maps_ARG, partial_ARG)
+ aligned_ARG, colon_ARG, columns_ARG, disk_ARG, ignorelockingfailure_ARG,
+ maps_ARG, noheadings_ARG, nosuffix_ARG, options_ARG, sort_ARG,
+ partial_ARG, segments_ARG, separator_ARG, unbuffered_ARG, units_ARG)
xx(lvextend,
"Add space to a logical volume",
@@ -135,6 +159,7 @@ xx(lvextend,
"\t -L|--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG,
@@ -146,7 +171,8 @@ xx(lvmchange,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-R|--reset]\n"
- "\t[-v|--verbose]\n",
+ "\t[-v|--verbose]\n"
+ "\t[--version]" "\n",
reset_ARG)
@@ -155,7 +181,8 @@ xx(lvmdiskscan,
"lvmdiskscan\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
- "\t[-l|--lvmpartition]\n",
+ "\t[-l|--lvmpartition]\n"
+ "\t[--version]" "\n",
lvmpartition_ARG)
@@ -165,6 +192,7 @@ xx(lvmsadc,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\t[LogFilePath]\n" )
xx(lvmsar,
@@ -175,6 +203,7 @@ xx(lvmsar,
"\t[-h|--help]\n"
"\t[-s|--stdin]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogFilePath\n",
full_ARG, stdin_ARG)
@@ -190,6 +219,7 @@ xx(lvreduce,
"\t -L|--size [-]LogicalVolumeSize[kKmMgGtT]}\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogicalVolume[Path]\n",
autobackup_ARG, force_ARG, extents_ARG,
@@ -204,6 +234,7 @@ xx(lvremove,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
autobackup_ARG, force_ARG, test_ARG)
@@ -233,11 +264,36 @@ xx(lvresize,
"\t -L|--size [+|-]LogicalVolumeSize[kKmMgGtT]}\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tLogicalVolume[Path] [ PhysicalVolumePath... ]\n",
autobackup_ARG, extents_ARG, size_ARG, stripes_ARG, stripesize_ARG,
test_ARG)
+xx(lvs,
+ "Display information about logical volumes",
+ "lvs" "\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
+ "\t[--noheadings]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[-P|--partial] " "\n"
+ "\t[--segments]\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
+ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
+
+ aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
+ options_ARG, partial_ARG, segments_ARG, separator_ARG, sort_ARG,
+ unbuffered_ARG, units_ARG)
+
xx(lvscan,
"List all logical volumes in all volume groups",
"lvscan " "\n"
@@ -258,6 +314,7 @@ xx(pvchange,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\t[-a|--all]\n"
"\t[-t|--test]\n"
"\t[-x|--allocatable y|n]\n"
@@ -307,18 +364,39 @@ xx(pvdata,
physicalvolume_ARG, uuidlist_ARG, volumegroup_ARG)
xx(pvdisplay,
- "Display various attributes of logical volume(s)",
+ "Display various attributes of physical volume(s)",
"pvdisplay\n"
"\t[-c|--colon]\n"
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[-m|--maps]\n"
+ "\t[--nosuffix]\n"
"\t[-s|--short]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
"\t[-v|--verbose]\n"
- "\tPhysicalVolumePath [PhysicalVolumePath...]\n",
+ "\t[--version]" "\n"
+ "\t[PhysicalVolumePath [PhysicalVolumePath...]]\n"
+ "\n"
+ "pvdisplay --columns|-C\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
+ "\t[--noheadings]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
+ "\t[PhysicalVolumePath [PhysicalVolumePath...]]\n",
- colon_ARG, ignorelockingfailure_ARG, maps_ARG, short_ARG)
+ aligned_ARG, colon_ARG, columns_ARG, ignorelockingfailure_ARG, maps_ARG,
+ noheadings_ARG, nosuffix_ARG, options_ARG, separator_ARG, short_ARG,
+ sort_ARG, unbuffered_ARG, units_ARG)
xx(pvmove,
"Move extents from one physical volume to another",
@@ -366,6 +444,27 @@ xx(pvresize,
***/
autobackup_ARG, physicalvolumesize_ARG)
+xx(pvs,
+ "Display information about physical volumes",
+ "pvs" "\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug]" "\n"
+ "\t[-h|-?|--help] " "\n"
+ "\t[--noheadings]\n"
+ "\t[--ignorelockingfailure]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t[PhysicalVolume [PhysicalVolume...]]\n",
+
+ aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
+ options_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
+
xx(pvscan,
"List all physical volumes",
"pvscan " "\n"
@@ -391,7 +490,7 @@ xx(vgcfgbackup,
"\t[--ignorelockingfailure]\n"
"\t[-P|--partial] " "\n"
"\t[-v|--verbose]" "\n"
- "\t[-V|--version] " "\n"
+ "\t[--version] " "\n"
"\t[VolumeGroupName...]\n",
file_ARG, ignorelockingfailure_ARG, partial_ARG)
@@ -437,6 +536,7 @@ xx(vgck,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n",
"\t[VolumeGroupName...]\n" )
xx(vgconvert,
@@ -481,13 +581,33 @@ xx(vgdisplay,
"\t[-d|--debug] " "\n"
"\t[-h|--help] " "\n"
"\t[--ignorelockingfailure]" "\n"
+ "\t[--nosuffix]\n"
"\t[-P|--partial] " "\n"
+ "\t[--units hsbkmgtHKMGT]\n"
"\t[-A|--activevolumegroups | [-D|--disk]" "\n"
"\t[--version]" "\n"
- "\t[VolumeGroupName...] ]\n",
+ "\t[VolumeGroupName [VolumeGroupName...]]\n"
+ "\n"
+ "vgdisplay --columns|-C\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug] " "\n"
+ "\t[-h|--help] " "\n"
+ "\t[--ignorelockingfailure]" "\n"
+ "\t[--noheadings]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[-P|--partial] " "\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[--verbose]" "\n"
+ "\t[--version]" "\n"
+ "\t[VolumeGroupName [VolumeGroupName...]]\n",
- activevolumegroups_ARG, colon_ARG, disk_ARG, ignorelockingfailure_ARG,
- short_ARG, partial_ARG)
+ activevolumegroups_ARG, aligned_ARG, colon_ARG, columns_ARG, disk_ARG,
+ ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG, options_ARG,
+ partial_ARG, separator_ARG, short_ARG, sort_ARG, unbuffered_ARG, units_ARG)
xx(vgexport,
"Unregister volume group(s) from the system",
@@ -509,6 +629,7 @@ xx(vgextend,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tVolumeGroupName PhysicalDevicePath [PhysicalDevicePath...]\n",
autobackup_ARG, test_ARG)
@@ -522,6 +643,7 @@ xx(vgimport,
"\t[-h|--help] " "\n"
"\t[-t|--test] " "\n"
"\t[-v|--verbose]" "\n"
+ "\t[--version]" "\n"
"\tVolumeGroupName..." "\n",
all_ARG, force_ARG, test_ARG)
@@ -535,6 +657,7 @@ xx(vgmerge,
"\t[-l|--list]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tDestinationVolumeGroupName SourceVolumeGroupName\n",
autobackup_ARG, list_ARG, test_ARG)
@@ -545,6 +668,7 @@ xx(vgmknodes,
"\t[-d|--debug]\n"
"\t[-h|--help]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\t[VolumeGroupName...]\n" )
xx(vgreduce,
@@ -556,6 +680,7 @@ xx(vgreduce,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tVolumeGroupName\n"
"\t[PhysicalVolumePath...]\n",
@@ -568,6 +693,7 @@ xx(vgremove,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tVolumeGroupName [VolumeGroupName...]\n",
test_ARG)
@@ -580,11 +706,34 @@ xx(vgrename,
"\t[-h|--help]\n"
"\t[-t|--test]\n"
"\t[-v|--verbose]\n"
+ "\t[--version]" "\n"
"\tOldVolumeGroupPath NewVolumeGroupPath |\n"
"\tOldVolumeGroupName NewVolumeGroupName\n",
autobackup_ARG, force_ARG, test_ARG)
+xx(vgs,
+ "Display information about volume groups",
+ "vgs" "\n"
+ "\t[--aligned]\n"
+ "\t[-d|--debug]\n"
+ "\t[-h|--help]\n"
+ "\t[--ignorelockingfailure]\n"
+ "\t[--noheadings]\n"
+ "\t[--nosuffix]\n"
+ "\t[-o|--options [+]Field[,Field]]\n"
+ "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
+ "\t[-P|--partial] " "\n"
+ "\t[--separator Separator]\n"
+ "\t[--unbuffered]\n"
+ "\t[--units hsbkmgtHKMGT]\n"
+ "\t[-v|--verbose]\n"
+ "\t[--version]\n"
+ "\t[VolumeGroupName [VolumeGroupName...]]\n",
+
+ aligned_ARG, ignorelockingfailure_ARG, noheadings_ARG, nosuffix_ARG,
+ options_ARG, partial_ARG, separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
+
xx(vgscan,
"Search for all volume groups",
"vgscan "
@@ -592,7 +741,8 @@ xx(vgscan,
"\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n"
"\t[-P|--partial] " "\n"
- "\t[-v|--verbose]\n" ,
+ "\t[-v|--verbose]\n"
+ "\t[--version]" "\n",
ignorelockingfailure_ARG, partial_ARG)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 176c7f4e..b7ca5315 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -144,7 +144,7 @@ static int _read_size_params(struct lvcreate_params *lp,
/* Size returned in kilobyte units; held in sectors */
if (arg_count(cmd, size_ARG))
- lp->size = arg_int64_value(cmd, size_ARG, 0) * 2ull;
+ lp->size = arg_uint64_value(cmd, size_ARG, 0) * 2ull;
return 1;
}
@@ -378,15 +378,11 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
lp->extents = lp->size;
if (lp->extents % vg->extent_size) {
- char *s1;
-
lp->extents += vg->extent_size - lp->extents %
vg->extent_size;
- log_print("Rounding up size to full physical "
- "extent %s",
- (s1 = display_size(lp->extents / 2,
- SIZE_SHORT)));
- dbg_free(s1);
+ log_print("Rounding up size to full physical extent %s",
+ display_size(cmd, lp->extents / 2,
+ SIZE_SHORT));
}
lp->extents /= vg->extent_size;
diff --git a/tools/lvdisplay.c b/tools/lvdisplay.c
index 69971b1b..47d546da 100644
--- a/tools/lvdisplay.c
+++ b/tools/lvdisplay.c
@@ -36,7 +36,20 @@ int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
{
- /* FIXME Allow VG args via process_each */
+ if (arg_count(cmd, columns_ARG)) {
+ if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
+ return lvs(cmd, argc, argv);
+ } else if (arg_count(cmd, aligned_ARG) ||
+ arg_count(cmd, noheadings_ARG) ||
+ arg_count(cmd, options_ARG) ||
+ arg_count(cmd, separator_ARG) ||
+ arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
if (arg_count(cmd, colon_ARG) && arg_count(cmd, verbose_ARG)) {
log_error("Options -v and -c are incompatible");
diff --git a/tools/lvm.c b/tools/lvm.c
index dbc295ff..66550319 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -157,7 +157,8 @@ static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
v *= factor;
a->i_value = (uint32_t) v;
- a->i64_value = (uint64_t) v;
+ a->i64_value = (int64_t) v;
+ a->ui64_value = (uint64_t) v;
return 1;
}
@@ -547,6 +548,17 @@ static int _get_settings(struct cmd_context *cmd)
else
init_ignorelockingfailure(0);
+ if (arg_count(cmd, nosuffix_ARG))
+ cmd->current_settings.suffix = 0;
+
+ if (arg_count(cmd, units_ARG))
+ if (!(cmd->current_settings.unit_factor =
+ units_to_bytes(arg_str_value(cmd, units_ARG, ""),
+ &cmd->current_settings.unit_type))) {
+ log_error("Invalid units specification");
+ return EINVALID_CMD_LINE;
+ }
+
/* Handle synonyms */
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
diff --git a/tools/lvmdiskscan.c b/tools/lvmdiskscan.c
index a6edfa6b..a33c128e 100644
--- a/tools/lvmdiskscan.c
+++ b/tools/lvmdiskscan.c
@@ -52,19 +52,14 @@ static void _count(struct device *dev, int *disks, int *parts)
(*parts)++;
}
-static void _print(struct device *dev, uint64_t size, char *what)
+static void _print(struct cmd_context *cmd, struct device *dev, uint64_t size,
+ char *what)
{
- char *dummy = display_size(size / 2, SIZE_SHORT);
- const char *name = dev_name(dev);
-
- if (!what)
- what = "";
-
- log_print("%-*s [%15s] %s", max_len, name, dummy, what);
- dbg_free(dummy);
+ log_print("%-*s [%15s] %s", max_len, dev_name(dev),
+ display_size(cmd, size / 2, SIZE_SHORT), what ? : "");
}
-static int _check_device(struct device *dev)
+static int _check_device(struct cmd_context *cmd, struct device *dev)
{
char buffer;
uint64_t size;
@@ -79,7 +74,7 @@ static int _check_device(struct device *dev)
if (!dev_get_size(dev, &size)) {
log_error("Couldn't get size of \"%s\"", dev_name(dev));
}
- _print(dev, size, NULL);
+ _print(cmd, dev, size, NULL);
_count(dev, &disks_found, &parts_found);
if (!dev_close(dev)) {
log_error("dev_close on \"%s\" failed", dev_name(dev));
@@ -114,7 +109,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
dev_name(dev));
continue;
}
- _print(dev, size, "LVM physical volume");
+ _print(cmd, dev, size, "LVM physical volume");
_count(dev, &pv_disks_found, &pv_parts_found);
continue;
}
@@ -123,7 +118,7 @@ int lvmdiskscan(struct cmd_context *cmd, int argc, char **argv)
continue;
/* What other device is it? */
- if (!_check_device(dev))
+ if (!_check_device(cmd, dev))
continue;
}
dev_iter_destroy(iter);
diff --git a/tools/lvresize.c b/tools/lvresize.c
index b058d8f5..163450b0 100644
--- a/tools/lvresize.c
+++ b/tools/lvresize.c
@@ -34,7 +34,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
sign_t sign = SIGN_NONE;
char *lv_name, *vg_name;
char *st;
- char *dummy;
const char *cmd_name;
struct list *pvh, *segh;
struct lv_list *lvl;
@@ -145,8 +144,6 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
extents = size * 2;
if (extents % vg->extent_size) {
- char *s1;
-
if (sign == SIGN_MINUS)
extents -= extents % vg->extent_size;
else
@@ -154,8 +151,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
(extents % vg->extent_size);
log_print("Rounding up size to full physical extent %s",
- (s1 = display_size(extents / 2, SIZE_SHORT)));
- dbg_free(s1);
+ display_size(cmd, extents / 2, SIZE_SHORT));
}
extents /= vg->extent_size;
@@ -310,16 +306,14 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
}
if (info.exists) {
- dummy = display_size((uint64_t)
- extents * (vg->extent_size / 2),
- SIZE_SHORT);
log_print("WARNING: Reducing active%s logical volume "
"to %s", info.open_count ? " and open" : "",
- dummy);
+ display_size(cmd, (uint64_t)
+ extents * (vg->extent_size / 2),
+ SIZE_SHORT));
log_print("THIS MAY DESTROY YOUR DATA "
"(filesystem etc.)");
- dbg_free(dummy);
}
if (!arg_count(cmd, force_ARG)) {
@@ -352,11 +346,10 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
/* Use full list from VG */
pvh = &vg->pvs;
}
- dummy = display_size((uint64_t)
- extents * (vg->extent_size / 2),
- SIZE_SHORT);
- log_print("Extending logical volume %s to %s", lv_name, dummy);
- dbg_free(dummy);
+ log_print("Extending logical volume %s to %s", lv_name,
+ display_size(cmd, (uint64_t)
+ extents * (vg->extent_size / 2),
+ SIZE_SHORT));
if (!lv_extend(vg->fid, lv, stripes, stripesize,
extents - lv->le_count, pvh))
diff --git a/tools/lvscan.c b/tools/lvscan.c
index d0449288..fd93d58e 100644
--- a/tools/lvscan.c
+++ b/tools/lvscan.c
@@ -27,7 +27,6 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
int lv_total = 0;
ulong lv_capacity_total = 0;
- char *dummy;
const char *active_str, *snapshot_str;
if (lv_info(lv, &info) && info.exists)
@@ -42,14 +41,11 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
else
snapshot_str = " ";
- dummy = display_size(lv->size / 2, SIZE_SHORT);
-
log_print("%s%s '%s%s/%s' [%s] %s", active_str, snapshot_str,
- cmd->dev_dir, lv->vg->name, lv->name, dummy,
+ cmd->dev_dir, lv->vg->name, lv->name,
+ display_size(cmd, lv->size / 2, SIZE_SHORT),
get_alloc_string(lv->alloc));
- dbg_free(dummy);
-
lv_total++;
lv_capacity_total += lv->size;
@@ -66,4 +62,5 @@ int lvscan(struct cmd_context *cmd, int argc, char **argv)
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
&lvscan_single);
+
}
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 7ca11ede..5534437d 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -130,9 +130,9 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
if (!pvcreate_check(cmd, pv_name))
goto error;
- size = arg_int64_value(cmd, physicalvolumesize_ARG, 0) * 2;
+ size = arg_uint64_value(cmd, physicalvolumesize_ARG, 0) * 2;
- pvmetadatasize = arg_int64_value(cmd, metadatasize_ARG, 0) * 2;
+ pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
if (!pvmetadatasize)
pvmetadatasize = find_config_int(cmd->cf->root,
"metadata/pvmetadatasize",
diff --git a/tools/pvdisplay.c b/tools/pvdisplay.c
index ff4d121a..2bb74ea4 100644
--- a/tools/pvdisplay.c
+++ b/tools/pvdisplay.c
@@ -20,10 +20,9 @@
#include "tools.h"
-void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv,
- void *handle)
+int pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, void *handle)
{
- char *sz;
uint64_t size;
const char *pv_name = dev_name(pv->dev);
@@ -34,67 +33,56 @@ void pvdisplay_single(struct cmd_context *cmd, struct physical_volume *pv,
size = (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
if (arg_count(cmd, short_ARG)) {
- sz = display_size(size / 2, SIZE_SHORT);
- log_print("Device \"%s\" has a capacity of %s", pv_name, sz);
- dbg_free(sz);
- return;
+ log_print("Device \"%s\" has a capacity of %s", pv_name,
+ display_size(cmd, size / 2, SIZE_SHORT));
+ return 0;
}
if (pv->status & EXPORTED_VG)
log_print("Physical volume \"%s\" of volume group \"%s\" "
"is exported", pv_name, pv->vg_name);
- if (!pv->vg_name) {
+ if (!pv->vg_name)
log_print("\"%s\" is a new physical volume of \"%s\"",
- pv_name, (sz = display_size(size / 2, SIZE_SHORT)));
- dbg_free(sz);
- }
+ pv_name, display_size(cmd, size / 2, SIZE_SHORT));
if (arg_count(cmd, colon_ARG)) {
pvdisplay_colons(pv);
- return;
+ return 0;
}
- pvdisplay_full(pv, handle);
+ pvdisplay_full(cmd, pv, handle);
if (!arg_count(cmd, maps_ARG))
- return;
+ return 0;
- return;
+ return 0;
}
int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
{
- int opt = 0;
-
- struct list *pvh, *pvs;
- struct physical_volume *pv;
+ if (arg_count(cmd, columns_ARG)) {
+ if (arg_count(cmd, colon_ARG) || arg_count(cmd, maps_ARG) ||
+ arg_count(cmd, short_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
+ return pvs(cmd, argc, argv);
+ } else if (arg_count(cmd, aligned_ARG) ||
+ arg_count(cmd, noheadings_ARG) ||
+ arg_count(cmd, options_ARG) ||
+ arg_count(cmd, separator_ARG) ||
+ arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
if (arg_count(cmd, colon_ARG) && arg_count(cmd, maps_ARG)) {
log_error("Option -v not allowed with option -c");
return EINVALID_CMD_LINE;
}
- if (argc) {
- log_very_verbose("Using physical volume(s) on command line");
-
- for (; opt < argc; opt++) {
- if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
- log_error("Failed to read physical "
- "volume \"%s\"", argv[opt]);
- continue;
- }
- pvdisplay_single(cmd, pv, NULL);
- }
- } else {
- log_verbose("Scanning for physical volume names");
- if (!(pvs = get_pvs(cmd)))
- return ECMD_FAILED;
-
- list_iterate(pvh, pvs)
- pvdisplay_single(cmd, list_item(pvh, struct pv_list)->pv,
- NULL);
- }
+ process_each_pv(cmd, argc, argv, NULL, NULL, pvdisplay_single);
return 0;
}
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 3f3b2f1b..395a245a 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -29,8 +29,6 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
char uuid[64];
int vg_name_len = 0;
- char *s1, *s2;
-
char pv_tmp_name[NAME_LEN] = { 0, };
char vg_tmp_name[NAME_LEN] = { 0, };
char vg_name_this[NAME_LEN] = { 0, };
@@ -73,8 +71,7 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
pv_max_name_len, pv_tmp_name,
vg_max_name_len, " ",
pv->fmt ? pv->fmt->name : " ",
- (s1 = display_size(pv->size / 2, SIZE_SHORT)));
- dbg_free(s1);
+ display_size(cmd, pv->size / 2, SIZE_SHORT));
return;
}
@@ -83,14 +80,12 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
log_print("PV %-*s is in exported VG %s "
"[%s / %s free]",
pv_max_name_len, pv_tmp_name,
- vg_name_this, (s1 =
- display_size(pv->pe_count *
- pv->pe_size / 2,
- SIZE_SHORT)),
- (s2 = display_size((pv->pe_count - pv->pe_alloc_count)
- * pv->pe_size / 2, SIZE_SHORT)));
- dbg_free(s1);
- dbg_free(s2);
+ vg_name_this,
+ display_size(cmd, pv->pe_count *
+ pv->pe_size / 2,
+ SIZE_SHORT),
+ display_size(cmd, (pv->pe_count - pv->pe_alloc_count)
+ * pv->pe_size / 2, SIZE_SHORT));
return;
}
@@ -99,13 +94,10 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
pv_tmp_name, vg_max_name_len, vg_tmp_name,
pv->fmt ? pv->fmt->name : " ",
- (s1 = display_size(pv->pe_count * pv->pe_size / 2, SIZE_SHORT)),
- (s2 =
- display_size((pv->pe_count - pv->pe_alloc_count) * pv->pe_size /
- 2, SIZE_SHORT)));
- dbg_free(s1);
- dbg_free(s2);
-
+ display_size(cmd, pv->pe_count * pv->pe_size / 2, SIZE_SHORT),
+ display_size(cmd,
+ (pv->pe_count - pv->pe_alloc_count) * pv->pe_size / 2,
+ SIZE_SHORT));
return;
}
@@ -113,7 +105,6 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
{
int new_pvs_found = 0;
int pvs_found = 0;
- char *s1, *s2, *s3;
struct list *pvs;
struct list *pvh;
@@ -205,14 +196,10 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
log_print("Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s]",
pvs_found,
- (s1 = display_size(size_total / 2, SIZE_SHORT)),
+ display_size(cmd, size_total / 2, SIZE_SHORT),
pvs_found - new_pvs_found,
- (s2 =
- display_size((size_total - size_new) / 2, SIZE_SHORT)),
- new_pvs_found, (s3 = display_size(size_new / 2, SIZE_SHORT)));
- dbg_free(s1);
- dbg_free(s2);
- dbg_free(s3);
+ display_size(cmd, (size_total - size_new) / 2, SIZE_SHORT),
+ new_pvs_found, display_size(cmd, size_new / 2, SIZE_SHORT));
return 0;
}
diff --git a/tools/report.c b/tools/report.c
new file mode 100644
index 00000000..21b4afc1
--- /dev/null
+++ b/tools/report.c
@@ -0,0 +1,235 @@
+/*
+ * 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"
+#include "report.h"
+#include "defaults.h"
+
+static int _vgs_single(struct cmd_context *cmd, const char *vg_name,
+ struct volume_group *vg, int consistent, void *handle)
+{
+ if (!vg) {
+ log_error("Volume group %s not found", vg_name);
+ return ECMD_FAILED;
+ }
+
+ if (!report_object(handle, vg, NULL, NULL, NULL))
+ return ECMD_FAILED;
+
+ return 0;
+}
+
+static int _lvs_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle)
+{
+ if (!report_object(handle, lv->vg, lv, NULL, NULL))
+ return ECMD_FAILED;
+
+ return 0;
+}
+
+static int _segs_single(struct cmd_context *cmd, struct lv_segment *seg,
+ void *handle)
+{
+ if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg))
+ return ECMD_FAILED;
+
+ return 0;
+}
+
+static int _lvsegs_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle)
+{
+ return process_each_segment_in_lv(cmd, lv, handle, _segs_single);
+}
+
+static int _pvs_single(struct cmd_context *cmd, struct volume_group *vg,
+ struct physical_volume *pv, void *handle)
+{
+ int consistent = 0;
+
+ if (!lock_vol(cmd, pv->vg_name, LCK_VG_READ)) {
+ log_error("Can't lock %s: skipping", pv->vg_name);
+ return 0;
+ }
+ vg = vg_read(cmd, pv->vg_name, &consistent);
+
+ if (!report_object(handle, vg, NULL, pv, NULL))
+ return ECMD_FAILED;
+
+ unlock_vg(cmd, pv->vg_name);
+
+ return 0;
+}
+
+static int _report(struct cmd_context *cmd, int argc, char **argv,
+ report_type_t report_type)
+{
+ void *report_handle;
+ char *opts, *str;
+ const char *keys, *options, *separator;
+
+ int aligned, buffered, headings;
+
+ aligned = find_config_int(cmd->cf->root, "report/aligned", '/',
+ DEFAULT_REP_ALIGNED);
+ buffered = find_config_int(cmd->cf->root, "report/buffered", '/',
+ DEFAULT_REP_BUFFERED);
+ headings = find_config_int(cmd->cf->root, "report/headings", '/',
+ DEFAULT_REP_HEADINGS);
+ separator = find_config_str(cmd->cf->root, "report/separator", '/',
+ DEFAULT_REP_SEPARATOR);
+
+ switch (report_type) {
+ case LVS:
+ keys = find_config_str(cmd->cf->root, "report/lvs_sort", '/',
+ DEFAULT_LVS_SORT);
+ if (!arg_count(cmd, verbose_ARG))
+ options = find_config_str(cmd->cf->root,
+ "report/lvs_cols", '/',
+ DEFAULT_LVS_COLS);
+ else
+ options = find_config_str(cmd->cf->root,
+ "report/lvs_cols_verbose",
+ '/', DEFAULT_LVS_COLS_VERB);
+ break;
+ case VGS:
+ keys = find_config_str(cmd->cf->root, "report/vgs_sort", '/',
+ DEFAULT_VGS_SORT);
+ if (!arg_count(cmd, verbose_ARG))
+ options = find_config_str(cmd->cf->root,
+ "report/vgs_cols", '/',
+ DEFAULT_VGS_COLS);
+ else
+ options = find_config_str(cmd->cf->root,
+ "report/vgs_cols_verbose",
+ '/', DEFAULT_VGS_COLS_VERB);
+ break;
+ case PVS:
+ keys = find_config_str(cmd->cf->root, "report/pvs_sort", '/',
+ DEFAULT_PVS_SORT);
+ if (!arg_count(cmd, verbose_ARG))
+ options = find_config_str(cmd->cf->root,
+ "report/pvs_cols", '/',
+ DEFAULT_PVS_COLS);
+ else
+ options = find_config_str(cmd->cf->root,
+ "report/pvs_cols_verbose",
+ '/', DEFAULT_PVS_COLS_VERB);
+ break;
+ case SEGS:
+ keys = find_config_str(cmd->cf->root, "report/segs_sort", '/',
+ DEFAULT_SEGS_SORT);
+ if (!arg_count(cmd, verbose_ARG))
+ options = find_config_str(cmd->cf->root,
+ "report/segs_cols", '/',
+ DEFAULT_SEGS_COLS);
+ else
+ options = find_config_str(cmd->cf->root,
+ "report/segs_cols_verbose",
+ '/', DEFAULT_SEGS_COLS_VERB);
+ break;
+ }
+
+ /* If -o supplied use it, else use default for report_type */
+ if (arg_count(cmd, options_ARG)) {
+ opts = arg_str_value(cmd, options_ARG, "");
+ if (!opts || !*opts) {
+ log_error("Invalid options string: %s", opts);
+ return 0;
+ }
+ if (*opts == '+') {
+ *opts = ',';
+ str =
+ pool_alloc(cmd->mem,
+ strlen(options) + strlen(opts) + 1);
+ strcpy(str, options);
+ strcat(str, opts);
+ options = str;
+ } else
+ options = opts;
+ }
+
+ /* -O overrides default sort settings */
+ if (arg_count(cmd, sort_ARG))
+ keys = arg_str_value(cmd, sort_ARG, "");
+
+ if (arg_count(cmd, separator_ARG))
+ separator = arg_str_value(cmd, separator_ARG, " ");
+ if (arg_count(cmd, separator_ARG))
+ aligned = 0;
+ if (arg_count(cmd, aligned_ARG))
+ aligned = 1;
+ if (arg_count(cmd, unbuffered_ARG) && !arg_count(cmd, sort_ARG))
+ buffered = 0;
+ if (arg_count(cmd, noheadings_ARG))
+ headings = 0;
+
+ if (!(report_handle = report_init(cmd, options, keys, &report_type,
+ separator, aligned, buffered,
+ headings)))
+ return 0;
+
+ switch (report_type) {
+ case LVS:
+ process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
+ &_lvs_single);
+ break;
+ case VGS:
+ process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, report_handle,
+ &_vgs_single);
+ break;
+ case PVS:
+ process_each_pv(cmd, argc, argv, NULL, report_handle,
+ &_pvs_single);
+ break;
+ case SEGS:
+ process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle,
+ &_lvsegs_single);
+ break;
+ }
+
+ report_output(report_handle);
+
+ report_free(report_handle);
+ return ECMD_PROCESSED;
+}
+
+int lvs(struct cmd_context *cmd, int argc, char **argv)
+{
+ report_type_t type;
+
+ if (arg_count(cmd, segments_ARG))
+ type = SEGS;
+ else
+ type = LVS;
+
+ return _report(cmd, argc, argv, type);
+}
+
+int vgs(struct cmd_context *cmd, int argc, char **argv)
+{
+ return _report(cmd, argc, argv, VGS);
+}
+
+int pvs(struct cmd_context *cmd, int argc, char **argv)
+{
+ return _report(cmd, argc, argv, PVS);
+}
diff --git a/tools/toollib.c b/tools/toollib.c
index 917b4ff0..80d0fbee 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -202,6 +202,28 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
return ret_max;
}
+int process_each_segment_in_lv(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ void *handle,
+ int (*process_single) (struct cmd_context * cmd,
+ struct lv_segment * seg,
+ void *handle))
+{
+ struct list *segh;
+ struct lv_segment *seg;
+ int ret_max = 0;
+ int ret;
+
+ list_iterate(segh, &lv->segments) {
+ seg = list_item(segh, struct lv_segment);
+ ret = process_single(cmd, seg, handle);
+ if (ret > ret_max)
+ ret_max = ret;
+ }
+
+ return ret_max;
+}
+
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int lock_type, int consistent, void *handle,
int (*process_single) (struct cmd_context * cmd,
@@ -303,23 +325,50 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
int ret = 0;
struct pv_list *pvl;
+ struct physical_volume *pv;
+ struct list *pvs, *pvh;
if (argc) {
log_verbose("Using physical volume(s) on command line");
for (; opt < argc; opt++) {
- if (!(pvl = find_pv_in_vg(vg, argv[opt]))) {
- log_error("Physical Volume \"%s\" not found in "
- "Volume Group \"%s\"", argv[opt],
- vg->name);
- continue;
+ if (vg) {
+ if (!(pvl = find_pv_in_vg(vg, argv[opt]))) {
+ log_error("Physical Volume \"%s\" not "
+ "found in Volume Group "
+ "\"%s\"", argv[opt],
+ vg->name);
+ continue;
+ }
+ pv = pvl->pv;
+ } else {
+ if (!(pv = pv_read(cmd, argv[opt], NULL, NULL))) {
+ log_error("Failed to read physical "
+ "volume \"%s\"", argv[opt]);
+ continue;
+ }
}
- ret = process_single(cmd, vg, pvl->pv, handle);
+
+ ret = process_single(cmd, vg, pv, handle);
if (ret > ret_max)
ret_max = ret;
}
} else {
- log_verbose("Using all physical volume(s) in volume group");
- process_each_pv_in_vg(cmd, vg, handle, process_single);
+ if (vg) {
+ log_verbose("Using all physical volume(s) in "
+ "volume group");
+ process_each_pv_in_vg(cmd, vg, handle, process_single);
+ } else {
+ log_verbose("Scanning for physical volume names");
+ if (!(pvs = get_pvs(cmd)))
+ return ECMD_FAILED;
+
+ list_iterate(pvh, pvs) {
+ pv = list_item(pvh, struct pv_list)->pv;
+ ret = process_single(cmd, NULL, pv, handle);
+ if (ret > ret_max)
+ ret_max = ret;
+ }
+ }
}
return ret_max;
diff --git a/tools/toollib.h b/tools/toollib.h
index 8b5ef7ed..9390ff3e 100644
--- a/tools/toollib.h
+++ b/tools/toollib.h
@@ -35,10 +35,9 @@ struct volume_group *recover_vg(struct cmd_context *cmd, const char *vgname,
int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
int lock_type, int consistent, void *handle,
int (*process_single) (struct cmd_context * cmd,
- const char *vg_name,
- struct volume_group *vg,
- int consistent,
- void *handle));
+ const char *vg_name,
+ struct volume_group * vg,
+ int consistent, void *handle));
int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
struct volume_group *vg, void *handle,
@@ -53,6 +52,12 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
struct logical_volume * lv,
void *handle));
+int process_each_segment_in_lv(struct cmd_context *cmd,
+ struct logical_volume *lv, void *handle,
+ int (*process_single) (struct cmd_context * cmd,
+ struct lv_segment * seg,
+ void *handle));
+
int process_each_pv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
void *handle,
int (*process_single) (struct cmd_context * cmd,
diff --git a/tools/tools.h b/tools/tools.h
index 9a16b6c4..7e5fc9b7 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -74,7 +74,8 @@ struct arg {
int count;
char *value;
uint32_t i_value;
- uint64_t i64_value;
+ int64_t i64_value;
+ uint64_t ui64_value;
sign_t sign;
void *ptr;
};
@@ -102,6 +103,7 @@ int minor_arg(struct cmd_context *cmd, struct arg *a);
int string_arg(struct cmd_context *cmd, struct arg *a);
int permission_arg(struct cmd_context *cmd, struct arg *a);
int metadatatype_arg(struct cmd_context *cmd, struct arg *a);
+int units_arg(struct cmd_context *cmd, struct arg *a);
char yes_no_prompt(const char *prompt, ...);
@@ -127,12 +129,18 @@ static inline uint32_t arg_int_value(struct cmd_context *cmd, int a,
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
}
-static inline uint64_t arg_int64_value(struct cmd_context *cmd, int a,
- uint64_t def)
+static inline int64_t arg_int64_value(struct cmd_context *cmd, int a,
+ uint64_t def)
{
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
}
+static inline uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
+ uint64_t def)
+{
+ return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
+}
+
static inline void *arg_ptr_value(struct cmd_context *cmd, int a, void *def)
{
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
diff --git a/tools/vgck.c b/tools/vgck.c
index 6a6eb1ec..5cd9a858 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -38,7 +38,6 @@ static int vgck_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- /* FIXME: free */
return 0;
}
diff --git a/tools/vgconvert.c b/tools/vgconvert.c
index 59043af7..5116b382 100644
--- a/tools/vgconvert.c
+++ b/tools/vgconvert.c
@@ -63,7 +63,7 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
}
if (cmd->fmt->features & FMT_MDAS) {
- pvmetadatasize = arg_int64_value(cmd, metadatasize_ARG, 0) * 2;
+ pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
if (!pvmetadatasize)
pvmetadatasize =
find_config_int(cmd->cf->root,
diff --git a/tools/vgdisplay.c b/tools/vgdisplay.c
index 72bc3b38..7a4e4bed 100644
--- a/tools/vgdisplay.c
+++ b/tools/vgdisplay.c
@@ -62,6 +62,23 @@ static int vgdisplay_single(struct cmd_context *cmd, const char *vg_name,
int vgdisplay(struct cmd_context *cmd, int argc, char **argv)
{
+ if (arg_count(cmd, columns_ARG)) {
+ if (arg_count(cmd, colon_ARG) ||
+ arg_count(cmd, activevolumegroups_ARG) ||
+ arg_count(cmd, short_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
+ return vgs(cmd, argc, argv);
+ } else if (arg_count(cmd, aligned_ARG) ||
+ arg_count(cmd, noheadings_ARG) ||
+ arg_count(cmd, options_ARG) ||
+ arg_count(cmd, separator_ARG) ||
+ arg_count(cmd, sort_ARG) || arg_count(cmd, unbuffered_ARG)) {
+ log_error("Incompatible options selected");
+ return EINVALID_CMD_LINE;
+ }
+
if (arg_count(cmd, colon_ARG) && arg_count(cmd, short_ARG)) {
log_error("Option -c is not allowed with option -s");
return EINVALID_CMD_LINE;