summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2013-01-07 10:17:04 +1100
committerNeilBrown <neilb@suse.de>2013-01-07 10:17:04 +1100
commit06d2ffc3e266eea0cbd157ccc3e497c7b9f4bdd3 (patch)
tree1d328642932691c9d1912a53062014ba5fea1c07 /util.c
parent6d388a88163a8f532513e73dd035892ea8a8ead2 (diff)
conditionally remove map_dev from find_free_devnum
map_dev can be slow so it is best to not call it when not necessary. The final test in "find_free_devnum" is not relevant when udev is being used, so remove the test in that case. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/util.c b/util.c
index 6c10365e..70ab6f12 100644
--- a/util.c
+++ b/util.c
@@ -839,7 +839,6 @@ int find_free_devnum(int use_partitions)
int devnum;
for (devnum = 127; devnum != 128;
devnum = devnum ? devnum-1 : (1<<20)-1) {
- char *dn;
int _devnum;
char nbuf[50];
@@ -849,11 +848,14 @@ int find_free_devnum(int use_partitions)
sprintf(nbuf, "%s%d", use_partitions?"mdp":"md", devnum);
if (!conf_name_is_free(nbuf))
continue;
- /* make sure it is new to /dev too, at least as a
- * non-standard */
- dn = map_dev(dev2major(_devnum), dev2minor(_devnum), 0);
- if (dn && ! is_standard(dn, NULL))
- continue;
+ if (!use_udev()) {
+ /* make sure it is new to /dev too, at least as a
+ * non-standard */
+ char *dn = map_dev(dev2major(_devnum),
+ dev2minor(_devnum), 0);
+ if (dn && ! is_standard(dn, NULL))
+ continue;
+ }
break;
}
if (devnum == 128)