]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: limit options --all, --online, --offline to parsable and extended output
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Wed, 8 Aug 2012 08:52:47 +0000 (10:52 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 13 Aug 2012 12:42:21 +0000 (14:42 +0200)
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>
sys-utils/lscpu.1
sys-utils/lscpu.c

index 41dae8369922255325f67bb3430f03974da519a9..f7e34b95d8d407dafa06d794a80d55ae4b5ad299 100644 (file)
@@ -81,13 +81,16 @@ and hypervisor support CPU polarization.
 .SH OPTIONS
 .TP
 .BR \-a , " \-\-all"
-Include online and offline CPUs in the output (default for -e).
+Include lines for online and offline CPUs in the output (default for -e). This
+option may only specified together with option -e or -p.
 .TP
 .BR \-b , " \-\-online"
-Limit the output to online CPUs (default for -p).
+Limit the output to online CPUs (default for -p). This option may only
+be specified together with option -e or -p.
 .TP
 .BR \-c , " \-\-offline"
-Limit the output to offline CPUs.
+Limit the output to offline CPUs. This option may only be specified together
+with option -e or -p.
 .TP
 .BR \-e , " \-\-extended " \fI[=list]\fP
 Display the CPU information in human readable format.
index b93998a5aa69c33fc32ed6f56af94d426af126ba..25a027345a61d7c4849c8c7b2fa69ea0613abd82 100644 (file)
@@ -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);