diff options
author | Matt Evans <matt@ozlabs.org> | 2010-05-14 14:15:09 +1000 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2010-05-19 12:18:29 +0900 |
commit | 436f1376e1621aeba54d8253244955df4865d5e9 (patch) | |
tree | ab557c57d939167e8a3217b960e7a54b95fcf18a /kexec/arch/sh | |
parent | b1dcc08ea79ca96256a9ae6ef59e5ea4e217ef1d (diff) |
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 <matt@ozlabs.org>
Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/arch/sh')
-rw-r--r-- | kexec/arch/sh/include/arch/options.h | 26 | ||||
-rw-r--r-- | kexec/arch/sh/kexec-sh.c | 7 |
2 files changed, 29 insertions, 4 deletions
diff --git a/kexec/arch/sh/include/arch/options.h b/kexec/arch/sh/include/arch/options.h index e02960d..571b271 100644 --- a/kexec/arch/sh/include/arch/options.h +++ b/kexec/arch/sh/include/arch/options.h @@ -7,16 +7,36 @@ #define OPT_NBSD_HOWTO (OPT_ARCH_MAX+3) #define OPT_NBSD_MROOT (OPT_ARCH_MAX+4) - +/* Options relevant to the architecture (excluding loader-specific ones): */ #define KEXEC_ARCH_OPTIONS \ KEXEC_OPTIONS \ {"command-line", 1, 0, OPT_APPEND}, \ {"append", 1, 0, OPT_APPEND}, \ {"empty-zero", 1, 0, OPT_APPEND}, \ {"howto", 1, 0, OPT_NBSD_HOWTO}, \ - {"miniroot", 1, 0, OPT_NBSD_MROOT}, \ - + {"miniroot", 1, 0, OPT_NBSD_MROOT}, +/* These options seem to be loader-specific rather than cris-specific, so + * ought to be moved to KEXEC_ALL_OPTIONS below and parsed in the relevant + * loader, e.g. kexec-netbsd-sh.c + */ #define KEXEC_ARCH_OPT_STR KEXEC_OPT_STR "" +/* The following two #defines list ALL of the options added by all of the + * architecture's loaders. + * o main() uses this complete list to scan for its options, ignoring + * arch-specific/loader-specific ones. + * o Then, arch_process_options() uses this complete list to scan for its + * options, ignoring general/loader-specific ones. + * o Then, the file_type[n].load re-scans for options, using + * KEXEC_ARCH_OPTIONS plus its loader-specific options subset. + * Any unrecognised options cause an error here. + * + * This is done so that main()'s/arch_process_options()'s getopt_long() calls + * don't choose a kernel filename from random arguments to options they don't + * recognise -- as they now recognise (if not act upon) all possible options. + */ +#define KEXEC_ALL_OPTIONS KEXEC_ARCH_OPTIONS +#define KEXEC_ALL_OPT_STR KEXEC_ARCH_OPT_STR + #endif /* KEXEC_ARCH_SH_OPTIONS_H */ diff --git a/kexec/arch/sh/kexec-sh.c b/kexec/arch/sh/kexec-sh.c index 1ad3d38..4b21ee8 100644 --- a/kexec/arch/sh/kexec-sh.c +++ b/kexec/arch/sh/kexec-sh.c @@ -97,8 +97,13 @@ void arch_usage(void) int arch_process_options(int argc, char **argv) { + /* The common options amongst loaders (e.g. --append) should be read + * here, and the loader-specific options (e.g. NetBSD stuff) should + * then be re-parsed in the loader. + * (e.g. in kexec-netbsd-sh.c, for example.) + */ static const struct option options[] = { - KEXEC_ARCH_OPTIONS + KEXEC_ALL_OPTIONS { 0, 0, NULL, 0 }, }; static const char short_options[] = KEXEC_ARCH_OPT_STR; |