Improve option parsing
stuff ====Do Not Remove==== Status: ok Signed-off-by: Neil Brown <neilb@suse.de>
This commit is contained in:
parent
8b0dabea07
commit
c06487ce20
|
@ -204,11 +204,9 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
|
|||
/* Impossible! */
|
||||
fprintf(stderr, Name ": fstat failed for %s: %s\n",
|
||||
devname, strerror(errno));
|
||||
close(dfd);
|
||||
} else if ((stb.st_mode & S_IFMT) != S_IFBLK) {
|
||||
fprintf(stderr, Name ": %s is not a block device.\n",
|
||||
devname);
|
||||
close(dfd);
|
||||
} else if (!tst && (tst = guess_super(dfd)) == NULL) {
|
||||
if ((inargv && verbose >= 0) || verbose > 0)
|
||||
fprintf(stderr, Name ": no recogniseable superblock\n");
|
||||
|
@ -216,11 +214,10 @@ int Assemble(struct supertype *st, char *mddev, int mdfd,
|
|||
if ((inargv && verbose >= 0) || verbose > 0)
|
||||
fprintf( stderr, Name ": no RAID superblock on %s\n",
|
||||
devname);
|
||||
close(dfd);
|
||||
} else {
|
||||
tst->ss->getinfo_super(&info, &ident2, super);
|
||||
close(dfd);
|
||||
}
|
||||
if (dfd >= 0) close(dfd);
|
||||
|
||||
if (ident->uuid_set &&
|
||||
(!super || same_uuid(info.uuid, ident->uuid, tst->ss->swapuuid)==0)) {
|
||||
|
|
|
@ -4,6 +4,9 @@ Changes Prior to this release
|
|||
- Support little-endian (Rather than hostendian) bitmaps.
|
||||
- Return correct error code from 'mdadm -S'
|
||||
- Remove extra blank line from 'mdadm -Eb' output.
|
||||
- Improve option parsing so that -a and -b do not have
|
||||
optional arguements: the arg is either required or not
|
||||
depending on context.
|
||||
- Allow scanning of devices listed in /proc/partitions even
|
||||
if they don't appear in /dev.
|
||||
|
||||
|
|
2
Makefile
2
Makefile
|
@ -98,7 +98,7 @@ mdassemble : $(ASSEMBLE_SRCS) mdadm.h
|
|||
|
||||
mdassemble.static : $(ASSEMBLE_SRCS) mdadm.h
|
||||
rm -f $(OBJS)
|
||||
$(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -o mdassemble $(ASSEMBLE_SRCS)
|
||||
$(CC) $(LDFLAGS) $(ASSEMBLE_FLAGS) -static -o mdassemble.static $(ASSEMBLE_SRCS)
|
||||
|
||||
mdassemble.uclibc : $(ASSEMBLE_SRCS) mdadm.h
|
||||
rm -f $(OBJS)
|
||||
|
|
3
ReadMe.c
3
ReadMe.c
|
@ -91,7 +91,8 @@ char Version[] = Name " - v2.1 - 12 September 2005\n";
|
|||
* At the time if writing, there is only minimal support.
|
||||
*/
|
||||
|
||||
char short_options[]="-ABCDEFGQhVXvqb::c:i:l:p:m:n:x:u:c:d:z:U:sa::rfRSow1te:";
|
||||
char short_options[]="-ABCDEFGQhVXvqbc:i:l:p:m:n:x:u:c:d:z:U:sarfRSow1te:";
|
||||
char short_bitmap_auto_options[]="-ABCDEFGQhVXvqb:c:i:l:p:m:n:x:u:c:d:z:U:sa:rfRSow1te:";
|
||||
struct option long_options[] = {
|
||||
{"manage", 0, 0, '@'},
|
||||
{"misc", 0, 0, '#'},
|
||||
|
|
24
mdadm.c
24
mdadm.c
|
@ -93,6 +93,7 @@ int main(int argc, char *argv[])
|
|||
struct supertype *ss = NULL;
|
||||
int writemostly = 0;
|
||||
int re_add = 0;
|
||||
char *shortopt = short_options;
|
||||
|
||||
int copies;
|
||||
|
||||
|
@ -113,7 +114,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
while ((option_index = -1) ,
|
||||
(opt=getopt_long(argc, argv,
|
||||
short_options, long_options,
|
||||
shortopt, long_options,
|
||||
&option_index)) != -1) {
|
||||
int newmode = mode;
|
||||
/* firstly, some mode-independant options */
|
||||
|
@ -150,6 +151,10 @@ int main(int argc, char *argv[])
|
|||
if (mode == ASSEMBLE || mode == BUILD || mode == CREATE || mode == GROW)
|
||||
break; /* b means bitmap */
|
||||
brief = 1;
|
||||
if (optarg) {
|
||||
fprintf(stderr, Name ": -b cannot have any extra immediately after it, sorry.\n");
|
||||
exit(2);
|
||||
}
|
||||
continue;
|
||||
|
||||
case ':':
|
||||
|
@ -164,19 +169,24 @@ int main(int argc, char *argv[])
|
|||
|
||||
switch(opt) {
|
||||
case '@': /* just incase they say --manage */
|
||||
newmode = MANAGE; break;
|
||||
newmode = MANAGE;
|
||||
shortopt = short_bitmap_auto_options;
|
||||
break;
|
||||
case 'a':
|
||||
case 'r':
|
||||
case 'f':
|
||||
case 6: /* re-add */
|
||||
if (!mode) newmode = MANAGE;
|
||||
if (!mode) {
|
||||
newmode = MANAGE;
|
||||
shortopt = short_bitmap_auto_options;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'A': newmode = ASSEMBLE; break;
|
||||
case 'B': newmode = BUILD; break;
|
||||
case 'C': newmode = CREATE; break;
|
||||
case 'A': newmode = ASSEMBLE; shortopt = short_bitmap_auto_options; break;
|
||||
case 'B': newmode = BUILD; shortopt = short_bitmap_auto_options; break;
|
||||
case 'C': newmode = CREATE; shortopt = short_bitmap_auto_options; break;
|
||||
case 'F': newmode = MONITOR;break;
|
||||
case 'G': newmode = GROW; break;
|
||||
case 'G': newmode = GROW; shortopt = short_bitmap_auto_options; break;
|
||||
|
||||
case '#':
|
||||
case 'D':
|
||||
|
|
Loading…
Reference in New Issue