mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
dmsetup: support printing full column names in report headings
Add '--headings none|abbrev|full|0|1|2' command line option to select the heading type. none|0 - no headings abbrev|1 - column name abbreviations full|2 - full column names (column names are equal to exact names that -o|--options also accepts to set report output)
This commit is contained in:
parent
14d0a9eef6
commit
5a1248f1d4
@ -1,5 +1,6 @@
|
||||
Version 1.02.197 -
|
||||
===================================
|
||||
Add dmsetup --headings none|abbrev|full to set report headings type.
|
||||
Add DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS to provide alternative headings.
|
||||
|
||||
Version 1.02.196 - 02nd August 2023
|
||||
|
@ -178,6 +178,7 @@ enum {
|
||||
GID_ARG,
|
||||
GROUP_ARG,
|
||||
GROUP_ID_ARG,
|
||||
HEADINGS_ARG,
|
||||
HELP_ARG,
|
||||
HISTOGRAM_ARG,
|
||||
INACTIVE_ARG,
|
||||
@ -4775,6 +4776,11 @@ static int _report_init(const struct command *cmd, const char *subcommand)
|
||||
_report_type |= DR_STATS_META;
|
||||
}
|
||||
|
||||
if (_switches[NOHEADINGS_ARG] && _switches[HEADINGS_ARG]) {
|
||||
log_error("Only one of --headings and --noheadings permitted.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* emulate old dmsetup behaviour */
|
||||
if (_switches[NOHEADINGS_ARG]) {
|
||||
separator = ":";
|
||||
@ -4782,6 +4788,9 @@ static int _report_init(const struct command *cmd, const char *subcommand)
|
||||
headings = 0;
|
||||
}
|
||||
|
||||
if (_switches[HEADINGS_ARG])
|
||||
headings = _int_args[HEADINGS_ARG];
|
||||
|
||||
if (_switches[UNBUFFERED_ARG])
|
||||
buffered = 0;
|
||||
|
||||
@ -4848,8 +4857,11 @@ static int _report_init(const struct command *cmd, const char *subcommand)
|
||||
if (buffered)
|
||||
flags |= DM_REPORT_OUTPUT_BUFFERED;
|
||||
|
||||
if (headings)
|
||||
if (headings) {
|
||||
flags |= DM_REPORT_OUTPUT_HEADINGS;
|
||||
if (headings == 2)
|
||||
flags |= DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS;
|
||||
}
|
||||
|
||||
if (field_prefixes)
|
||||
flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX;
|
||||
@ -6166,7 +6178,8 @@ static int _stats_help(CMD_ARGS);
|
||||
* [--units <u>] [--programid <id>] [--regionid <id>]
|
||||
* [-o <fields>] [-O|--sort <sort_fields>]
|
||||
* [-S|--select <selection>] [--nameprefixes]
|
||||
* [--noheadings] [--separator <separator>]
|
||||
* [--noheadings|--headings none|abbrev|full|0|1|2]
|
||||
* [--separator <separator>]
|
||||
* [--allprograms|--programid id] [<device>...]
|
||||
* ungroup --groupid <id> [--allprograms|--programid id]
|
||||
* [--alldevices|<device>...]
|
||||
@ -6336,7 +6349,8 @@ static void _dmsetup_usage(FILE *out)
|
||||
" [--udevcookie <cookie>] [--noudevrules] [--noudevsync] [--verifyudev]\n"
|
||||
" [-y|--yes] [--readahead {[+]<sectors>|auto|none}] [--retry]\n"
|
||||
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
|
||||
" [-S|--select <selection>] [--nameprefixes] [--noheadings]\n"
|
||||
" [-S|--select <selection>] [--nameprefixes]\n"
|
||||
" [--noheadings|--headings none|abbrev|full|0|1|2]\n"
|
||||
" [--separator <separator>]\n\n",
|
||||
_base_commands[_base_command].name);
|
||||
|
||||
@ -6866,6 +6880,7 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
||||
{"gid", 1, &ind, GID_ARG},
|
||||
{"group", 0, &ind, GROUP_ARG},
|
||||
{"groupid", 1, &ind, GROUP_ID_ARG},
|
||||
{"headings", 1, &ind, HEADINGS_ARG},
|
||||
{"help", 0, &ind, HELP_ARG},
|
||||
{"histogram", 0, &ind, HISTOGRAM_ARG},
|
||||
{"inactive", 0, &ind, INACTIVE_ARG},
|
||||
@ -7170,6 +7185,19 @@ static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
|
||||
_switches[EXEC_ARG]++;
|
||||
_command_to_exec = optarg;
|
||||
}
|
||||
if (ind == HEADINGS_ARG) {
|
||||
_switches[HEADINGS_ARG]++;
|
||||
if (!strcasecmp(optarg, "none") || !strcmp(optarg, "0"))
|
||||
_int_args[HEADINGS_ARG] = 0;
|
||||
else if (!strcasecmp(optarg, "abbrev") || !strcmp(optarg, "1"))
|
||||
_int_args[HEADINGS_ARG] = 1;
|
||||
else if (!strcasecmp(optarg, "full") || !strcmp(optarg, "2"))
|
||||
_int_args[HEADINGS_ARG] = 2;
|
||||
else {
|
||||
log_error("Unknown headings type.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if (ind == TARGET_ARG) {
|
||||
_switches[TARGET_ARG]++;
|
||||
_target = optarg;
|
||||
|
@ -91,6 +91,7 @@ dmsetup \(em low level logical volume management
|
||||
. IR fields ]
|
||||
. RB [ -O | --sort
|
||||
. IR sort_fields ]
|
||||
. RB [ --idsinheadings ]
|
||||
. RB [ --nameprefixes ]
|
||||
. RB [ --separator
|
||||
. IR separator ]
|
||||
@ -502,6 +503,10 @@ Specify the minor number.
|
||||
When creating a device, don't load any table.
|
||||
.
|
||||
.TP
|
||||
.B --idsinheadings
|
||||
Show column identifiers instead of names in report output headings.
|
||||
.
|
||||
.TP
|
||||
.B --nameprefixes
|
||||
Add a "DM_" prefix plus the field name to the output. Useful with
|
||||
\fB--noheadings\fP to produce a list of
|
||||
|
Loading…
Reference in New Issue
Block a user