}
}
}
+
+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;
+}
extern char *conf_word(FILE *file, int allow_key);
extern void print_quoted(char *str);
extern void print_escape(char *str);
+extern int use_udev(void);
extern int conf_name_is_free(char *name);
extern int conf_verify_devnames(struct mddev_ident *array_list);
extern int devname_matches(char *name, char *match);
* If we cannot detect udev, we need to make
* devices and links ourselves.
*/
- if ((stat("/dev/.udev", &stb) != 0 && stat("/run/udev", &stb) != 0) ||
- check_env("MDADM_NO_UDEV")) {
+ if (!use_udev()) {
/* Make sure 'devname' exists and 'chosen' is a symlink to it */
if (lstat(devname, &stb) == 0) {
/* Must be the correct device, else error */
int devnum;
for (devnum = 127; devnum != 128;
devnum = devnum ? devnum-1 : (1<<20)-1) {
- char *dn;
int _devnum;
char nbuf[50];
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)