inf->disk.minor = minor(stb.st_rdev);
remove_partitions(fd);
- st->ss->add_to_super(st, &inf->disk,
- fd, dv->devname);
+ if (st->ss->add_to_super(st, &inf->disk,
+ fd, dv->devname)) {
+ fprintf(stderr, Name ": failed to add %s\n",
+ dv->devname);
+ goto abort;
+ }
st->ss->getinfo_super(st, inf);
safe_mode_delay = inf->safe_mode_delay;
if (dv->writemostly == 1)
disc.state |= 1 << MD_DISK_WRITEMOSTLY;
dfd = open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
- tst->ss->add_to_super(tst, &disc, dfd,
- dv->devname);
+ if (tst->ss->add_to_super(tst, &disc, dfd,
+ dv->devname)) {
+ fprintf(stderr, Name ": failed to add %s\n",
+ dv->devname);
+ close(dfd);
+ return 1;
+ }
/* write_init_super will close 'dfd' */
if (tst->ss->external)
/* mdmon will write the metadata */
/* update the metadata to include new device, either at create or
* when hot-adding a spare.
*/
- void (*add_to_super)(struct supertype *st, mdu_disk_info_t *dinfo,
+ int (*add_to_super)(struct supertype *st, mdu_disk_info_t *dinfo,
int fd, char *devname);
/* Write metadata to one device when fixing problems or adding
/* add a device to a container, either while creating it or while
* expanding a pre-existing container
*/
-static void add_to_super_ddf(struct supertype *st,
+static int add_to_super_ddf(struct supertype *st,
mdu_disk_info_t *dk, int fd, char *devname)
{
struct ddf_super *ddf = st->sb;
if (ddf->currentconf) {
add_to_super_ddf_bvd(st, dk, fd, devname);
- return;
+ return 0;
}
/* This is device numbered dk->number. We need to create
fprintf(stderr, Name
": %s could allocate buffer for new disk, aborting\n",
__func__);
- abort();
+ return 1;
}
dd->major = major(stb.st_rdev);
dd->minor = minor(stb.st_rdev);
ddf->dlist = dd;
ddf->updates_pending = 1;
}
+
+ return 0;
}
/*
}
#ifndef MDASSEMBLE
-static void add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
+static int add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk,
int fd, char *devname)
{
struct intel_super *super = st->sb;
break;
if (!dl || ! (dk->state & (1<<MD_DISK_SYNC)))
- return;
+ return 1;
/* add a pristine spare to the metadata */
if (dl->index < 0) {
sum = __gen_imsm_checksum(mpb);
mpb->family_num = __cpu_to_le32(sum);
}
+
+ return 0;
}
-static void add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
+static int add_to_super_imsm(struct supertype *st, mdu_disk_info_t *dk,
int fd, char *devname)
{
struct intel_super *super = st->sb;
int rv;
struct stat stb;
- if (super->current_vol >= 0) {
- add_to_super_imsm_volume(st, dk, fd, devname);
- return;
- }
+ if (super->current_vol >= 0)
+ return add_to_super_imsm_volume(st, dk, fd, devname);
fstat(fd, &stb);
dd = malloc(sizeof(*dd));
if (!dd) {
fprintf(stderr,
Name ": malloc failed %s:%d.\n", __func__, __LINE__);
- abort();
+ return 1;
}
memset(dd, 0, sizeof(*dd));
dd->major = major(stb.st_rdev);
dd->next = super->disks;
super->disks = dd;
}
+
+ return 0;
}
static int store_imsm_mpb(int fd, struct intel_super *super);
#ifndef MDASSEMBLE
/* Add a device to the superblock being created */
-static void add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
+static int add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo,
int fd, char *devname)
{
mdp_super_t *sb = st->sb;
di->disk = *dinfo;
di->next = NULL;
*dip = di;
+
+ return 0;
}
#endif
};
#ifndef MDASSEMBLE
/* Add a device to the superblock being created */
-static void add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
+static int add_to_super1(struct supertype *st, mdu_disk_info_t *dk,
int fd, char *devname)
{
struct mdp_superblock_1 *sb = st->sb;
di->disk = *dk;
di->next = NULL;
*dip = di;
+
+ return 0;
}
#endif