summaryrefslogtreecommitdiff
path: root/lib.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 /lib.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 'lib.c')
-rw-r--r--lib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 1c856541..8124fa1b 100644
--- a/lib.c
+++ b/lib.c
@@ -390,3 +390,16 @@ void print_escape(char *str)
}
}
}
+
+int use_udev(void)
+{
+ static int use = -1;
+ struct stat stb;
+
+ if (use < 0) {
+ use = ((stat("/dev/.udev", &stb) == 0
+ || stat("/run/udev", &stb) == 0)
+ && check_env("MDADM_NO_UDEV") == 0);
+ }
+ return use;
+}