change Examine to take a struct context

Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
NeilBrown 2012-07-09 17:20:00 +10:00
parent 265460abab
commit eec3f88785
3 changed files with 21 additions and 24 deletions

View File

@ -30,10 +30,9 @@
#endif #endif
#include "md_u.h" #include "md_u.h"
#include "md_p.h" #include "md_p.h"
int Examine(struct mddev_dev *devlist, int brief, int verbose, int Examine(struct mddev_dev *devlist,
int export, int scan, struct context *c,
int SparcAdjust, struct supertype *forcest, struct supertype *forcest)
char *homehost)
{ {
/* Read the raid superblock from a device and /* Read the raid superblock from a device and
@ -69,7 +68,7 @@ int Examine(struct mddev_dev *devlist, int brief, int verbose,
fd = dev_open(devlist->devname, O_RDONLY); fd = dev_open(devlist->devname, O_RDONLY);
if (fd < 0) { if (fd < 0) {
if (!scan) { if (!c->scan) {
pr_err("cannot open %s: %s\n", pr_err("cannot open %s: %s\n",
devlist->devname, strerror(errno)); devlist->devname, strerror(errno));
rv = 1; rv = 1;
@ -91,18 +90,18 @@ int Examine(struct mddev_dev *devlist, int brief, int verbose,
st->ignore_hw_compat = 1; st->ignore_hw_compat = 1;
if (!container) if (!container)
err = st->ss->load_super(st, fd, err = st->ss->load_super(st, fd,
(brief||scan) ? NULL (c->brief||c->scan) ? NULL
:devlist->devname); :devlist->devname);
if (err && st->ss->load_container) { if (err && st->ss->load_container) {
err = st->ss->load_container(st, fd, err = st->ss->load_container(st, fd,
(brief||scan) ? NULL (c->brief||c->scan) ? NULL
:devlist->devname); :devlist->devname);
if (!err) if (!err)
have_container = 1; have_container = 1;
} }
st->ignore_hw_compat = 0; st->ignore_hw_compat = 0;
} else { } else {
if (!brief) { if (!c->brief) {
pr_err("No md superblock detected on %s.\n", devlist->devname); pr_err("No md superblock detected on %s.\n", devlist->devname);
rv = 1; rv = 1;
} }
@ -113,16 +112,16 @@ int Examine(struct mddev_dev *devlist, int brief, int verbose,
if (err) if (err)
continue; continue;
if (SparcAdjust) if (c->SparcAdjust)
st->ss->update_super(st, NULL, "sparc2.2", st->ss->update_super(st, NULL, "sparc2.2",
devlist->devname, 0, 0, NULL); devlist->devname, 0, 0, NULL);
/* Ok, its good enough to try, though the checksum could be wrong */ /* Ok, its good enough to try, though the checksum could be wrong */
if (brief && st->ss->brief_examine_super == NULL) { if (c->brief && st->ss->brief_examine_super == NULL) {
if (!scan) if (!c->scan)
pr_err("No brief listing for %s on %s\n", pr_err("No brief listing for %s on %s\n",
st->ss->name, devlist->devname); st->ss->name, devlist->devname);
} else if (brief) { } else if (c->brief) {
struct array *ap; struct array *ap;
char *d; char *d;
for (ap=arrays; ap; ap=ap->next) { for (ap=arrays; ap; ap=ap->next) {
@ -145,27 +144,27 @@ int Examine(struct mddev_dev *devlist, int brief, int verbose,
ap->spares++; ap->spares++;
d = dl_strdup(devlist->devname); d = dl_strdup(devlist->devname);
dl_add(ap->devs, d); dl_add(ap->devs, d);
} else if (export) { } else if (c->export) {
if (st->ss->export_examine_super) if (st->ss->export_examine_super)
st->ss->export_examine_super(st); st->ss->export_examine_super(st);
st->ss->free_super(st); st->ss->free_super(st);
} else { } else {
printf("%s:\n",devlist->devname); printf("%s:\n",devlist->devname);
st->ss->examine_super(st, homehost); st->ss->examine_super(st, c->homehost);
st->ss->free_super(st); st->ss->free_super(st);
} }
} }
if (brief) { if (c->brief) {
struct array *ap; struct array *ap;
for (ap=arrays; ap; ap=ap->next) { for (ap=arrays; ap; ap=ap->next) {
char sep='='; char sep='=';
char *d; char *d;
int newline = 0; int newline = 0;
ap->st->ss->brief_examine_super(ap->st, verbose > 0); ap->st->ss->brief_examine_super(ap->st, c->verbose > 0);
if (ap->spares) if (ap->spares)
newline += printf(" spares=%d", ap->spares); newline += printf(" spares=%d", ap->spares);
if (verbose > 0) { if (c->verbose > 0) {
newline += printf(" devices"); newline += printf(" devices");
for (d=dl_next(ap->devs); d!= ap->devs; d=dl_next(d)) { for (d=dl_next(ap->devs); d!= ap->devs; d=dl_next(d)) {
printf("%c%s", sep, d); printf("%c%s", sep, d);
@ -175,11 +174,11 @@ int Examine(struct mddev_dev *devlist, int brief, int verbose,
if (ap->st->ss->brief_examine_subarrays) { if (ap->st->ss->brief_examine_subarrays) {
if (newline) if (newline)
printf("\n"); printf("\n");
ap->st->ss->brief_examine_subarrays(ap->st, verbose); ap->st->ss->brief_examine_subarrays(ap->st, c->verbose);
} }
ap->st->ss->free_super(ap->st); ap->st->ss->free_super(ap->st);
/* FIXME free ap */ /* FIXME free ap */
if (ap->spares || verbose > 0) if (ap->spares || c->verbose > 0)
printf("\n"); printf("\n");
} }
} }

View File

@ -1354,9 +1354,7 @@ int main(int argc, char *argv[])
pr_err("No devices listed in %s\n", configfile?configfile:DefaultConfFile); pr_err("No devices listed in %s\n", configfile?configfile:DefaultConfFile);
exit(1); exit(1);
} }
rv = Examine(devlist, c.brief, c.verbose, rv = Examine(devlist, &c, ss);
c.export, c.scan,
c.SparcAdjust, ss, c.homehost);
} else if (devmode == DetailPlatform) { } else if (devmode == DetailPlatform) {
rv = Detail_Platform(ss ? ss->ss : NULL, ss ? c.scan : 1, c.verbose); rv = Detail_Platform(ss ? ss->ss : NULL, ss ? c.scan : 1, c.verbose);
} else if (devlist == NULL) { } else if (devlist == NULL) {

View File

@ -1116,8 +1116,8 @@ extern int Create(struct supertype *st, char *mddev,
extern int Detail(char *dev, int brief, int export, int test, char *homehost, char *prefer); extern int Detail(char *dev, int brief, int export, int test, char *homehost, char *prefer);
extern int Detail_Platform(struct superswitch *ss, int scan, int verbose); extern int Detail_Platform(struct superswitch *ss, int scan, int verbose);
extern int Query(char *dev); extern int Query(char *dev);
extern int Examine(struct mddev_dev *devlist, int brief, int verbose, int export, int scan, extern int Examine(struct mddev_dev *devlist, struct context *c,
int SparcAdjust, struct supertype *forcest, char *homehost); struct supertype *forcest);
extern int Monitor(struct mddev_dev *devlist, extern int Monitor(struct mddev_dev *devlist,
char *mailaddr, char *alert_cmd, char *mailaddr, char *alert_cmd,
int period, int daemonise, int scan, int oneshot, int period, int daemonise, int scan, int oneshot,