tmpdev->used = 1;
loop:
- tst->ss->free_super(tst);
+ if (tst)
+ tst->ss->free_super(tst);
}
if (mdfd < 0) {
*/
mdu_array_info_t inf;
char *c;
- if (!st->sb) {
+ if (!st || !st->sb) {
return 2;
}
st->ss->getinfo_super(st, &info);
== devices[devcnt].i.events
&& (devices[best[i]].i.disk.minor
!= devices[devcnt].i.disk.minor)
- && st->ss->major == 0
- && info.array.level != -4) {
+ && st->ss == &super0
+ && info.array.level != LEVEL_MULTIPATH) {
/* two different devices with identical superblock.
* Could be a mis-detection caused by overlapping
* partitions. fail-safe.
devcnt++;
}
- if (update && strcmp(update, "byteorder")==0)
- st->minor_version = 90;
-
if (devcnt == 0) {
fprintf(stderr, Name ": no devices found for %s\n",
mddev);
- st->ss->free_super(st);
+ if (st)
+ st->ss->free_super(st);
if (must_close) close(mdfd);
return 1;
}
+ if (update && strcmp(update, "byteorder")==0)
+ st->minor_version = 90;
+
st->ss->getinfo_super(st, &info);
clean = info.array.state & 1;
continue;
}
tst = dup_super(st);
- if (tst->ss->load_super(st,fd, NULL)) {
+ if (tst->ss->load_super(tst,fd, NULL)) {
close(fd);
fprintf(stderr, Name ": RAID superblock disappeared from %s - not updating.\n",
devices[chosen_drive].devname);
struct mdinfo *sra;
if (st->ss->external) {
char ver[100];
- strcat(strcpy(ver, "external:"), st->ss->text_version);
+ strcat(strcpy(ver, "external:"), info.text_version);
sra = sysfs_read(mdfd, 0, 0);
if ((vers % 100) < 2 ||
sra == NULL ||
if ((vers % 100) >= 1) { /* can use different versions */
mdu_array_info_t inf;
memset(&inf, 0, sizeof(inf));
- inf.major_version = st->ss->major;
- inf.minor_version = st->minor_version;
+ inf.major_version = info.array.major_version;
+ inf.minor_version = info.array.minor_version;
rv = ioctl(mdfd, SET_ARRAY_INFO, &inf);
} else
rv = ioctl(mdfd, SET_ARRAY_INFO, NULL);
if (j >= 0 /* && devices[j].uptodate */) {
#ifndef MDASSEMBLE
- if (st->ss->external) {
- devices[j].i.disk.number =
- devices[j].i.disk.raid_disk;
- st->ss->getinfo_super_n(st,
- &devices[j].i);
- rv = sysfs_add_disk(sra,
- &devices[j].i);
- } else
+ if (st->ss->external)
+ rv = sysfs_add_disk(sra, &devices[j].i);
+ else
#endif
rv = ioctl(mdfd, ADD_NEW_DISK,
&devices[j].i.disk);
"start the array while not clean "
"- consider --force.\n");
- if (must_close) close(mdfd);
+ if (must_close) {
+ ioctl(mdfd, STOP_ARRAY, NULL);
+ close(mdfd);
+ }
return 1;
}
if (runstop == -1) {
fprintf(stderr, " (use --run to insist).\n");
}
}
- if (must_close) close(mdfd);
+ if (must_close) {
+ ioctl(mdfd, STOP_ARRAY, NULL);
+ close(mdfd);
+ }
return 1;
} else {
/* The "chosen_drive" is a good choice, and if necessary, the superblock has