for (part = 0; part < 16; part++) {
if (part) {
sprintf(be, "p%d", part);
- if (isdigit(pe[-1]))
- sprintf(pe, "p%d", part);
- else
- sprintf(pe, "%d", part);
+ if (path) {
+ if (isdigit(pe[-1]))
+ sprintf(pe, "p%d", part);
+ else
+ sprintf(pe, "%d", part);
+ }
}
/* FIXME test if really is md device ?? */
unlink(base);
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)) {
+ close(dfd);
+ return 1;
+ }
/* write_init_super will close 'dfd' */
if (tst->ss->external)
/* mdmon will write the metadata */
" to container - odd\n");
return 1;
}
- if (!sysfs_unique_holder(dnum, stb.st_rdev)) {
+ /* in the detached case it is not possible to
+ * check if we are the unique holder, so just
+ * rely on the 'detached' checks
+ */
+ if (strcmp(dv->devname, "detached") == 0 ||
+ sysfs_unique_holder(dnum, stb.st_rdev))
+ /* pass */;
+ else {
fprintf(stderr, Name
": %s is %s, cannot remove.\n",
dnprintable,