lscpu: support +list for -e, -p and -C
For example "lscpu -e=+MHZ" to list the default columns and MHZ. We use the same in other tools. Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
0b83e26373
commit
1242c3fde7
|
@ -130,6 +130,9 @@ are included in the command output.
|
|||
When specifying the \fIlist\fP argument, the string of option, equal sign (=), and
|
||||
\fIlist\fP must not contain any blanks or other whitespace.
|
||||
Examples: '\fB\-C=NAME,ONE-SIZE\fP' or '\fB\-\-caches=NAME,ONE-SIZE\fP'.
|
||||
|
||||
The default list of columns may be extended if list is specified in the format +list
|
||||
(e.g., lscpu -C=+ALLOC-POLICY).
|
||||
.TP
|
||||
.BR \-c , " \-\-offline"
|
||||
Limit the output to offline CPUs.
|
||||
|
@ -144,6 +147,9 @@ are included in the command output.
|
|||
When specifying the \fIlist\fP argument, the string of option, equal sign (=), and
|
||||
\fIlist\fP must not contain any blanks or other whitespace.
|
||||
Examples: '\fB\-e=cpu,node\fP' or '\fB\-\-extended=cpu,node\fP'.
|
||||
|
||||
The default list of columns may be extended if list is specified in the format +list
|
||||
(e.g., lscpu -e=+MHZ).
|
||||
.TP
|
||||
.BR \-h , " \-\-help"
|
||||
Display help text and exit.
|
||||
|
@ -163,6 +169,9 @@ If the \fIlist\fP argument is used, cache columns are separated with a colon (:)
|
|||
When specifying the \fIlist\fP argument, the string of option, equal sign (=), and
|
||||
\fIlist\fP must not contain any blanks or other whitespace.
|
||||
Examples: '\fB\-p=cpu,node\fP' or '\fB\-\-parse=cpu,node\fP'.
|
||||
|
||||
The default list of columns may be extended if list is specified in the format +list
|
||||
(e.g., lscpu -p=+MHZ).
|
||||
.TP
|
||||
.BR \-s , " \-\-sysroot " \fIdirectory\fP
|
||||
Gather CPU data for a Linux instance other than the instance from which the
|
||||
|
|
|
@ -1163,6 +1163,7 @@ int main(int argc, char *argv[])
|
|||
int c, all = 0;
|
||||
int columns[ARRAY_SIZE(coldescs_cpu)], ncolumns = 0;
|
||||
int cpu_modifier_specified = 0;
|
||||
char *outarg = NULL;
|
||||
size_t i;
|
||||
enum {
|
||||
OPT_OUTPUT_ALL = CHAR_MAX + 1,
|
||||
|
@ -1223,11 +1224,7 @@ int main(int argc, char *argv[])
|
|||
if (optarg) {
|
||||
if (*optarg == '=')
|
||||
optarg++;
|
||||
ncolumns = string_to_idarray(optarg,
|
||||
columns, ARRAY_SIZE(columns),
|
||||
cache_column_name_to_id);
|
||||
if (ncolumns < 0)
|
||||
return EXIT_FAILURE;
|
||||
outarg = optarg;
|
||||
}
|
||||
cxt->mode = LSCPU_OUTPUT_CACHES;
|
||||
break;
|
||||
|
@ -1239,11 +1236,7 @@ int main(int argc, char *argv[])
|
|||
if (optarg) {
|
||||
if (*optarg == '=')
|
||||
optarg++;
|
||||
ncolumns = string_to_idarray(optarg,
|
||||
columns, ARRAY_SIZE(columns),
|
||||
cpu_column_name_to_id);
|
||||
if (ncolumns < 0)
|
||||
return EXIT_FAILURE;
|
||||
outarg = optarg;
|
||||
}
|
||||
cxt->mode = c == 'p' ? LSCPU_OUTPUT_PARSABLE : LSCPU_OUTPUT_READABLE;
|
||||
break;
|
||||
|
@ -1333,6 +1326,11 @@ int main(int argc, char *argv[])
|
|||
columns[ncolumns++] = COL_CACHE_PHYLINE;
|
||||
columns[ncolumns++] = COL_CACHE_COHERENCYSIZE;
|
||||
}
|
||||
if (outarg && string_add_to_idarray(outarg, columns,
|
||||
ARRAY_SIZE(columns),
|
||||
&ncolumns, cache_column_name_to_id) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
print_caches_readable(cxt, columns, ncolumns);
|
||||
break;
|
||||
case LSCPU_OUTPUT_READABLE:
|
||||
|
@ -1370,6 +1368,10 @@ int main(int argc, char *argv[])
|
|||
columns[ncolumns++] = COL_CPU_MINMHZ;
|
||||
}
|
||||
}
|
||||
if (outarg && string_add_to_idarray(outarg, columns,
|
||||
ARRAY_SIZE(columns),
|
||||
&ncolumns, cpu_column_name_to_id) < 0)
|
||||
return EXIT_FAILURE;
|
||||
print_cpus_readable(cxt, columns, ncolumns);
|
||||
break;
|
||||
case LSCPU_OUTPUT_PARSABLE:
|
||||
|
@ -1384,6 +1386,11 @@ int main(int argc, char *argv[])
|
|||
columns[ncolumns++] = COL_CPU_CACHE;
|
||||
cxt->show_compatible = 1;
|
||||
}
|
||||
if (outarg && string_add_to_idarray(outarg, columns,
|
||||
ARRAY_SIZE(columns),
|
||||
&ncolumns, cpu_column_name_to_id) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
print_cpus_parsable(cxt, columns, ncolumns);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue