if (ioctl(fd, GET_ARRAY_INFO, &array)) {
fprintf(stderr, Name ": cannot get array info for %s\n",
devname);
- return 1;
+ goto abort;
}
/* array.size is only 32 bit and may be truncated.
if (!tst) {
fprintf(stderr, Name ": unsupport array - version %d.%d\n",
array.major_version, array.minor_version);
- return 1;
+ goto abort;
}
stb.st_rdev = 0;
fprintf(stderr, Name ": %s only meaningful "
"with -r, not -%c\n",
dv->devname, dv->disposition);
- return 1;
+ goto abort;
}
for (; j < 1024 && remaining_disks > 0; j++) {
unsigned dev;
fprintf(stderr, Name ": %s only meaningful "
"with -r of -f, not -%c\n",
dv->devname, dv->disposition);
- return 1;
+ goto abort;
}
for (; j < 1024 && remaining_disks > 0; j++) {
int sfd;
if (dv->disposition != 'a' || dv->re_add == 0) {
fprintf(stderr, Name ": 'missing' only meaningful "
"with --re-add\n");
- return 1;
+ goto abort;
}
if (add_devlist == NULL)
add_devlist = conf_get_devs();
fprintf(stderr, Name ": %s only meaningful "
"with -r or -f, not -%c\n",
dv->devname, dv->disposition);
- return 1;
+ goto abort;
}
sprintf(dname, "dev-%s", dv->devname);
fprintf(stderr, Name ": %s does not appear "
"to be a component of %s\n",
dv->devname, devname);
- return 1;
+ goto abort;
}
}
} else {
dv->devname, strerror(errno));
if (tfd >= 0)
close(tfd);
- return 1;
+ goto abort;
}
close(tfd);
tfd = -1;
fprintf(stderr, Name ": %s is not a "
"block device.\n",
dv->devname);
- return 1;
+ goto abort;
}
}
switch(dv->disposition){
default:
fprintf(stderr, Name ": internal error - devmode[%s]=%d\n",
dv->devname, dv->disposition);
- return 1;
+ goto abort;
case 'a':
/* add the device */
if (subarray) {
fprintf(stderr, Name ": Cannot add disks to a"
" \'member\' array, perform this"
" operation on the parent container\n");
- return 1;
+ goto abort;
}
/* Make sure it isn't in use (in 2.6 or later) */
tfd = dev_open(add_dev, O_RDONLY|O_EXCL|O_DIRECT);
if (tfd < 0) {
fprintf(stderr, Name ": Cannot open %s: %s\n",
dv->devname, strerror(errno));
- return 1;
+ goto abort;
}
st = dup_super(tst);
if (!get_dev_size(tfd, dv->devname, &ldsize)) {
st->ss->free_super(st);
close(tfd);
- return 1;
+ goto abort;
}
} else if (!get_dev_size(tfd, NULL, &ldsize)) {
st->ss->free_super(st);
add_dev, devname);
st->ss->free_super(st);
close(tfd);
- return 1;
+ goto abort;
}
fprintf(stderr, Name
": %s is larger than %s can "
fprintf(stderr, Name ": hot add failed for %s: %s\n",
add_dev, strerror(errno));
- return 1;
+ goto abort;
}
if (array.not_persistent == 0 || tst->ss->external) {
close(tfd);
st->ss->free_super(st);
fprintf(stderr, Name ": cannot load array metadata from %s\n", devname);
- return 1;
+ goto abort;
}
/* Make sure device is large enough */
continue;
fprintf(stderr, Name ": %s not large enough to join array\n",
dv->devname);
- return 1;
+ goto abort;
}
/* Possibly this device was recently part of the array
fprintf(stderr, Name ": failed to open %s for"
" superblock update during re-add\n", dv->devname);
st->ss->free_super(st);
- return 1;
+ goto abort;
}
if (dv->writemostly == 1)
fprintf(stderr, Name ": failed to update"
" superblock during re-add\n");
st->ss->free_super(st);
- return 1;
+ goto abort;
}
}
/* don't even try if disk is marked as faulty */
st->ss->free_super(st);
if (add_dev != dv->devname)
continue;
- return 1;
+ goto abort;
}
skip_re_add:
re_add_failed = 1;
fprintf(stderr, Name
": --re-add for %s to %s is not possible\n",
dv->devname, devname);
- return 1;
+ goto abort;
}
if (re_add_failed) {
fprintf(stderr, Name ": %s reports being an active member for %s, but a --re-add fails.\n",
dv->devname);
if (tfd >= 0)
close(tfd);
- return 1;
+ goto abort;
}
} else {
/* non-persistent. Must ensure that new drive
dv->devname);
if (tfd >= 0)
close(tfd);
- return 1;
+ goto abort;
}
}
/* committed to really trying this device now*/
if (tst->ss->add_to_super(tst, &disc, dfd,
dv->devname)) {
close(dfd);
- return 1;
+ goto abort;
}
if (tst->ss->write_init_super(tst)) {
close(dfd);
- return 1;
+ goto abort;
}
} else if (dv->re_add) {
/* this had better be raid1.
" could not get exclusive access to container\n",
dv->devname);
tst->ss->free_super(tst);
- return 1;
+ goto abort;
}
dfd = dev_open(dv->devname, O_RDWR | O_EXCL|O_DIRECT);
dv->devname)) {
close(dfd);
close(container_fd);
- return 1;
+ goto abort;
}
if (tst->update_tail)
flush_metadata_updates(tst);
dv->devname);
close(container_fd);
tst->ss->free_super(tst);
- return 1;
+ goto abort;
}
sra->array.level = LEVEL_CONTAINER;
/* Need to set data_offset and component_size */
" failed for %s\n", dv->devname);
close(container_fd);
sysfs_free(sra);
- return 1;
+ goto abort;
}
ping_monitor_by_id(devnum);
sysfs_free(sra);
if (ioctl(fd, ADD_NEW_DISK, &disc)) {
fprintf(stderr, Name ": add new device failed for %s as %d: %s\n",
dv->devname, j, strerror(errno));
- return 1;
+ goto abort;
}
}
if (verbose >= 0)
" operation on the parent container\n");
if (sysfd >= 0)
close(sysfd);
- return 1;
+ goto abort;
}
if (tst->ss->external) {
/* To remove a device from a container, we must
" to container - odd\n");
if (sysfd >= 0)
close(sysfd);
- return 1;
+ goto abort;
}
/* in the detached case it is not possible to
* check if we are the unique holder, so just
errno == EEXIST ? "still in use":
"not a member");
close(lfd);
- return 1;
+ goto abort;
}
}
/* FIXME check that it is a current member */
strerror(errno));
if (lfd >= 0)
close(lfd);
- return 1;
+ goto abort;
}
if (tst->ss->external) {
/*
if (!name) {
fprintf(stderr, Name ": unable to get container name\n");
- return 1;
+ goto abort;
}
ping_manager(name);
dnprintable, strerror(errno));
if (sysfd >= 0)
close(sysfd);
- return 1;
+ goto abort;
}
if (sysfd >= 0)
close(sysfd);
if (test && count == 0)
return 2;
return 0;
+
+abort:
+ return 1;
}
int autodetect(void)