if (fd >=0) close(fd);
free(st->devname);
free(st);
+ put_md_name(st->devname);
continue;
}
close(fd);
activity,
map_num(pers, info.array.level),
mddev);
+ if (st->ss->major == 0)
+ put_md_name(mddev);
}
return 0;
}
if (num < 0) {
/* need to pick an unused number */
mdlist = mdstat_read(0, 0);
- for (num = 0 ; ; num++) {
+ /* Choose a large number. Start from 127 and search down,
+ * but if nothing is found, start really big
+ */
+ for (num = 127 ; num != 128 ; num = num ? num-1 : (1<<22)-1) {
struct mdstat_ent *me;
int devnum = num;
if (major != MD_MAJOR)
if (me->devnum == devnum)
break;
if (!me) {
- /* doesn't exist if mdstat.
+ /* doesn't exist in mdstat.
* make sure it is new to /dev too
*/
char *dn;
{
mdp_super_t *sb = sbv;
char *c=map_num(pers, sb->level);
+ char *nm;
printf("ARRAY %s level=%s num-devices=%d UUID=",
- get_md_name(sb->md_minor),
+ nm = get_md_name(sb->md_minor),
c?c:"-unknown-", sb->raid_disks);
if (sb->minor_version >= 90)
printf("%08x:%08x:%08x:%08x", sb->set_uuid0, sb->set_uuid1,
else
printf("%08x", sb->set_uuid0);
printf("\n");
+ put_md_name(nm);
}
static void detail_super0(void *sbv, char *homehost)
{
struct devmap *p;
char *std = NULL, *nonstd=NULL;
+ int did_check = 0;
+ retry:
if (!devlist_ready) {
char *dev = "/dev";
struct stat stb;
dev = "/dev/.";
nftw(dev, add_dev, 10, FTW_PHYS);
devlist_ready=1;
+ did_check = 1;
}
for (p=devlist; p; p=p->next)
nonstd = p->name;
}
}
+ if (!std && !nonstd && !did_check) {
+ devlist_ready = 0;
+ goto retry;
+ }
if (create && !std && !nonstd) {
static char buf[30];
snprintf(buf, 1024, "%d:%d", major, minor);