summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/util.c b/util.c
index 35bb91bb..00bf8037 100644
--- a/util.c
+++ b/util.c
@@ -1,7 +1,7 @@
/*
* mdadm - manage Linux "md" devices aka RAID arrays.
*
- * Copyright (C) 2001-2006 Neil Brown <neilb@suse.de>
+ * Copyright (C) 2001-2009 Neil Brown <neilb@suse.de>
*
*
* This program is free software; you can redistribute it and/or modify
@@ -19,12 +19,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Neil Brown
- * Email: <neilb@cse.unsw.edu.au>
- * Paper: Neil Brown
- * School of Computer Science and Engineering
- * The University of New South Wales
- * Sydney, 2052
- * Australia
+ * Email: <neilb@suse.de>
*/
#include "mdadm.h"
@@ -511,14 +506,13 @@ int nftw(const char *path, int (*han)(const char *name, const struct stat *stb,
/*
* Find a block device with the right major/minor number.
* 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.
+ * If we find a name in /dev/md/, we prefer that.
* This applies only to names for MD devices.
*/
char *map_dev(int major, int minor, int create)
{
struct devmap *p;
- char *std = NULL, *nonstd=NULL;
+ char *regular = NULL, *preferred=NULL;
int did_check = 0;
if (major == 0 && minor == 0)
@@ -545,27 +539,27 @@ char *map_dev(int major, int minor, int create)
for (p=devlist; p; p=p->next)
if (p->major == major &&
p->minor == minor) {
- if (is_standard(p->name, NULL)) {
- if (std == NULL ||
- strlen(p->name) < strlen(std))
- std = p->name;
+ if (strncmp(p->name, "/dev/md/",8) == 0) {
+ if (preferred == NULL ||
+ strlen(p->name) < strlen(preferred))
+ preferred = p->name;
} else {
- if (nonstd == NULL ||
- strlen(p->name) < strlen(nonstd))
- nonstd = p->name;
+ if (regular == NULL ||
+ strlen(p->name) < strlen(regular))
+ regular = p->name;
}
}
- if (!std && !nonstd && !did_check) {
+ if (!regular && !preferred && !did_check) {
devlist_ready = 0;
goto retry;
}
- if (create && !std && !nonstd) {
+ if (create && !regular && !preferred) {
static char buf[30];
snprintf(buf, sizeof(buf), "%d:%d", major, minor);
- nonstd = buf;
+ regular = buf;
}
- return nonstd ? nonstd : std;
+ return preferred ? preferred : regular;
}
unsigned long calc_csum(void *super, int bytes)
@@ -916,7 +910,10 @@ struct supertype *super_by_fd(int fd)
if (sra)
sysfs_free(sra);
sra = sysfs_read(-1, devnum, GET_VERSION);
- verstr = sra->text_version ? : "-no-metadata-";
+ if (sra && sra->text_version[0])
+ verstr = sra->text_version;
+ else
+ verstr = "-no-metadata-";
}
for (i = 0; st == NULL && superlist[i] ; i++)