return 0;
}
+#ifndef MDASSEMBLE
+
int Manage_runstop(char *devname, int fd, int runstop, int quiet)
{
/* Run or stop the array. array must already be configured
devname, strerror(errno));
return 1;
}
+ if (quiet <= 0)
+ fprintf(stderr, Name ": started %s\n", devname);
} else if (runstop < 0){
+ struct map_ent *map = NULL;
+ struct stat stb;
if (ioctl(fd, STOP_ARRAY, NULL)) {
if (quiet==0)
fprintf(stderr, Name ": fail to stop array %s: %s\n",
}
if (quiet <= 0)
fprintf(stderr, Name ": stopped %s\n", devname);
+ if (fstat(fd, &stb) == 0) {
+ int devnum;
+ if (major(stb.st_rdev) == MD_MAJOR)
+ devnum = minor(stb.st_rdev);
+ else
+ devnum = -1-(minor(stb.st_rdev)>>6);
+ map_delete(&map, devnum);
+ map_write(map);
+ map_free(map);
+ }
}
return 0;
}
return 1;
}
for (dv = devlist ; dv; dv=dv->next) {
+ unsigned long long ldsize;
+
if (stat(dv->devname, &stb)) {
fprintf(stderr, Name ": cannot find %s: %s\n",
dv->devname, strerror(errno));
dv->devname, dv->disposition);
return 1;
case 'a':
- /* add the device - hot or cold */
+ /* add the device */
st = super_by_version(array.major_version,
array.minor_version);
if (!st) {
if (array.not_persistent==0)
st->ss->load_super(st, tfd, &osuper, NULL);
/* will use osuper later */
+ if (!get_dev_size(tfd, dv->devname, &ldsize)) {
+ close(tfd);
+ return 1;
+ }
close(tfd);
if (array.major_version == 0 &&
if (array.not_persistent == 0) {
+ /* Make sure device is large enough */
+ if (st->ss->avail_size(st, ldsize/512) <
+ array.size) {
+ fprintf(stderr, Name ": %s not large enough to join array\n",
+ dv->devname);
+ return 1;
+ }
+
/* need to find a sample superblock to copy, and
* a spare slot to use
*/
close(dfd);
continue;
}
+ remove_partitions(dfd);
close(dfd);
break;
}
/* fall back on normal-add */
}
}
+ } else {
+ /* non-persistent. Must ensure that new drive
+ * is at least array.size big.
+ */
+ if (ldsize/512 < array.size) {
+ fprintf(stderr, Name ": %s not large enough to join array\n",
+ dv->devname);
+ return 1;
+ }
}
/* in 2.6.17 and earlier, version-1 superblocks won't
* use the number we write, but will choose a free number.
return 0;
}
+#endif