1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Add --prefixes to reporting tools for field name prefix output format.

E.g. lvs --prefixes --noheadings --unbuffered --units m --nosuffix

(Used '--prefixes' for now, but I'm looking for a better name.)
This commit is contained in:
Alasdair Kergon 2008-04-20 00:15:08 +00:00
parent c791f186ce
commit f419a87150
7 changed files with 36 additions and 13 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.36 -
=================================
Add --prefixes to reporting tools for field name prefix output format.
Fix lvconvert -m0 allocatable space check.
Version 2.02.35 - 15th April 2008

View File

@ -102,6 +102,7 @@
#define DEFAULT_REP_ALIGNED 1
#define DEFAULT_REP_BUFFERED 1
#define DEFAULT_REP_HEADINGS 1
#define DEFAULT_REP_PREFIXES 0
#define DEFAULT_REP_SEPARATOR " "
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,mirror_log,copy_percent,convert_lv"

View File

@ -386,7 +386,7 @@ static int _pvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_
const uint32_t status = *(const uint32_t *) data;
char *repstr;
if (!(repstr = dm_pool_zalloc(mem, 4))) {
if (!(repstr = dm_pool_zalloc(mem, 3))) {
log_error("dm_pool_alloc failed");
return 0;
}
@ -1077,9 +1077,10 @@ static struct dm_report_field_type _fields[] = {
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
report_type_t *report_type, const char *separator,
int aligned, int buffered, int headings)
int aligned, int buffered, int headings, int field_prefixes)
{
uint32_t report_flags = 0;
void *rh;
if (aligned)
report_flags |= DM_REPORT_OUTPUT_ALIGNED;
@ -1090,8 +1091,16 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
if (headings)
report_flags |= DM_REPORT_OUTPUT_HEADINGS;
return dm_report_init(report_type, _report_types, _fields, format,
separator, report_flags, keys, cmd);
if (field_prefixes)
report_flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
rh = dm_report_init(report_type, _report_types, _fields, format,
separator, report_flags, keys, cmd);
if (field_prefixes)
dm_report_set_output_field_name_prefix(rh, "lvm2_");
return rh;
}
/*

View File

@ -28,7 +28,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,
report_type_t *report_type, const char *separator,
int aligned, int buffered, int headings);
int aligned, int buffered, int headings, int field_prefixes);
void report_free(void *handle);
int report_object(void *handle, struct volume_group *vg,
struct logical_volume *lv, struct physical_volume *pv,

View File

@ -53,6 +53,7 @@ arg(monitor_ARG, '\0', "monitor", yes_no_arg, 0)
arg(config_ARG, '\0', "config", string_arg, 0)
arg(trustcache_ARG, '\0', "trustcache", NULL, 0)
arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0)
arg(prefixes_ARG, '\0', "prefixes", NULL, 0)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)

View File

@ -368,6 +368,7 @@ xx(lvs,
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
"\t[-P|--partial] " "\n"
"\t[--prefixes]\n"
"\t[--segments]\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
@ -378,8 +379,9 @@ xx(lvs,
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG,
segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG,
units_ARG)
xx(lvscan,
"List all logical volumes in all volume groups",
@ -575,6 +577,7 @@ xx(pvs,
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
"\t[-P|--partial] " "\n"
"\t[--prefixes]\n"
"\t[--segments]\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
@ -585,8 +588,9 @@ xx(pvs,
"\t[PhysicalVolume [PhysicalVolume...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG,
segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG,
units_ARG)
xx(pvscan,
"List all physical volumes",
@ -890,6 +894,7 @@ xx(vgs,
"\t[-o|--options [+]Field[,Field]]\n"
"\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n"
"\t[-P|--partial] " "\n"
"\t[--prefixes]\n"
"\t[--separator Separator]\n"
"\t[--trustcache]\n"
"\t[--unbuffered]\n"
@ -899,8 +904,8 @@ xx(vgs,
"\t[VolumeGroupName [VolumeGroupName...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG,
sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG,
separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG)
xx(vgscan,
"Search for all volume groups",

View File

@ -158,7 +158,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
char *str;
const char *keys = NULL, *options = NULL, *separator;
int r = ECMD_PROCESSED;
int aligned, buffered, headings;
int aligned, buffered, headings, field_prefixes;
unsigned args_are_pvs;
aligned = find_config_tree_int(cmd, "report/aligned",
@ -169,6 +169,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
DEFAULT_REP_HEADINGS);
separator = find_config_tree_str(cmd, "report/separator",
DEFAULT_REP_SEPARATOR);
field_prefixes = find_config_tree_int(cmd, "report/prefixes",
DEFAULT_REP_PREFIXES);
args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0;
@ -270,10 +272,14 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
buffered = 0;
if (arg_count(cmd, noheadings_ARG))
headings = 0;
if (arg_count(cmd, prefixes_ARG)) {
aligned = 0;
field_prefixes = 1;
}
if (!(report_handle = report_init(cmd, options, keys, &report_type,
separator, aligned, buffered,
headings))) {
headings, field_prefixes))) {
stack;
return ECMD_FAILED;
}