From f2e55eccfb92969c3e11bc5d4883315f2e866a14 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 4 Nov 2008 20:51:12 +1100 Subject: mdopen: use small sequence number for uniquifying array names. Rather than appending the md minor number, we now append a small sequence number to make sure name in /dev/md/ that aren't LOCAL are unique. As the map file is locked while we do this, we are sure of no losing any races. Signed-off-by: NeilBrown --- mapfile.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'mapfile.c') diff --git a/mapfile.c b/mapfile.c index 1c2dc52..6169d52 100644 --- a/mapfile.c +++ b/mapfile.c @@ -245,3 +245,18 @@ struct map_ent *map_by_devnum(struct map_ent **map, int devnum) return mp; return NULL; } + +struct map_ent *map_by_name(struct map_ent **map, char *name) +{ + struct map_ent *mp; + if (!*map) + map_read(map); + + for (mp = *map ; mp ; mp = mp->next) { + if (strncmp(mp->path, "/dev/md/", 8) != 0) + continue; + if (strcmp(mp->path+8, name) == 0) + return mp; + } + return NULL; +} -- cgit v1.2.1