+ struct array {
+ struct supertype *st;
+ struct mdinfo info;
+ void *devs;
+ struct array *next;
+ int spares;
+ } *arrays = NULL;
+
+ for (; devlist ; devlist = devlist->next) {
+ struct supertype *st;
+ int have_container = 0;
+
+ fd = dev_open(devlist->devname, O_RDONLY);
+ if (fd < 0) {
+ if (!c->scan) {
+ pr_err("cannot open %s: %s\n",
+ devlist->devname, strerror(errno));
+ rv = 1;
+ }
+ err = 1;
+ }
+ else {
+ int container = 0;
+ if (forcest)
+ st = dup_super(forcest);
+ else if (must_be_container(fd)) {
+ /* might be a container */
+ st = super_by_fd(fd, NULL);
+ container = 1;
+ } else
+ st = guess_super(fd);
+ if (st) {
+ err = 1;
+ st->ignore_hw_compat = 1;
+ if (!container)
+ err = st->ss->load_super(st, fd,
+ (c->brief||c->scan) ? NULL
+ :devlist->devname);
+ if (err && st->ss->load_container) {
+ err = st->ss->load_container(st, fd,
+ (c->brief||c->scan) ? NULL
+ :devlist->devname);
+ if (!err)
+ have_container = 1;
+ }
+ st->ignore_hw_compat = 0;
+ } else {
+ if (!c->brief) {
+ pr_err("No md superblock detected on %s.\n", devlist->devname);
+ rv = 1;
+ }
+ err = 1;
+ }
+ close(fd);
+ }
+ if (err)
+ continue;
+
+ if (c->SparcAdjust)
+ st->ss->update_super(st, NULL, "sparc2.2",
+ devlist->devname, 0, 0, NULL);
+ /* Ok, its good enough to try, though the checksum could be wrong */
+
+ if (c->brief && st->ss->brief_examine_super == NULL) {
+ if (!c->scan)
+ pr_err("No brief listing for %s on %s\n",
+ st->ss->name, devlist->devname);
+ } else if (c->brief) {
+ struct array *ap;
+ char *d;
+ for (ap = arrays; ap; ap = ap->next) {
+ if (st->ss == ap->st->ss &&
+ st->ss->compare_super(ap->st, st) == 0)
+ break;
+ }
+ if (!ap) {
+ ap = xmalloc(sizeof(*ap));
+ ap->devs = dl_head();
+ ap->next = arrays;
+ ap->spares = 0;
+ ap->st = st;
+ arrays = ap;
+ st->ss->getinfo_super(st, &ap->info, NULL);
+ } else
+ st->ss->getinfo_super(st, &ap->info, NULL);
+ if (!have_container &&
+ !(ap->info.disk.state & (1<<MD_DISK_SYNC)))
+ ap->spares++;
+ d = dl_strdup(devlist->devname);
+ dl_add(ap->devs, d);
+ } else if (c->export) {
+ if (st->ss->export_examine_super)
+ st->ss->export_examine_super(st);
+ st->ss->free_super(st);
+ } else {
+ printf("%s:\n",devlist->devname);
+ st->ss->examine_super(st, c->homehost);
+ st->ss->free_super(st);
+ }