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;
}
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) {
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;
}
|| chunk != 0 || level != UnSet) {
rv = Grow_reshape(devlist->devname, mdfd, quiet, backup_file,
size, level, layout_str, chunk, raiddisks,
- force);
+ devlist->next,
+ assume_clean, force);
} else if (array_size < 0)
fprintf(stderr, Name ": no changes to --grow\n");
break;