+
+
+ rv = 0;
+ switch(mode) {
+ case '@':/* Management */
+ /* readonly, add/remove, readwrite, runstop */
+ if (readonly>0)
+ rv = Manage_ro(devs[0], mdfd, readonly);
+ if (!rv && devs_found>1)
+ rv = Manage_subdevs(devs[0], mdfd,
+ devs_found-1, devs+1, devmodes+1);
+ if (!rv && readonly < 0)
+ rv = Manage_ro(devs[0], mdfd, readonly);
+ if (!rv && runstop)
+ rv = Manage_runstop(devs[0], mdfd, runstop);
+ break;
+ case 'A': /* Assemble */
+ if (!scan)
+ rv = Assemble(devs[0], mdfd, &ident, configfile,
+ devs_found-1, devs+1,
+ readonly, runstop, verbose, force);
+ else if (devs_found>0)
+ for (i=0; i<devs_found; i++) {
+ mddev_ident_t array_ident = conf_get_ident(configfile, devs[i]);
+ mdfd = open_mddev(devs[i]);
+ if (mdfd < 0) {
+ rv |= 1;
+ continue;
+ }
+ if (array_ident == NULL) {
+ fprintf(stderr, Name ": %s not identified in config file.\n",
+ devs[i]);
+ rv |= 1;
+ continue;
+ }
+ rv |= Assemble(devs[i], mdfd, array_ident, configfile,
+ 0, NULL,
+ readonly, runstop, verbose, force);
+ }
+ 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 = 1;
+ } else
+ for (; array_list; array_list = array_list->next) {
+ mdfd = open_mddev(array_list->devname);
+ if (mdfd < 0) {
+ rv |= 1;
+ continue;
+ }
+ rv |= Assemble(array_list->devname, mdfd,
+ array_list, configfile,
+ 0, NULL,
+ readonly, runstop, verbose, force);
+ }
+ }
+ break;
+ case 'B': /* Build */
+ rv = Build(devs[0], mdfd, chunk, level, raiddisks, devs_found-1,devs+1);
+ break;
+ case 'C': /* Create */
+ rv = Create(devs[0], mdfd, chunk, level, layout, size,
+ raiddisks, sparedisks,
+ devs_found-1,devs+1, runstop, verbose, force);
+ break;
+ case 'D': /* Detail */
+ for (i=0; i<devs_found; i++)
+ rv |= Detail(devs[i]);
+ break;
+ case 'E': /* Examine */
+ for (i=0; i<devs_found; i++)
+ rv |= Examine(devs[i]);
+ break;
+ case 'F': /* Follow */
+ rv= Monitor(devs_found, devs, mailaddr, program,
+ delay?delay:60, configfile);