Add support for reporting column identifiers instead of names in report headings

This adds DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS flag to libdevmapper's report code. If it is used for dm_report_init or dm_report_init_with_selection, it will cause the reporting code to print column identifiers instead of abbreviated names. That means, using the id member of the struct dm_report_field_type instead of the heading member (the struct dm_report_field_type *fields is an array defining the fields/columns when calling dm report init). These IDs are unambiguous, they are always without spaces (one word) and this makes it easier to match the headers in the report output with the set of columns that were requested for the report.

On LVM tools side, we have a new --headings none|abbrev|full comannd line option that can be used together with reporting commands (lvs, pvs, vgs...). Also, there's accompanying report/headings lvm.conf option, which already exists and for which we can now use new value "2" to denote "full" (note: 0 == none, 1 == abbrev).

On dmsetup tool side, we have a new --headings none|abbrev|full command line option.

We're keeping the default to abbrev (or 1), which is the abbreviated form of the column name as we used before, so we're not changing this default.

I've also added a few lines to the man lvmreport.

Example:

# lvs -o+seg_start,seg_start_pe
  LV    VG LSize Cpy%Sync Start Start
  lvol0 vg 4.00m             0      0
  lvol1 vg 4.00m 100.00      0      0

# lvs --headings full -o+seg_start,seg_start_pe
  lv_name vg_name lv_size copy_percent seg_start seg_start_pe
  lvol0   vg        4.00m                     0             0
  lvol1   vg        4.00m 100.00              0             0

Initiated by: https://bugzilla.redhat.com/show_bug.cgi?id=2233336 Related discussion: https://listman.redhat.com/archives/linux-lvm/2023-August/026389.html

Edited by Peter Rajnoha

Merge request reports

Loading