From 436f1376e1621aeba54d8253244955df4865d5e9 Mon Sep 17 00:00:00 2001 From: Matt Evans Date: Fri, 14 May 2010 14:15:09 +1000 Subject: kexec-tools: Fix option/argument parsing The argument parsing is currently a bit broken as main()'s getopt_long() knows nothing about either the architecture-specific options or, even more specifically, the architecture-and-loader-specific options. This patch introduces new #defines for all architectures, KEXEC_ALL_OPTIONS and KEXEC_ALL_OPT_STR. These contain all possible options for a given build, and the getopt_long() passes in main() and arch_process_options() will now recognise arch- and loader-specific options; these will not be re-ordered in argv[], there is no confusion over which argv[] entry is the kernel filename, and using '--opt=foo' and '--opt foo' both work. All architectures have command line options (and #define OPT_BLAHs) consolidated into their include/arch/option.h files. x86_64 builds parts of i386/ as well, so now both share a single option.h file (with a symlink). Signed-off-by: Matt Evans Signed-off-by: Simon Horman --- kexec/kexec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'kexec/kexec.c') diff --git a/kexec/kexec.c b/kexec/kexec.c index a9a0f3f..2b5dc42 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -1057,17 +1057,17 @@ int main(int argc, char *argv[]) int result = 0; int fileind; static const struct option options[] = { - KEXEC_ARCH_OPTIONS + KEXEC_ALL_OPTIONS { 0, 0, 0, 0}, }; - static const char short_options[] = KEXEC_OPT_STR; + static const char short_options[] = KEXEC_ALL_OPT_STR; arch_init(); - opterr = 0; /* Don't complain about unrecognized options here */ while ((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) { switch(opt) { + case '?': case OPT_HELP: usage(); return 0; -- cgit