struct mddev_ident_s ident;
char *configfile = NULL;
char *cp;
+ char *update = NULL;
int scan = 0;
char devmode = 0;
int runstop = 0;
char *mailaddr = NULL;
char *program = NULL;
int delay = 0;
+ int daemonise = 0;
int mdfd = -1;
continue;
case O(ASSEMBLE,'m'): /* super-minor for array */
- if (ident.super_minor >= 0) {
+ if (ident.super_minor != -1) {
fprintf(stderr, Name ": super-minor cannot be set twice. "
"Second value: %s.\n", optarg);
exit(2);
}
- ident.super_minor = strtoul(optarg, &cp, 10);
- if (!optarg[0] || *cp) {
- fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
- exit(2);
+ if (strcmp(optarg, "dev")==0)
+ ident.super_minor = -2;
+ else {
+ ident.super_minor = strtoul(optarg, &cp, 10);
+ if (!optarg[0] || *cp) {
+ fprintf(stderr, Name ": Bad super-minor number: %s.\n", optarg);
+ exit(2);
+ }
}
continue;
+ case O(ASSEMBLE,'U'): /* update the superblock */
+ if (update) {
+ fprintf(stderr, Name ": Can only update one aspect of superblock, both %s and %s given.\n",
+ update, optarg);
+ exit(2);
+ }
+ update = optarg;
+ if (strcmp(update, "sparc2.2")==0) continue;
+ if (strcmp(update, "super-minor") == 0)
+ continue;
+ fprintf(stderr, Name ": '--update %s' invalid. Only 'sparc2.2' or 'super-minor' supported\n",update);
+ exit(2);
+
case O(ASSEMBLE,'c'): /* config file */
case O(MISC, 'c'):
case O(MONITOR,'c'):
}
}
continue;
+ case O(MONITOR,'f'): /* daemonise */
+ daemonise = 1;
+ continue;
/* now the general management options. Some are applicable
}
SparcAdjust = 1;
continue;
- case O(MISC,23):
- if (devmode != 'E') {
- fprintf(stderr, Name ": --sparc2.2update only allowed with --examine\n");
- exit(2);
- }
- SparcAdjust = 2;
- continue;
}
/* We have now processed all the valid options. Anything else is
* an error
mdfd = open_mddev(devlist->devname);
if (mdfd < 0)
exit(1);
+ if (ident.super_minor == -2) {
+ struct stat stb;
+ fstat(mdfd, &stb);
+ ident.super_minor = MINOR(stb.st_rdev);
+ }
}
rv = 0;
rv = Manage_runstop(devlist->devname, mdfd, runstop);
break;
case ASSEMBLE:
- if (!scan)
+ if (devs_found == 1 && ident.uuid_set == 0 &&
+ ident.super_minor == -1 && !scan ) {
+ /* Only a device has been given, so get details from config file */
+ mddev_ident_t array_ident = conf_get_ident(configfile, devlist->devname);
+ mdfd = open_mddev(devlist->devname);
+ if (mdfd < 0)
+ rv |= 1;
+ else {
+ if (array_ident == NULL) {
+ fprintf(stderr, Name ": %s not identified in config file.\n",
+ devlist->devname);
+ rv |= 1;
+ }
+ else
+ rv |= Assemble(devlist->devname, mdfd, array_ident, configfile,
+ NULL,
+ readonly, runstop, update, verbose, force);
+ }
+ } else if (!scan)
rv = Assemble(devlist->devname, mdfd, &ident, configfile,
devlist->next,
- readonly, runstop, verbose, force);
- else if (devs_found>0)
+ readonly, runstop, update, verbose, force);
+ else if (devs_found>0) {
+ if (update && devs_found > 1) {
+ fprintf(stderr, Name ": can only update a single array at a time\n");
+ exit(1);
+ }
for (dv = devlist ; dv ; dv=dv->next) {
mddev_ident_t array_ident = conf_get_ident(configfile, dv->devname);
mdfd = open_mddev(dv->devname);
}
rv |= Assemble(dv->devname, mdfd, array_ident, configfile,
NULL,
- readonly, runstop, verbose, force);
+ readonly, runstop, update, verbose, force);
}
- else {
+ } else {
mddev_ident_t array_list = conf_get_ident(configfile, NULL);
if (!array_list) {
fprintf(stderr, Name ": No arrays found in config file\n");
rv |= Assemble(array_list->devname, mdfd,
array_list, configfile,
NULL,
- readonly, runstop, verbose, force);
+ readonly, runstop, NULL, verbose, force);
}
}
break;
}
break;
case MONITOR:
-/*
if (!devlist && !scan) {
fprintf(stderr, Name ": Cannot monitor: need --scan or at least one device\n");
rv = 1;
break;
}
-*/ rv= Monitor(devlist, mailaddr, program,
- delay?delay:60, scan, configfile);
+ rv= Monitor(devlist, mailaddr, program,
+ delay?delay:60, daemonise, scan, configfile);
break;
}
exit(rv);