[klibc] [patch] skip existing md devices

Aaron Griffin aaronmgriffin at gmail.com
Wed May 10 11:20:29 PDT 2006

The following patch will ignore already configured md devices in
kinit.  The rationale is that, if an md device already exists, it was
previously assembled by some other tool (e.g. mdadm) and should remain
there.  Currently, kinit removes it and attempts to recreate it, which
can cause all sorts of issues, especially in the situation that, the
md device is further encrypted and/or is an lvm volume.

Signed-off-by: Aaron Griffin <aaron at archlinux.org>

--- a/usr/kinit/do_mounts_md.c	2006-05-08 12:59:42.000000000 -0500
+++ b/usr/kinit/do_mounts_md.c	2006-05-10 11:07:08.000000000 -0500
@@ -222,6 +222,7 @@
 		char *devname;
 		mdu_disk_info_t dinfo;
 		char name[16];
+		struct stat st;

 		dev_minor = md_setup_args[ent].minor;
 		partitioned = md_setup_args[ent].partitioned;
@@ -230,6 +231,9 @@
 		snprintf(name, sizeof name,
 			 "/dev/md%s%d", partitioned?"_d":"", dev_minor);

+		if (stat(name,&st) == 0)
+			continue;
 		if (partitioned)
 			dev = makedev(mdp_major(), dev_minor << MdpMinorShift);

More information about the klibc mailing list