1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

report: select: add --select arg to pvs, vgs and lvs

This commit is contained in:
Peter Rajnoha 2014-05-29 09:38:59 +02:00
parent 3a1c7e5d78
commit 5b734a0ea1
5 changed files with 24 additions and 19 deletions

View File

@ -1234,7 +1234,7 @@ static const struct dm_report_field_type _devtypes_fields[] = {
void *report_init(struct cmd_context *cmd, const char *format, const char *keys, void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
report_type_t *report_type, const char *separator, report_type_t *report_type, const char *separator,
int aligned, int buffered, int headings, int field_prefixes, int aligned, int buffered, int headings, int field_prefixes,
int quoted, int columns_as_rows) int quoted, int columns_as_rows, const char *selection)
{ {
uint32_t report_flags = 0; uint32_t report_flags = 0;
int devtypes_report = *report_type & DEVTYPES ? 1 : 0; int devtypes_report = *report_type & DEVTYPES ? 1 : 0;
@ -1258,9 +1258,10 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
if (columns_as_rows) if (columns_as_rows)
report_flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS; report_flags |= DM_REPORT_OUTPUT_COLUMNS_AS_ROWS;
rh = dm_report_init(report_type, devtypes_report ? _devtypes_report_types : _report_types, rh = dm_report_init_with_selection(report_type,
devtypes_report ? _devtypes_fields : _fields, format, devtypes_report ? _devtypes_report_types : _report_types,
separator, report_flags, keys, cmd); devtypes_report ? _devtypes_fields : _fields, format,
separator, report_flags, keys, selection, cmd);
if (rh && field_prefixes) if (rh && field_prefixes)
dm_report_set_output_field_name_prefix(rh, "lvm2_"); dm_report_set_output_field_name_prefix(rh, "lvm2_");

View File

@ -38,7 +38,7 @@ typedef int (*field_report_fn) (struct report_handle * dh, struct field * field,
void *report_init(struct cmd_context *cmd, const char *format, const char *keys, void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
report_type_t *report_type, const char *separator, report_type_t *report_type, const char *separator,
int aligned, int buffered, int headings, int field_prefixes, int aligned, int buffered, int headings, int field_prefixes,
int quoted, int columns_as_rows); int quoted, int columns_as_rows, const char *selection);
void report_free(void *handle); void report_free(void *handle);
int report_object(void *handle, struct volume_group *vg, int report_object(void *handle, struct volume_group *vg,
struct logical_volume *lv, struct physical_volume *pv, struct logical_volume *lv, struct physical_volume *pv,

View File

@ -174,6 +174,7 @@ arg(physicalextentsize_ARG, 's', "physicalextentsize", size_mb_arg, 0)
arg(stdin_ARG, 's', "stdin", NULL, 0) arg(stdin_ARG, 's', "stdin", NULL, 0)
arg(snapshot_ARG, 's', "snapshot", NULL, 0) arg(snapshot_ARG, 's', "snapshot", NULL, 0)
arg(short_ARG, 's', "short", NULL, 0) arg(short_ARG, 's', "short", NULL, 0)
arg(select_ARG, 'S', "select", string_arg, 0)
arg(thin_ARG, 'T', "thin", NULL, 0) arg(thin_ARG, 'T', "thin", NULL, 0)
arg(test_ARG, 't', "test", NULL, 0) arg(test_ARG, 't', "test", NULL, 0)
arg(uuid_ARG, 'u', "uuid", NULL, 0) arg(uuid_ARG, 'u', "uuid", NULL, 0)

View File

@ -574,6 +574,7 @@ xx(lvs,
"\t[--readonly]\n" "\t[--readonly]\n"
"\t[--rows]\n" "\t[--rows]\n"
"\t[--segments]\n" "\t[--segments]\n"
"\t[-S|--select Selection]\n"
"\t[--separator Separator]\n" "\t[--separator Separator]\n"
"\t[--trustcache]\n" "\t[--trustcache]\n"
"\t[--unbuffered]\n" "\t[--unbuffered]\n"
@ -584,11 +585,10 @@ xx(lvs,
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
nameprefixes_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG,
noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, partial_ARG, readonly_ARG, rows_ARG, segments_ARG, select_ARG,
readonly_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG,
rows_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unquoted_ARG)
unbuffered_ARG, units_ARG, unquoted_ARG)
xx(lvscan, xx(lvscan,
"List all logical volumes in all volume groups", "List all logical volumes in all volume groups",
@ -816,6 +816,7 @@ xx(pvs,
"\t[--readonly]\n" "\t[--readonly]\n"
"\t[--rows]\n" "\t[--rows]\n"
"\t[--segments]\n" "\t[--segments]\n"
"\t[-S|--select Selection]\n"
"\t[--separator Separator]\n" "\t[--separator Separator]\n"
"\t[--trustcache]\n" "\t[--trustcache]\n"
"\t[--unbuffered]\n" "\t[--unbuffered]\n"
@ -827,8 +828,8 @@ xx(pvs,
aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG,
partial_ARG, readonly_ARG, rows_ARG, segments_ARG, separator_ARG, sort_ARG, partial_ARG, readonly_ARG, rows_ARG, segments_ARG, select_ARG, separator_ARG,
trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG) sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG)
xx(pvscan, xx(pvscan,
"List all physical volumes", "List all physical volumes",
@ -1202,6 +1203,7 @@ xx(vgs,
"\t[-P|--partial] " "\n" "\t[-P|--partial] " "\n"
"\t[--readonly]\n" "\t[--readonly]\n"
"\t[--rows]\n" "\t[--rows]\n"
"\t[-S|--select Selection]\n"
"\t[--separator Separator]\n" "\t[--separator Separator]\n"
"\t[--trustcache]\n" "\t[--trustcache]\n"
"\t[--unbuffered]\n" "\t[--unbuffered]\n"
@ -1212,11 +1214,9 @@ xx(vgs,
"\t[VolumeGroupName [VolumeGroupName...]]\n", "\t[VolumeGroupName [VolumeGroupName...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, ignoreskippedcluster_ARG,
nameprefixes_ARG, nameprefixes_ARG, noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG,
noheadings_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, partial_ARG, readonly_ARG, rows_ARG, select_ARG, separator_ARG, sort_ARG,
readonly_ARG, trustcache_ARG, unbuffered_ARG, units_ARG, unquoted_ARG)
rows_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG,
unquoted_ARG)
xx(vgscan, xx(vgscan,
"Search for all volume groups", "Search for all volume groups",

View File

@ -235,7 +235,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
void *report_handle; void *report_handle;
const char *opts; const char *opts;
char *str; char *str;
const char *keys = NULL, *options = NULL, *separator; const char *keys = NULL, *options = NULL, *selection = NULL, *separator;
int r = ECMD_PROCESSED; int r = ECMD_PROCESSED;
int aligned, buffered, headings, field_prefixes, quoted; int aligned, buffered, headings, field_prefixes, quoted;
int columns_as_rows; int columns_as_rows;
@ -348,10 +348,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
if (arg_count(cmd, rows_ARG)) if (arg_count(cmd, rows_ARG))
columns_as_rows = 1; columns_as_rows = 1;
if (arg_count(cmd, select_ARG))
selection = arg_str_value(cmd, select_ARG, NULL);
if (!(report_handle = report_init(cmd, options, keys, &report_type, if (!(report_handle = report_init(cmd, options, keys, &report_type,
separator, aligned, buffered, separator, aligned, buffered,
headings, field_prefixes, quoted, headings, field_prefixes, quoted,
columns_as_rows))) { columns_as_rows, selection))) {
if ( (!strcasecmp(options, DM_REPORT_FIELD_RESERVED_NAME_HELP) || if ( (!strcasecmp(options, DM_REPORT_FIELD_RESERVED_NAME_HELP) ||
!strcmp(options, DM_REPORT_FIELD_RESERVED_NAME_HELP_ALT)) || !strcmp(options, DM_REPORT_FIELD_RESERVED_NAME_HELP_ALT)) ||
(!strcasecmp(keys, DM_REPORT_FIELD_RESERVED_NAME_HELP) || (!strcasecmp(keys, DM_REPORT_FIELD_RESERVED_NAME_HELP) ||