- * The best place for the mapfile wold be /var/run/mdadm/map. However
- * it is needed during initramfs early-boot, and /var/run doesn't exist there
- * and certainly doesn't persist through to normal boot.
- * So we store it in /dev/.mdadm/map but allow this to be changed at
- * compile time. via MAP_DIR and MAP_FILE
- *
+ * The best place for the mapfile is /run/mdadm/map. Distros and users
+ * which have not switched to /run yet can choose a different location
+ * at compile time via MAP_DIR and MAP_FILE.
- if (mel->devnum < 0)
- fprintf(f, "mdp%d ", -1-mel->devnum);
- else
- fprintf(f, "md%d ", mel->devnum);
+ fprintf(f, "%s ", mel->devnm);
fprintf(f, "%s ", mel->metadata);
fprintf(f, "%08x:%08x:%08x:%08x ", mel->uuid[0],
mel->uuid[1], mel->uuid[2], mel->uuid[3]);
fprintf(f, "%s ", mel->metadata);
fprintf(f, "%08x:%08x:%08x:%08x ", mel->uuid[0],
mel->uuid[1], mel->uuid[2], mel->uuid[3]);
- int devnum, char *metadata, int uuid[4], char *path)
+ char * devnm, char *metadata, int uuid[4], char *path)
strcpy(me->metadata, metadata);
memcpy(me->uuid, uuid, 16);
strcpy(me->metadata, metadata);
memcpy(me->uuid, uuid, 16);
- if (sscanf(buf, " %3[mdp]%d %s %x:%x:%x:%x %200s",
- nam, &devnum, metadata, uuid, uuid+1,
+ if (sscanf(buf, " %s %s %x:%x:%x:%x %200s",
+ devnm, metadata, uuid, uuid+1,
- if (strncmp(nam, "md", 2) != 0)
- continue;
- if (nam[2] == 'p')
- devnum = -1 - devnum;
- map_add(melp, devnum, metadata, uuid, path);
+ map_add(melp, devnm, metadata, uuid, path);
-int map_update(struct map_ent **mpp, int devnum, char *metadata,
+int map_update(struct map_ent **mpp, char *devnm, char *metadata,
strcpy(mp->metadata, metadata);
memcpy(mp->uuid, uuid, 16);
free(mp->path);
strcpy(mp->metadata, metadata);
memcpy(mp->uuid, uuid, 16);
free(mp->path);
- map_add(&map, devnum, metadata, uuid, path);
+ map_add(&map, devnm, metadata, uuid, path);
for (mp = *map ; mp ; mp = mp->next) {
if (memcmp(uuid, mp->uuid, 16) != 0)
continue;
for (mp = *map ; mp ; mp = mp->next) {
if (memcmp(uuid, mp->uuid, 16) != 0)
continue;
struct mdstat_ent *mdstat = mdstat_read(0, 0);
struct mdstat_ent *md;
struct map_ent *map = NULL;
struct mdstat_ent *mdstat = mdstat_read(0, 0);
struct mdstat_ent *md;
struct map_ent *map = NULL;
- info = st->ss->container_content(st, subarray);
+ if (subarray)
+ info = st->ss->container_content(st, subarray);
+ else {
+ info = xmalloc(sizeof(*info));
+ st->ss->getinfo_super(st, info, NULL);
+ }
+ if (!info)
+ continue;
- if (md->devnum >= 0)
- path = map_dev(MD_MAJOR, md->devnum, 0);
- else
- path = map_dev(mdp, (-1-md->devnum)<< 6, 0);
+ devid = devnm2devid(md->devnm);
+ path = map_dev(major(devid), minor(devid), 0);
if (path == NULL ||
strncmp(path, "/dev/md/", 8) != 0) {
/* We would really like a name that provides
* an MD_DEVNAME for udev.
* The name needs to be unique both in /dev/md/
* and in this mapfile.
if (path == NULL ||
strncmp(path, "/dev/md/", 8) != 0) {
/* We would really like a name that provides
* an MD_DEVNAME for udev.
* The name needs to be unique both in /dev/md/
* and in this mapfile.
+ if (homehost && unum == -1 &&
+ strncmp(name, homehost,
+ strlen(homehost)) == 0 &&
+ name[strlen(homehost)] == ':')
+ name += strlen(homehost)+1;