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

conf: add report/mark_invisible_devices

This commit is contained in:
Peter Rajnoha 2016-01-13 11:30:07 +01:00
parent 7f74a99502
commit e168b5de75
5 changed files with 15 additions and 8 deletions

View File

@ -478,6 +478,7 @@ int process_profilable_config(struct cmd_context *cmd)
cmd->si_unit_consistency = find_config_tree_bool(cmd, global_si_unit_consistency_CFG, NULL);
cmd->report_binary_values_as_numeric = find_config_tree_bool(cmd, report_binary_values_as_numeric_CFG, NULL);
cmd->report_mark_invisible_devices = find_config_tree_bool(cmd, report_mark_invisible_devices_CFG, NULL);
cmd->default_settings.suffix = find_config_tree_bool(cmd, global_suffix_CFG, NULL);
cmd->report_list_item_separator = find_config_tree_str(cmd, report_list_item_separator_CFG, NULL);
if (!(cmd->time_format = _set_time_format(cmd)))

View File

@ -121,6 +121,7 @@ struct cmd_context {
unsigned auto_set_activation_skip:1;
unsigned si_unit_consistency:1;
unsigned report_binary_values_as_numeric:1;
unsigned report_mark_invisible_devices:1;
unsigned metadata_read_only:1;
unsigned ignore_clustered_vgs:1;
unsigned threaded:1; /* set if running within a thread e.g. clvmd */

View File

@ -1671,6 +1671,9 @@ cfg(report_pvsegs_cols_verbose_CFG, "pvsegs_cols_verbose", report_CFG_SECTION, C
"List of columns to sort by when reporting 'pvs --segments' command in verbose mode.\n"
"See 'pvs --segments -o help' for the list of possible fields.\n")
cfg(report_mark_invisible_devices_CFG, "mark_invisible_devices", report_CFG_SECTION, CFG_PROFILABLE | CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 2, 140), NULL, 0, NULL,
"Use brackets [] to mark invisible devices.\n")
cfg(dmeventd_mirror_library_CFG, "mirror_library", dmeventd_CFG_SECTION, 0, CFG_TYPE_STRING, DEFAULT_DMEVENTD_MIRROR_LIB, vsn(1, 2, 3), NULL, 0, NULL,
"The library dmeventd uses when monitoring a mirror device.\n"
"libdevmapper-event-lvm2mirror.so attempts to recover from\n"

View File

@ -29,7 +29,8 @@ static struct utsname _utsname;
static int _utsinit = 0;
static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
int range_format, int metadata_areas_only)
int range_format, int metadata_areas_only,
int mark_invisible)
{
static const char pool_grow_object_failed_msg[] = "dm_pool_grow_object failed";
unsigned int s;
@ -71,7 +72,7 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
if (!visible && !dm_pool_grow_object(mem, "[", 1)) {
if (!visible && mark_invisible && !dm_pool_grow_object(mem, "[", 1)) {
log_error(pool_grow_object_failed_msg);
return NULL;
}
@ -81,7 +82,7 @@ static char *_format_pvsegs(struct dm_pool *mem, const struct lv_segment *seg,
return NULL;
}
if (!visible && !dm_pool_grow_object(mem, "]", 1)) {
if (!visible && mark_invisible && !dm_pool_grow_object(mem, "]", 1)) {
log_error(pool_grow_object_failed_msg);
return NULL;
}
@ -128,22 +129,22 @@ out:
char *lvseg_devices(struct dm_pool *mem, const struct lv_segment *seg)
{
return _format_pvsegs(mem, seg, 0, 0);
return _format_pvsegs(mem, seg, 0, 0, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_metadata_devices(struct dm_pool *mem, const struct lv_segment *seg)
{
return _format_pvsegs(mem, seg, 0, 1);
return _format_pvsegs(mem, seg, 0, 1, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_seg_pe_ranges(struct dm_pool *mem, const struct lv_segment *seg)
{
return _format_pvsegs(mem, seg, 1, 0);
return _format_pvsegs(mem, seg, 1, 0, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_seg_metadata_le_ranges(struct dm_pool *mem, const struct lv_segment *seg)
{
return _format_pvsegs(mem, seg, 1, 1);
return _format_pvsegs(mem, seg, 1, 1, seg->lv->vg->cmd->report_mark_invisible_devices);
}
char *lvseg_tags_dup(const struct lv_segment *seg)

View File

@ -1581,11 +1581,12 @@ static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
{
struct cmd_context *cmd = (struct cmd_context *) private;
const struct logical_volume *lv = (const struct logical_volume *) data;
char *repstr, *lvname;
size_t len;
if (lv_is_visible(lv))
if (lv_is_visible(lv) || !cmd->report_mark_invisible_devices)
return _string_disp(rh, mem, field, &lv->name, private);
len = strlen(lv->name) + 3;