summaryrefslogtreecommitdiff
path: root/lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib.c b/lib.c
index 2739b3d3..c04f6a07 100644
--- a/lib.c
+++ b/lib.c
@@ -188,8 +188,11 @@ int nftw(const char *path, int (*han)(const char *name, const struct stat *stb,
* If we find multiple names, choose the shortest.
* If we find a name in /dev/md/, we prefer that.
* This applies only to names for MD devices.
+ * If 'prefer' is set (normally to e.g. /by-path/)
+ * then we prefer a name which contains that string.
*/
-char *map_dev(int major, int minor, int create)
+char *map_dev_preferred(int major, int minor, int create,
+ char *prefer)
{
struct devmap *p;
char *regular = NULL, *preferred=NULL;
@@ -219,7 +222,8 @@ char *map_dev(int major, int minor, int create)
for (p=devlist; p; p=p->next)
if (p->major == major &&
p->minor == minor) {
- if (strncmp(p->name, "/dev/md/",8) == 0) {
+ if (strncmp(p->name, "/dev/md/",8) == 0
+ || (prefer && strstr(p->name, prefer))) {
if (preferred == NULL ||
strlen(p->name) < strlen(preferred))
preferred = p->name;
@@ -243,6 +247,7 @@ char *map_dev(int major, int minor, int create)
}
+
/* conf_word gets one word from the conf file.
* if "allow_key", then accept words at the start of a line,
* otherwise stop when such a word is found.