c = map_num(pers, array.level);
if (export) {
- if (c)
- printf("MD_LEVEL=%s\n", c);
- printf("MD_DEVICES=%d\n", array.raid_disks);
- if (sra && sra->array.major_version < 0)
- printf("MD_METADATA=%s\n", sra->text_version);
- else
- printf("MD_METADATA=%d.%02d\n",
- array.major_version, array.minor_version);
+ if (array.raid_disks) {
+ if (c)
+ printf("MD_LEVEL=%s\n", c);
+ printf("MD_DEVICES=%d\n", array.raid_disks);
+ } else {
+ printf("MD_LEVEL=container\n");
+ printf("MD_DEVICES=%d\n", array.nr_disks);
+ }
+ if (container) {
+ printf("MD_CONTAINER=%s\n", container);
+ printf("MD_MEMBER=%s\n", member);
+ } else {
+ if (sra && sra->array.major_version < 0)
+ printf("MD_METADATA=%s\n", sra->text_version);
+ else
- printf("MD_METADATA=%02d.%02d\n",
++ printf("MD_METADATA=%d.%02d\n",
+ array.major_version, array.minor_version);
+ }
+
+ if (st && st->sb) {
+ struct mdinfo info;
+ char nbuf[64];
+ st->ss->getinfo_super(st, &info);
+ fname_from_uuid(st, &info, nbuf, ':');
+ printf("MD_UUID=%s\n", nbuf+5);
- if (st && st->sb)
- st->ss->export_detail_super(st);
+ if (st->ss->export_detail_super)
+ st->ss->export_detail_super(st);
+ }
goto out;
}
if (brief) {
mdu_bitmap_file_t bmf;
- printf("ARRAY %s level=%s num-devices=%d", dev,
- c?c:"-unknown-",
- array.raid_disks );
- if (sra && sra->array.major_version < 0)
- printf(" metadata=%s", sra->text_version);
+ if (array.raid_disks)
+ printf("ARRAY %s level=%s num-devices=%d", dev,
+ c?c:"-unknown-",
+ array.raid_disks );
else
- printf(" metadata=%d.%02d",
- array.major_version, array.minor_version);
+ printf("ARRAY %s level=container num-devices=%d",
+ dev, array.nr_disks);
+
+ if (container) {
+ printf(" container=%s", container);
+ printf(" member=%s", member);
+ } else {
+ if (sra && sra->array.major_version < 0)
+ printf(" metadata=%s", sra->text_version);
+ else
- printf(" metadata=%02d.%02d",
++ printf(" metadata=%d.%02d",
+ array.major_version, array.minor_version);
+ }
/* Only try GET_BITMAP_FILE for 0.90.01 and later */
if (vers >= 9001 &&
if (sra && sra->array.major_version < 0)
printf(" Version : %s\n", sra->text_version);
else
- printf(" Version : %02d.%02d\n",
+ printf(" Version : %d.%02d\n",
array.major_version, array.minor_version);
+ }
atime = array.ctime;
- printf(" Creation Time : %.24s\n", ctime(&atime));
+ if (atime)
+ printf(" Creation Time : %.24s\n", ctime(&atime));
if (array.raid_disks == 0) c = "container";
printf(" Raid Level : %s\n", c?c:"-unknown-");
if (larray_size)
int dfd, mdfd;
char *avail;
int active_disks;
+ int uuid_for_name = 0;
+ char *name_to_use;
+ char nbuf[64];
+
struct createinfo *ci = conf_get_create_info();
- char *name;
- if (autof == 0)
- autof = ci->autof;
- /* 1/ Check if devices is permitted by mdadm.conf */
+ /* 1/ Check if device is permitted by mdadm.conf */
if (!conf_test_dev(devname)) {
if (verbose >= 0)
match = array_list;
}
- /* 3a/ if not, check for homehost match. If no match, reject. */
+ /* 3a/ if not, check for homehost match. If no match, continue
+ * but don't trust the 'name' in the array. Thus a 'random' minor
+ * number will be assigned, and the device name will be based
+ * on that. */
- name = info.name;
if (!match) {
if (homehost == NULL ||
- st->ss->match_home(st, homehost) == 0) {
- if (verbose >= 0)
- fprintf(stderr, Name
- ": not found in mdadm.conf and not identified by homehost.\n");
- name = NULL;
- }
+ st->ss->match_home(st, homehost) != 1)
+ uuid_for_name = 1;
}
/* 4/ Determine device number. */
- /* - If in mdadm.conf with std name, use that */
- /* - UUID in /var/run/mdadm.map use that */
+ /* - If in mdadm.conf with std name, get number from name. */
+ /* - UUID in /var/run/mdadm.map get number from mapping */
/* - If name is suggestive, use that. unless in use with */
/* different uuid. */
/* - Choose a free, high number. */
/* - Use a partitioned device unless strong suggestion not to. */
/* e.g. auto=md */
+ mp = map_by_uuid(&map, info.uuid);
+
+ if (uuid_for_name && ! mp) {
+ name_to_use = fname_from_uuid(st, &info, nbuf, '-');
+ if (verbose >= 0)
+ fprintf(stderr, Name
+ ": not found in mdadm.conf and not identified by homehost"
+ " - using uuid based name\n");
+ } else
+ name_to_use = info.name;
- if (match && is_standard(match->devname, &devnum))
- /* We have devnum now */;
- else if (mp != NULL)
+ /* There are three possible sources for 'autof': command line,
+ * ARRAY line in mdadm.conf, or CREATE line in mdadm.conf.
+ * They have precedence in that order.
+ */
+ if (autof == 0 && match)
+ autof = match->autof;
+ if (autof == 0)
+ autof = ci->autof;
+
+ if (match && (rv = is_standard(match->devname, &devnum))) {
+ devnum = (rv > 0) ? (-1-devnum) : devnum;
- } else if ((mp = map_by_uuid(&map, info.uuid)) != NULL)
++ } else if (mp != NULL)
devnum = mp->devnum;
else {
/* Have to guess a bit. */
close(bmfd);
}
sra = sysfs_read(mdfd, devnum, 0);
- if (sra == NULL || active_disks >= info.array.working_disks)
+ if ((sra == NULL || active_disks >= info.array.working_disks)
- && name != NULL)
++ && uuid_for_name == 0)
rv = ioctl(mdfd, RUN_ARRAY, NULL);
else
rv = sysfs_set_str(sra, NULL,