char *shortopt = short_options;
int dosyslog = 0;
int rebuild_map = 0;
- int auto_update_home = 0;
char *subarray = NULL;
char *remove_path = NULL;
+ char *udev_filename = NULL;
int print_help = 0;
FILE *outf;
}
subarray = optarg;
}
+ case UdevRules:
case 'K': if (!mode) newmode = MISC; break;
case NoSharing: newmode = MONITOR; break;
}
exit(2);
} else if (!mode && newmode) {
mode = newmode;
+ if (mode == MISC && devs_found) {
+ fprintf(stderr, Name ": No action given for %s in --misc mode\n",
+ devlist->devname);
+ fprintf(stderr," Action options must come before device names\n");
+ exit(2);
+ }
} else {
/* special case of -c --help */
if ((opt == 'c' || opt == ConfigFile) &&
exit(2);
}
chunk = parse_size(optarg);
- if (chunk < 8 || ((chunk-1)&chunk)) {
+ if (chunk < 8 || (chunk&1)) {
fprintf(stderr, Name ": invalid chunk/rounding value: %s\n",
optarg);
exit(2);
}
- /* Covert sectors to K */
+ /* Convert sectors to K */
chunk /= 2;
continue;
-#if 0
- case O(ASSEMBLE,AutoHomeHost):
- auto_update_home = 1;
- continue;
-#endif
case O(INCREMENTAL, 'e'):
case O(CREATE,'e'):
case O(ASSEMBLE,'e'):
case O(CREATE,AssumeClean):
case O(BUILD,AssumeClean): /* assume clean */
+ case O(GROW,AssumeClean):
assume_clean = 1;
continue;
case O(ASSEMBLE,Force): /* force assembly */
case O(MISC,'f'): /* force zero */
case O(MISC,Force): /* force zero */
+ case O(MANAGE,Force): /* add device which is too large */
force=1;
continue;
case O(ASSEMBLE,'U'): /* update the superblock */
case O(MISC,'U'):
if (update) {
- fprintf(stderr, Name ": Can only update one aspect of superblock, both %s and %s given.\n",
+ fprintf(stderr, Name ": Can only update one aspect"
+ " of superblock, both %s and %s given.\n",
update, optarg);
exit(2);
}
if (mode == MISC && !subarray) {
- fprintf(stderr, Name ": Only subarrays can be updated in misc mode\n");
+ fprintf(stderr, Name ": Only subarrays can be"
+ " updated in misc mode\n");
exit(2);
}
update = optarg;
continue;
if (strcmp(update, "byteorder")==0) {
if (ss) {
- fprintf(stderr, Name ": must not set metadata type with --update=byteorder.\n");
+ fprintf(stderr,
+ Name ": must not set metadata"
+ " type with --update=byteorder.\n");
exit(2);
}
for(i=0; !ss && superlist[i]; i++)
- ss = superlist[i]->match_metadata_desc("0.swap");
+ ss = superlist[i]->match_metadata_desc(
+ "0.swap");
if (!ss) {
- fprintf(stderr, Name ": INTERNAL ERROR cannot find 0.swap\n");
+ fprintf(stderr, Name ": INTERNAL ERROR"
+ " cannot find 0.swap\n");
exit(2);
}
" 'no-bitmap'\n");
exit(outf == stdout ? 0 : 2);
+ case O(MANAGE,'U'):
+ /* update=devicesize is allowed with --re-add */
+ if (devmode != 'a' || re_add != 1) {
+ fprintf(stderr, Name "--update in Manage mode only"
+ " allowed with --re-add.\n");
+ exit(1);
+ }
+ 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, "devicesize") != 0) {
+ fprintf(stderr, Name ": only 'devicesize' can be"
+ " updated with --re-add\n");
+ exit(2);
+ }
+ continue;
+
case O(INCREMENTAL,NoDegraded):
fprintf(stderr, Name ": --no-degraded is deprecated in Incremental mode\n");
case O(ASSEMBLE,NoDegraded): /* --no-degraded */
}
devmode = opt;
continue;
+ case O(MISC, UdevRules):
+ if (devmode && devmode != opt) {
+ fprintf(stderr, Name ": --udev-rules must"
+ " be the only option.\n");
+ } else {
+ if (udev_filename)
+ fprintf(stderr, Name ": only specify one udev "
+ "rule filename. %s ignored.\n",
+ optarg);
+ else
+ udev_filename = optarg;
+ }
+ devmode = opt;
+ continue;
case O(MISC,'t'):
test = 1;
continue;
if (homehost == NULL)
homehost = conf_get_homehost(&require_homehost);
- if (homehost == NULL || strcmp(homehost, "<system>")==0) {
+ if (homehost == NULL || strcasecmp(homehost, "<system>")==0) {
if (gethostname(sys_hostname, sizeof(sys_hostname)) == 0) {
sys_hostname[sizeof(sys_hostname)-1] = 0;
homehost = sys_hostname;
}
}
+ if (homehost && (!homehost[0] || strcasecmp(homehost, "<none>") == 0)) {
+ homehost = NULL;
+ require_homehost = 0;
+ }
if ((mode != MISC || devmode != 'E') &&
geteuid() != 0) {
rv = Manage_ro(devlist->devname, mdfd, readonly);
if (!rv && devs_found>1)
rv = Manage_subdevs(devlist->devname, mdfd,
- devlist->next, verbose-quiet, test);
+ devlist->next, verbose-quiet, test,
+ update, force);
if (!rv && readonly < 0)
rv = Manage_ro(devlist->devname, mdfd, readonly);
if (!rv && runstop)
cnt++;
acnt++;
}
- if (rv2 == 1)
- /* found something so even though assembly failed we
- * want to avoid auto-updates
- */
- auto_update_home = 0;
} while (rv2!=2);
/* Incase there are stacked devices, we need to go around again */
} while (acnt);
-#if 0
- if (cnt == 0 && auto_update_home && homehost) {
- /* Nothing found, maybe we need to bootstrap homehost info */
- do {
- acnt = 0;
- do {
- rv2 = Assemble(
- ss, NULL,
- &ident,
- NULL, NULL, 0,
- readonly, runstop,
- "homehost",
- homehost,
- require_homehost,
- verbose-quiet, force);
- if (rv2==0) {
- cnt++;
- acnt++;
- }
- } while (rv2!=2);
- /* Incase there are stacked devices, we need to go around again */
- } while (acnt);
- }
-#endif
if (cnt == 0 && rv == 0) {
fprintf(stderr, Name ": No arrays found in config file or automatically\n");
rv = 1;
free_mdstat(ms);
} while (!last && err);
if (err) rv |= 1;
+ } else if (devmode == UdevRules) {
+ rv = Write_rules(udev_filename);
} else {
fprintf(stderr, Name ": No devices given.\n");
exit(2);
break;
}
}
- if (devs_found > 1) {
-
+ if (devs_found > 1 && raiddisks == 0) {
/* must be '-a'. */
- if (size >= 0 || raiddisks || chunk || layout_str != NULL || bitmap_file) {
- fprintf(stderr, Name ": --add cannot be used with other geometry changes in --grow mode\n");
+ if (size >= 0 || chunk || layout_str != NULL || bitmap_file) {
+ fprintf(stderr, Name ": --add cannot be used with "
+ "other geometry changes in --grow mode\n");
rv = 1;
break;
}
for (dv=devlist->next; dv ; dv=dv->next) {
- rv = Grow_Add_device(devlist->devname, mdfd, dv->devname);
+ rv = Grow_Add_device(devlist->devname, mdfd,
+ dv->devname);
if (rv)
break;
}
} else if (bitmap_file) {
- if (size >= 0 || raiddisks || chunk || layout_str != NULL) {
- fprintf(stderr, Name ": --bitmap changes cannot be used with other geometry changes in --grow mode\n");
+ if (size >= 0 || raiddisks || chunk ||
+ layout_str != NULL || devs_found > 1) {
+ fprintf(stderr, Name ": --bitmap changes cannot be "
+ "used with other geometry changes "
+ "in --grow mode\n");
rv = 1;
break;
}
} else if (size >= 0 || raiddisks != 0 || layout_str != NULL
|| chunk != 0 || level != UnSet) {
rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file,
- size, level, layout_str, chunk, raiddisks);
+ size, level, layout_str, chunk, raiddisks,
+ devlist->next,
+ assume_clean, force);
} else if (array_size < 0)
fprintf(stderr, Name ": no changes to --grow\n");
break;