/* 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");
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)) {
- 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.
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)
* 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, '#'},
struct supertype *ss = NULL;
int writemostly = 0;
int re_add = 0;
+ char *shortopt = short_options;
int copies;
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 */
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 ':':
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':
};
extern char short_options[];
+extern char short_bitmap_auto_options[];
extern struct option long_options[];
extern char Version[], Usage[], Help[], OptionHelp[],
Help_create[], Help_build[], Help_assemble[], Help_grow[],