#include <ctype.h>
-static int scan_assemble(int autof, struct supertype *ss,
- int readonly, int runstop,
- struct mddev_ident *ident,
- char *homehost, int require_homehost,
- int verbose, int force,
- int freeze_reshape);
-static int misc_scan(char devmode, int verbose, int export, int test,
- char *homehost, char *prefer);
-static int stop_scan(int quiet);
+static int scan_assemble(struct supertype *ss,
+ struct context *c,
+ struct mddev_ident *ident);
+static int misc_scan(char devmode, struct context *c);
+static int stop_scan(int verbose);
static int misc_list(struct mddev_dev *devlist,
- int brief, int verbose, int export, int test,
- char *homehost, char *prefer, char *subarray,
- char *update, struct mddev_ident *ident,
- struct supertype *ss, int force, int quiet);
+ struct mddev_ident *ident,
+ struct supertype *ss, struct context *c);
int main(int argc, char *argv[])
case 'v': c.verbose++;
continue;
- case 'q': c.quiet++;
+ case 'q': c.verbose--;
continue;
case 'b':
ident.autof = c.autof;
+ if (c.scan && c.verbose < 2)
+ /* --scan implied --brief unless -vv */
+ c.brief = 1;
+
rv = 0;
switch(mode) {
case MANAGE:
rv = Manage_ro(devlist->devname, mdfd, c.readonly);
if (!rv && devs_found>1)
rv = Manage_subdevs(devlist->devname, mdfd,
- devlist->next, c.verbose-c.quiet, c.test,
+ devlist->next, c.verbose, c.test,
c.update, c.force);
if (!rv && c.readonly < 0)
rv = Manage_ro(devlist->devname, mdfd, c.readonly);
if (!rv && c.runstop)
- rv = Manage_runstop(devlist->devname, mdfd, c.runstop, c.quiet);
+ rv = Manage_runstop(devlist->devname, mdfd, c.runstop, c.verbose, 0);
break;
case ASSEMBLE:
if (devs_found == 1 && ident.uuid_set == 0 &&
if (array_ident->autof == 0)
array_ident->autof = c.autof;
rv |= Assemble(ss, devlist->devname, array_ident,
- NULL, c.backup_file, c.invalid_backup,
- c.readonly, c.runstop, c.update,
- c.homehost, c.require_homehost,
- c.verbose-c.quiet, c.force,
- c.freeze_reshape);
+ NULL, &c);
}
} else if (!c.scan)
rv = Assemble(ss, devlist->devname, &ident,
- devlist->next, c.backup_file, c.invalid_backup,
- c.readonly, c.runstop, c.update,
- c.homehost, c.require_homehost,
- c.verbose-c.quiet, c.force,
- c.freeze_reshape);
+ devlist->next, &c);
else if (devs_found > 0) {
if (c.update && devs_found > 1) {
pr_err("can only update a single array at a time\n");
if (array_ident->autof == 0)
array_ident->autof = c.autof;
rv |= Assemble(ss, dv->devname, array_ident,
- NULL, c.backup_file, c.invalid_backup,
- c.readonly, c.runstop, c.update,
- c.homehost, c.require_homehost,
- c.verbose-c.quiet, c.force,
- c.freeze_reshape);
+ NULL, &c);
}
} else {
if (c.update) {
pr_err("--backup_file not meaningful with a --scan assembly.\n");
exit(1);
}
- rv = scan_assemble(c.autof, ss, c.readonly, c.runstop,
- &ident, c.homehost,
- c.require_homehost,
- c.verbose - c.quiet,
- c.force, c.freeze_reshape);
+ rv = scan_assemble(ss, &c, &ident);
}
break;
rv = Build(devlist->devname, chunk, level, layout,
raiddisks, devlist->next, assume_clean,
bitmap_file, bitmap_chunk, write_behind,
- c.delay, c.verbose-c.quiet, c.autof, size);
+ &c, size);
break;
case CREATE:
if (c.delay == 0)
}
rv = Create(ss, devlist->devname, chunk, level, layout, size<0 ? 0 : size,
- raiddisks, sparedisks, ident.name, c.homehost,
+ raiddisks, sparedisks, ident.name,
ident.uuid_set ? ident.uuid : NULL,
- devs_found-1, devlist->next, c.runstop,
- c.readonly, c.verbose-c.quiet, c.force, assume_clean,
- bitmap_file, bitmap_chunk, write_behind, c.delay, c.autof);
+ devs_found-1, devlist->next,
+ assume_clean,
+ bitmap_file, bitmap_chunk, write_behind, &c);
break;
case MISC:
if (devmode == 'E') {
pr_err("No devices listed in %s\n", configfile?configfile:DefaultConfFile);
exit(1);
}
- if (c.brief && c.verbose)
- c.brief = 2;
- rv = Examine(devlist, c.scan?(c.verbose>1?0:c.verbose+1):c.brief,
- c.export, c.scan,
- c.SparcAdjust, ss, c.homehost);
+ rv = Examine(devlist, &c, ss);
} else if (devmode == DetailPlatform) {
rv = Detail_Platform(ss ? ss->ss : NULL, ss ? c.scan : 1, c.verbose);
} else if (devlist == NULL) {
if (devmode == 'S' && c.scan)
- rv = stop_scan(c.quiet);
+ rv = stop_scan(c.verbose);
else if ((devmode == 'D' || devmode == Waitclean) && c.scan)
- rv = misc_scan(devmode, c.verbose, c.export,
- c.test, c.homehost, c.prefer);
+ rv = misc_scan(devmode, &c);
else if (devmode == UdevRules)
rv = Write_rules(udev_filename);
else {
exit(2);
}
} else
- rv = misc_list(devlist, c.brief, c.verbose, c.export, c.test,
- c.homehost, c.prefer, c.subarray, c.update,
- &ident,
- ss, c.force, c.quiet);
+ rv = misc_list(devlist, &ident, ss, &c);
break;
case MONITOR:
if (!devlist && !c.scan) {
else
c.delay = 60;
}
+ if (c.delay == 0)
+ c.delay = 60;
rv= Monitor(devlist, mailaddr, program,
- c.delay?c.delay:60, daemonise, c.scan, oneshot,
- dosyslog, c.test, pidfile, increments,
- spare_sharing, c.prefer);
+ &c, daemonise, oneshot,
+ dosyslog, pidfile, increments,
+ spare_sharing);
break;
case GROW:
c.verbose);
else if (size >= 0 || raiddisks != 0 || layout_str != NULL
|| chunk != 0 || level != UnSet) {
- rv = Grow_reshape(devlist->devname, mdfd, c.quiet, c.backup_file,
+ rv = Grow_reshape(devlist->devname, mdfd, c.verbose, c.backup_file,
size, level, layout_str, chunk, raiddisks,
devlist->next,
assume_clean, c.force);
}
if (devmode == 'f')
rv = IncrementalRemove(devlist->devname, remove_path,
- c.verbose-c.quiet);
+ c.verbose);
else
- rv = Incremental(devlist->devname, c.verbose-c.quiet,
- c.runstop, ss, c.homehost,
- c.require_homehost, c.autof,
- c.freeze_reshape);
+ rv = Incremental(devlist->devname, &c, ss);
break;
case AUTODETECT:
autodetect();
exit(rv);
}
-static int scan_assemble(int autof, struct supertype *ss,
- int readonly, int runstop,
- struct mddev_ident *ident,
- char *homehost, int require_homehost,
- int verbose, int force,
- int freeze_reshape)
+static int scan_assemble(struct supertype *ss,
+ struct context *c,
+ struct mddev_ident *ident)
{
struct mddev_ident *a, *array_list = conf_get_ident(NULL);
struct mddev_dev *devlist = conf_get_devs();
for (a = array_list; a ; a = a->next) {
a->assembled = 0;
if (a->autof == 0)
- a->autof = autof;
+ a->autof = c->autof;
}
if (map_lock(&map))
pr_err("%s: failed to get "
continue;
r = Assemble(ss, a->devname,
- a,
- NULL, NULL, 0,
- readonly, runstop, NULL,
- homehost, require_homehost,
- verbose, force,
- freeze_reshape);
+ a, NULL, c);
if (r == 0) {
a->assembled = 1;
successes++;
cnt++;
}
} while (failures && successes);
- if (homehost && cnt == 0) {
+ if (c->homehost && cnt == 0) {
/* Maybe we can auto-assemble something.
* Repeatedly call Assemble in auto-assemble mode
* until it fails
*/
int rv2;
int acnt;
- ident->autof = autof;
+ ident->autof = c->autof;
do {
struct mddev_dev *devlist = conf_get_devs();
acnt = 0;
do {
rv2 = Assemble(ss, NULL,
ident,
- devlist, NULL, 0,
- readonly,
- runstop, NULL,
- homehost,
- require_homehost,
- verbose,
- force,
- freeze_reshape);
+ devlist, c);
if (rv2==0) {
cnt++;
acnt++;
return rv;
}
-static int misc_scan(char devmode, int verbose, int export, int test,
- char *homehost, char *prefer)
+static int misc_scan(char devmode, struct context *c)
{
/* apply --detail or --wait-clean to
* all devices in /proc/mdstat
struct mdstat_ent *e;
struct map_ent *map = NULL;
int members;
- int v = verbose>1?0:verbose+1;
int rv = 0;
for (members = 0; members <= 1; members++) {
continue;
}
if (devmode == 'D')
- rv |= Detail(name, v,
- export, test,
- homehost, prefer);
+ rv |= Detail(name, c);
else
- rv |= WaitClean(name, -1, v);
+ rv |= WaitClean(name, -1, c->verbose);
put_md_name(name);
}
}
return rv;
}
-static int stop_scan(int quiet)
+static int stop_scan(int verbose)
{
/* apply --stop to all devices in /proc/mdstat */
/* Due to possible stacking of devices, repeat until
}
mdfd = open_mddev(name, 1);
if (mdfd >= 0) {
- if (Manage_runstop(name, mdfd, -1, quiet?1:last?0:-1))
+ if (Manage_runstop(name, mdfd, -1, verbose, !last))
err = 1;
else
progress = 1;
}
static int misc_list(struct mddev_dev *devlist,
- int brief, int verbose, int export, int test,
- char *homehost, char *prefer, char *subarray,
- char *update, struct mddev_ident *ident,
- struct supertype *ss, int force, int quiet)
+ struct mddev_ident *ident,
+ struct supertype *ss, struct context *c)
{
struct mddev_dev *dv;
int rv = 0;
switch(dv->disposition) {
case 'D':
- rv |= Detail(dv->devname,
- brief?1+verbose:0,
- export, test, homehost, prefer);
+ rv |= Detail(dv->devname, c);
continue;
case KillOpt: /* Zero superblock */
if (ss)
- rv |= Kill(dv->devname, ss, force, quiet,0);
+ rv |= Kill(dv->devname, ss, c->force, c->verbose,0);
else {
- int q = quiet;
+ int v = c->verbose;
do {
- rv |= Kill(dv->devname, NULL, force, q, 0);
- q = 1;
+ rv |= Kill(dv->devname, NULL, c->force, v, 0);
+ v = -1;
} while (rv == 0);
rv &= ~2;
}
case 'Q':
rv |= Query(dv->devname); continue;
case 'X':
- rv |= ExamineBitmap(dv->devname, brief, ss); continue;
+ rv |= ExamineBitmap(dv->devname, c->brief, ss); continue;
case 'W':
case WaitOpt:
rv |= Wait(dv->devname); continue;
case Waitclean:
- rv |= WaitClean(dv->devname, -1, verbose-quiet); continue;
+ rv |= WaitClean(dv->devname, -1, c->verbose); continue;
case KillSubarray:
- rv |= Kill_subarray(dv->devname, subarray, quiet);
+ rv |= Kill_subarray(dv->devname, c->subarray, c->verbose);
continue;
case UpdateSubarray:
- if (update == NULL) {
+ if (c->update == NULL) {
pr_err("-U/--update must be specified with --update-subarray\n");
rv |= 1;
continue;
}
- rv |= Update_subarray(dv->devname, subarray,
- update, ident, quiet);
+ rv |= Update_subarray(dv->devname, c->subarray,
+ c->update, ident, c->verbose);
continue;
}
mdfd = open_mddev(dv->devname, 1);
if (mdfd>=0) {
switch(dv->disposition) {
case 'R':
- rv |= Manage_runstop(dv->devname, mdfd, 1, quiet); break;
+ rv |= Manage_runstop(dv->devname, mdfd, 1, c->verbose, 0); break;
case 'S':
- rv |= Manage_runstop(dv->devname, mdfd, -1, quiet); break;
+ rv |= Manage_runstop(dv->devname, mdfd, -1, c->verbose, 0); break;
case 'o':
rv |= Manage_ro(dv->devname, mdfd, 1); break;
case 'w':