summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2005-06-14 00:14:24 +0000
committerNeil Brown <neilb@suse.de>2005-06-14 00:14:24 +0000
commit02bdee4f3beb7fda16fc09687025f3476d751c2f (patch)
tree650447ef5e0efaf09f2a69ff6d39195b93b0026f
parentd78d4a97b78ed1b732d84eac5acea907a63952fd (diff)
downloadmdadm-02bdee4f3beb7fda16fc09687025f3476d751c2f.tar.gz
mdadm-02bdee4f3beb7fda16fc09687025f3476d751c2f.tar.xz
mdadm-02bdee4f3beb7fda16fc09687025f3476d751c2f.zip
When finding a /dev name for a device, prefer shorter names
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
-rw-r--r--ChangeLog1
-rw-r--r--util.c22
2 files changed, 16 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index e85b583..2d4b709 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@ Changes Prior to 1.12.0 release
- Fix parsing of /dev/md/N in is_standard
- Fix rounding errors in human_size()
- Fix silly example in mdadm.conf-examples
+ - When finding a /dev name for a device, prefer shorter names
Changes Prior to 1.11.0 release
- Fix embarassing bug which causes --add to always fail.
diff --git a/util.c b/util.c
index add88de..a7dc7c7 100644
--- a/util.c
+++ b/util.c
@@ -478,12 +478,15 @@ int add_dev(const char *name, const struct stat *stb, int flag)
/*
* Find a block device with the right major/minor number.
- * Avoid /dev/mdNN and /dev/md/dNN if possible
+ * If we find multiple names, choose the shortest.
+ * If we find a non-standard name, it is probably there
+ * deliberately so prefer it over a standard name.
+ * This applies only to names for MD devices.
*/
char *map_dev(int major, int minor)
{
struct devmap *p;
- char *std = NULL;
+ char *std = NULL, *nonstd=NULL;
if (!devlist_ready) {
#ifndef __dietlibc__
nftw("/dev", add_dev, 10, FTW_PHYS);
@@ -496,12 +499,17 @@ char *map_dev(int major, int minor)
for (p=devlist; p; p=p->next)
if (p->major == major &&
p->minor == minor) {
- if (is_standard(p->name, NULL))
- std = p->name;
- else
- return p->name;
+ if (is_standard(p->name, NULL)) {
+ if (std == NULL ||
+ strlen(p->name) < strlen(std))
+ std = p->name;
+ } else {
+ if (nonstd == NULL ||
+ strlen(p->name) < strlen(nonstd))
+ nonstd = p->name;
+ }
}
- return std;
+ return nonstd ? nonstd : std;
}
#endif