[RFC PATCH] kexec-tools: Fix option/argument parsing

David N. Lombard dnlombar at ichips.intel.com
Thu May 13 09:42:49 EDT 2010


On Thu, May 13, 2010 at 01:14:32AM -0700, Matt Evans wrote:
> Hi,
> 
> 
> In playing with kexec-tools I've noticed various problems with the argument
> passing, meaning one has to be careful to use certain forms of arguments
> and present them in a certain order.
> 
> The arguments end up being parsed three times, each getting more specific
> than the last.  main() looks for general args, arch_process_options() looks
> for options common to all loaders for the arch, and then finally many
> file_type load() methods check for options specific to that filetype.
> 
> As GNU getopt works, it re-orders the argv[] pushing any args it doesn't
> recognise to the end.  This includes arguments to valid options which
> are simply not recognised the first time around.

This is a long standing problem; I found it years ago.  My patch saved a copy
of the original argc and then passed that original version to each phase instead
of the mangled vector.

I hope your suggestion is accepted or prompts a solution, as the problem can
be quite vexing...

-- 
David N. Lombard, Intel, Irvine, CA
I do not speak for Intel Corporation; all comments are strictly my own.



More information about the kexec mailing list