[klibc] create_dev and raid

Aaron Griffin aaronmgriffin at gmail.com
Mon May 8 00:12:28 PDT 2006


Yet another one of those "it would make sense it" posts.

Currently, create_dev in do_mounts.c simply unlinks the device and recreates it.

This doesn't seem right.  If /dev/hda3 has already been created, by
some early-userspace app (udev), there's no need to unlink or even
parse the name again.  Now, when talking about simple block devices,
this doesn't make much of a difference (except when you take into
account the FS-mount looping).  However, if you take a look at 
do_mounts_md, if the raid array has already been assembled (say, for
instance, because the array was encrypted, or part of an lvm group),
kinit will again try to assemble it, spit out a mess of error
messages, and carry on.

The addition of a simple check in the md loop would fix this issue
[see below].  The reason being that, even if /dev/md0 is not identical
to the way kinit would have created it, it has been assembled by
early-userland apps and is probably supposed to be overridden.

--- do_mounts_md.c      2006-05-08 01:51:02.000000000 -0500
+++ do_mounts_md.old    2006-05-08 02:07:35.000000000 -0500
@@ -222,7 +222,6 @@
                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;
@@ -231,8 +230,6 @@
                snprintf(name, sizeof name,
                         "/dev/md%s%d", partitioned?"_d":"", dev_minor);

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



More information about the klibc mailing list