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

libdm: add dm_report_column_headings

Add a function to print column headings regardless of whether they
have already been output. This will be used by dmstats to issue
periodic reminders of the column headings.

This patch removes a check for RH_HEADINGS_PRINTED from
_report_headings that prevents headings being displayed if the flag
is already set; this check is redundant since the only existing
caller (_output_as_columns()) already tests the flag before
calling the function.
This commit is contained in:
Bryn M. Reeves 2015-08-07 18:11:23 +01:00
parent cafe145ba2
commit 666c77c0f2
4 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,4 @@
dm_report_column_headings
dm_report_get_interval_ms
dm_report_get_interval_ns
dm_report_set_interval_ms

View File

@ -1896,6 +1896,14 @@ int dm_report_object_is_selected(struct dm_report *rh, void *object, int do_outp
int dm_report_compact_fields(struct dm_report *rh);
int dm_report_output(struct dm_report *rh);
/*
* Output the report headings for a columns-based report, even if they
* have already been shown. Useful for repeating reports that wish to
* issue a periodic reminder of the column headings.
*/
int dm_report_column_headings(struct dm_report *rh);
void dm_report_free(struct dm_report *rh);
/*

View File

@ -3922,9 +3922,6 @@ static int _report_headings(struct dm_report *rh)
char *buf = NULL;
size_t buf_size = 0;
if (rh->flags & RH_HEADINGS_PRINTED)
return 1;
rh->flags |= RH_HEADINGS_PRINTED;
if (!(rh->flags & DM_REPORT_OUTPUT_HEADINGS))
@ -3997,6 +3994,11 @@ static int _report_headings(struct dm_report *rh)
return 0;
}
int dm_report_column_headings(struct dm_report *rh)
{
return _report_headings(rh);
}
/*
* Sort rows of data
*/

View File

@ -3970,6 +3970,8 @@ doit:
r = _perform_command_for_all_repeatable_args(cmd, subcommand, argc, argv, NULL, multiple_devices);
if (_report) {
if (_count > 1)
dm_report_column_headings(_report);
dm_report_output(_report);
if (_count > 1) {