mdmon: fix arg parsing.

-t aka --takeover should not be setting container_name.
It sets it to NULL which causes failure when you try
  mdmon --all --takeover

Signed-off-by: NeilBrown <neilb@suse.de>
ReadMe: various updates and corrections.

Signed-off-by: NeilBrown <neilb@suse.de>
Use explicit non-char opt for --zero-super

As we don't allow '-K' for '--zero-super' there is no point
using it internally.  Just define a 'KillOpt' like with
other options.

Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c: various minor clean-ups

Signed-off-by: NeilBrown <neilb@suse.de>
main: split scan_assemble into a separate function

main is too big.  This makes it a little more manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
main: extract more functions.

extract misc_scan stop_scan misc_list from main to try to
make main() a little more manageable.

Signed-off-by: NeilBrown <neilb@suse.de>
Help: use an array to choose which help matches which mode.

Looks cleaner than a big switch statement.

Signed-off-by: NeilBrown <neilb@suse.de>
Introduce pr_err for printing error messages.

'pr_err("' is a lot shorter than 'fprintf(stderr, Name ": '
cont_err() is also available.

Signed-off-by: NeilBrown <neilb@suse.de>
Remove re_add flag in favour of new disposition.

Instead of
   disposition == 'a'  re_add == 1
use
   disposition == 'A'

to record that a re-add was requested.

Signed-off-by: NeilBrown <neilb@suse.de>
Remove scattered checks for malloc success.

malloc should never fail, and if it does it is unlikely
that anything else useful can be done.  Best approach is to
abort and let some super-daemon restart.

So define xmalloc, xcalloc, xrealloc, xstrdup which don't
fail but just print a message and exit.  Then use those
removing all the tests for failure.

Also replace all "malloc;memset" sequences with 'xcalloc'.

Signed-off-by: NeilBrown <neilb@suse.de>
Assemble: allow arrays to be assembled read-only.

The option was there, but never used.

Signed-off-by: NeilBrown <neilb@suse.de>
Create: support --readonly flag.

Allow array to be created read-only

Signed-off-by: NeilBrown <neilb@suse.de>
Create parse_num() function.

Instead of open-coding this several times, just do it once.

The frees up the name 'c' which I'm about to use.

Signed-off-by: NeilBrown <neilb@suse.de>
Create 'struct context' for ad hoc context option.

Rather than passing a long list of little flags etc to various
functions we will soon pass a small collection of structures.

This first step combines a collection of variables local to
'main' into a single structure.

Signed-off-by: NeilBrown <neilb@suse.de>
Convert 'quiet' to 'not verbose' in various places.

If we change some functions to accept 'verbose', where <0 means to be
quiet, in place of 'quiet', then we will be able to merge
'quiet' and 'verbose' together for simplicity.

Signed-off-by: NeilBrown <neilb@suse.de>
Discard 'quiet' context variable.

Just use negative verbose, now that we are ready for that.

Signed-off-by: NeilBrown <neilb@suse.de>
Convert Assemble() to take a context rather than a list of options.

Signed-off-by: NeilBrown <neilb@suse.de>
Change misc_list to take struct context

Signed-off-by: NeilBrown <neilb@suse.de>
Change Build to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
Change Create to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>