summaryrefslogtreecommitdiffstats
path: root/sys-utils/lscpu.c
diff options
context:
space:
mode:
authorHeiko Carstens2012-08-08 10:52:47 +0200
committerKarel Zak2012-08-13 14:42:21 +0200
commit7fc12cd2760f8f2858eef8bd7e170cef9932d26f (patch)
tree0cde5ba79a4cda0cfdf98e84f6dd1ba61ae3e4a7 /sys-utils/lscpu.c
parentlib/tt: always escape '\' to simplify parsing in scripts (diff)
downloadkernel-qcow2-util-linux-7fc12cd2760f8f2858eef8bd7e170cef9932d26f.tar.gz
kernel-qcow2-util-linux-7fc12cd2760f8f2858eef8bd7e170cef9932d26f.tar.xz
kernel-qcow2-util-linux-7fc12cd2760f8f2858eef8bd7e170cef9932d26f.zip
lscpu: limit options --all, --online, --offline to parsable and extended output
Passing the --all, --online or --offline options for the output summary doesn't make much sense. It should be limited to the two list output options. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Diffstat (limited to 'sys-utils/lscpu.c')
-rw-r--r--sys-utils/lscpu.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index b93998a5a..25a027345 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -1243,6 +1243,7 @@ int main(int argc, char *argv[])
struct lscpu_desc _desc = { .flags = 0 }, *desc = &_desc;
int c, i;
int columns[ARRAY_SIZE(coldescs)], ncolumns = 0;
+ int cpu_modifier_specified = 0;
static const struct option longopts[] = {
{ "all", no_argument, 0, 'a' },
@@ -1276,12 +1277,15 @@ int main(int argc, char *argv[])
switch (c) {
case 'a':
mod->online = mod->offline = 1;
+ cpu_modifier_specified = 1;
break;
case 'b':
mod->online = 1;
+ cpu_modifier_specified = 1;
break;
case 'c':
mod->offline = 1;
+ cpu_modifier_specified = 1;
break;
case 'h':
usage(stdout);
@@ -1316,6 +1320,14 @@ int main(int argc, char *argv[])
}
}
+ if (cpu_modifier_specified && mod->mode == OUTPUT_SUMMARY) {
+ fprintf(stderr,
+ _("%s: options --all, --online and --offline may only "
+ "be used with options --extended or --parsable.\n"),
+ program_invocation_short_name);
+ return EXIT_FAILURE;
+ }
+
if (argc != optind)
usage(stderr);