diff options
author | NeilBrown <neilb@suse.de> | 2010-11-25 18:58:45 +1100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-11-25 18:58:45 +1100 |
commit | 1c7a808c4d696f6ba30c92941661a7f62eb3ff3a (patch) | |
tree | 6b09b43155cee2fc0c8b03e35857cdc4733056da /ReadMe.c | |
parent | 2bf740b39403a6a8ae5a1c5f94554959424b6ebc (diff) |
Improve opt parsing, and distinguish long from short.
In several cases, two different long options map to the same short
option. So e.g. you could give '--brief' and it would be interpreted
as '--bitmap'. That isn't really good.
So for every shared short option, define an option number and return
that for the long option instead. Then always check for both the
short and long options.
Also give some bugs like " mode == 'G'" which should be '== GROW'.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'ReadMe.c')
-rw-r--r-- | ReadMe.c | 53 |
1 files changed, 27 insertions, 26 deletions
@@ -93,8 +93,8 @@ char short_bitmap_auto_options[]= "-ABCDEFGIQhVXWZ:vqb:c:i:l:p:m:n:x:u:c:d:z:U:N:sa:rfRSow1tye:"; struct option long_options[] = { - {"manage", 0, 0, '@'}, - {"misc", 0, 0, '#'}, + {"manage", 0, 0, ManageOpt}, + {"misc", 0, 0, MiscOpt}, {"assemble", 0, 0, 'A'}, {"build", 0, 0, 'B'}, {"create", 0, 0, 'C'}, @@ -116,29 +116,30 @@ struct option long_options[] = { /* after those will normally come the name of the md device */ {"help", 0, 0, 'h'}, - {"help-options",0,0,'h'}, + {"help-options",0,0, HelpOptions}, {"version", 0, 0, 'V'}, {"verbose", 0, 0, 'v'}, {"quiet", 0, 0, 'q'}, /* For create or build: */ - {"chunk", 1, 0, 'c'}, - {"rounding", 1, 0, 'c'}, /* for linear, chunk is really a rounding number */ + {"chunk", 1, 0, ChunkSize}, + {"rounding", 1, 0, ChunkSize}, /* for linear, chunk is really a + * rounding number */ {"level", 1, 0, 'l'}, /* 0,1,4,5,6,linear */ - {"parity", 1, 0, 'p'}, /* {left,right}-{a,}symmetric */ - {"layout", 1, 0, 'p'}, + {"parity", 1, 0, Layout}, /* {left,right}-{a,}symmetric */ + {"layout", 1, 0, Layout}, {"raid-disks",1, 0, 'n'}, {"raid-devices",1, 0, 'n'}, {"spare-disks",1,0, 'x'}, {"spare-devices",1,0, 'x'}, {"size", 1, 0, 'z'}, - {"auto", 1, 0, 'a'}, /* also for --assemble */ + {"auto", 1, 0, Auto}, /* also for --assemble */ {"assume-clean",0,0, AssumeClean }, {"metadata", 1, 0, 'e'}, /* superblock format */ - {"bitmap", 1, 0, 'b'}, + {"bitmap", 1, 0, Bitmap}, {"bitmap-chunk", 1, 0, BitmapChunk}, {"write-behind", 2, 0, WriteBehind}, - {"write-mostly",0, 0, 'W'}, + {"write-mostly",0, 0, WriteMostly}, {"re-add", 0, 0, ReAdd}, {"homehost", 1, 0, HomeHost}, #if 0 @@ -148,40 +149,40 @@ struct option long_options[] = { /* For assemble */ {"uuid", 1, 0, 'u'}, - {"super-minor",1,0, 'm'}, + {"super-minor",1,0, SuperMinor}, {"name", 1, 0, 'N'}, - {"config", 1, 0, 'c'}, + {"config", 1, 0, ConfigFile}, {"scan", 0, 0, 's'}, - {"force", 0, 0, 'f'}, + {"force", 0, 0, Force}, {"update", 1, 0, 'U'}, /* Management */ - {"add", 0, 0, 'a'}, - {"remove", 0, 0, 'r'}, - {"fail", 0, 0, 'f'}, - {"set-faulty",0, 0, 'f'}, + {"add", 0, 0, Add}, + {"remove", 0, 0, Remove}, + {"fail", 0, 0, Fail}, + {"set-faulty",0, 0, Fail}, {"run", 0, 0, 'R'}, {"stop", 0, 0, 'S'}, {"readonly", 0, 0, 'o'}, {"readwrite", 0, 0, 'w'}, {"no-degraded",0,0, NoDegraded }, - {"wait", 0, 0, 'W'}, + {"wait", 0, 0, WaitOpt}, {"wait-clean", 0, 0, Waitclean }, /* For Detail/Examine */ - {"brief", 0, 0, 'b'}, + {"brief", 0, 0, Brief}, {"export", 0, 0, 'Y'}, {"sparc2.2", 0, 0, Sparc22}, {"test", 0, 0, 't'}, /* For Follow/monitor */ - {"mail", 1, 0, 'm'}, - {"program", 1, 0, 'p'}, - {"alert", 1, 0, 'p'}, - {"increment", 1, 0, 'r'}, + {"mail", 1, 0, EMail}, + {"program", 1, 0, ProgramOpt}, + {"alert", 1, 0, ProgramOpt}, + {"increment", 1, 0, Increment}, {"delay", 1, 0, 'd'}, - {"daemonise", 0, 0, 'f'}, - {"daemonize", 0, 0, 'f'}, + {"daemonise", 0, 0, Fork}, + {"daemonize", 0, 0, Fork}, {"oneshot", 0, 0, '1'}, {"pid-file", 1, 0, 'i'}, {"syslog", 0, 0, 'y'}, @@ -192,7 +193,7 @@ struct option long_options[] = { {"array-size", 1, 0, 'Z'}, /* For Incremental */ - {"rebuild-map", 0, 0, 'r'}, + {"rebuild-map", 0, 0, RebuildMapOpt}, {"path", 1, 0, IncrementalPath}, {0, 0, 0, 0} |