char ver[100];
strcat(strcpy(ver, "external:"),
info.text_version);
- if (st->ss->external == 2) {
+ if (st->ss->external && st->subarray[0]) {
/* member */
/* When creating a member, we need to be careful
strcasecmp(dv->devname, "missing")==0)
continue;
- if (st->ss->external == 2)
+ if (st->ss->external && st->subarray[0])
fd = open(dv->devname, O_RDWR, 0);
else
fd = open(dv->devname, O_RDWR|O_EXCL,0);
}
if (verbose >= 0)
fprintf(stderr, Name ": array %s started.\n", mddev);
- if (st->ss->external == 2) {
+ if (st->ss->external && st->subarray[0]) {
if (need_mdmon) {
int dn = st->container_dev;
int i;
return 1;
case 'a':
/* add the device */
- if (tst == &supertype_container_member) {
+ if (tst->subarray[0]) {
fprintf(stderr, Name ": Cannot add disks to a"
" \'member\' array, perform this"
" operation on the parent container\n");
case 'r':
/* hot remove */
- if (tst == &supertype_container_member) {
+ if (tst->subarray[0]) {
fprintf(stderr, Name ": Cannot remove disks from a"
" \'member\' array, perform this"
" operation on the parent container\n");
int minor_version;
int max_devs;
int container_dev; /* devnum of container */
+ char subarray[32]; /* name of array inside container */
void *sb;
void *info;
};
-extern struct supertype supertype_container_member;
extern struct supertype *super_by_fd(int fd);
extern struct supertype *guess_super(int fd);
extern struct supertype *dup_super(struct supertype *st);
if (load_super_ddf_all(st, fd, &st->sb, devname, 1) == 0)
return 0;
#endif
+ if (st->subarray[0])
+ return 1; /* FIXME Is this correct */
if (get_dev_size(fd, devname, &dsize) == 0)
return 1;
vcl = malloc(offsetof(struct vcl, conf) + ddf->conf_rec_len * 512);
vcl->lba_offset = (__u64*) &vcl->conf.phys_refnum[ddf->mppe];
vcl->vcnum = venum;
+ sprintf(st->subarray, "%d", venum);
vcl->block_sizes = NULL; /* FIXME not for CONCAT */
vc = &vcl->conf;
seq = load_ddf_local(dfd, super, NULL, keep_fd);
if (!keep_fd) close(dfd);
}
+ if (st->subarray[0]) {
+ struct vcl *v;
+
+ for (v = super->conflist; v; v = v->next)
+ if (v->vcnum == atoi(st->subarray))
+ super->newconf = v;
+ if (!super->newconf)
+ return 1;
+ }
*sbp = super;
if (st->ss == NULL) {
st->ss = &super_ddf_container;
close(dfd);
}
+ if (st->subarray[0]) {
+ /* FIXME */
+ }
+
*sbp = super;
if (st->ss == NULL) {
st->ss = &super_imsm_container;
if (load_super_imsm_all(st, fd, &st->sb, devname, 1) == 0)
return 0;
#endif
+ if (st->subarray[0])
+ return 1; /* FIXME */
super = alloc_super(0);
if (!super) {
free_super0(st);
+ if (st->subarray[0])
+ return 1;
+
if (!get_dev_size(fd, devname, &dsize))
return 1;
free_super1(st);
+ if (st->subarray[0])
+ return 1;
+
if (st->ss == NULL || st->minor_version == -1) {
int bestvers = -1;
struct supertype tst;
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)
-struct supertype supertype_container_member;
-
struct supertype *super_by_fd(int fd)
{
mdu_array_info_t array;
char *verstr;
char version[20];
int i;
+ char *subarray = NULL;
sra = sysfs_read(fd, 0, GET_VERSION);
sprintf(version, "%d.%d", vers, minor);
verstr = version;
}
- if (minor == -2 && verstr[0] == '/')
- st = &supertype_container_member;
- else
- for (i = 0; st == NULL && superlist[i] ; i++)
- st = superlist[i]->match_metadata_desc(verstr);
+ if (minor == -2 && verstr[0] == '/') {
+ char *dev = verstr+1;
+ subarray = strchr(dev, '/');
+ int devnum;
+ if (subarray)
+ *subarray++ = '\0';
+ if (strncmp(dev, "md_d", 4) == 0)
+ devnum = -1-atoi(dev+4);
+ else
+ devnum = atoi(dev+2);
+ subarray = strdup(subarray);
+ if (sra)
+ sysfs_free(sra);
+ sra = sysfs_read(-1, devnum, GET_VERSION);
+ verstr = sra->text_version ? : "-no-metadata-";
+ }
+
+ for (i = 0; st == NULL && superlist[i] ; i++)
+ st = superlist[i]->match_metadata_desc(verstr);
if (sra)
sysfs_free(sra);
- if (st)
+ if (st) {
st->sb = NULL;
+ if (subarray) {
+ strncpy(st->subarray, subarray, 32);
+ st->subarray[31] = 0;
+ free(subarray);
+ } else
+ st->subarray[0] = 0;
+ }
return st;
}
#endif /* !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) */
st->ss = orig->ss;
st->max_devs = orig->max_devs;
st->minor_version = orig->minor_version;
+ strcpy(st->subarray, orig->subarray);
st->sb = NULL;
st->info = NULL;
return st;