On Fri, Oct 19, 2001 at 05:00:16PM +0200, Poul-Henning Kamp wrote:
> Sounds like the bug is the md driver cloning "md10ec" which it shouldn't
> do.  This bug must naturally be in md_clone(), but I don't have the
> minutes right now to hunt it down.
> Should be quite simple to nail, it's just some string handling code.

        I might be missing something again, so please be kind :).

        First, there is not such function md_clone(), so I assume you mean

        My analysis of this is that devfs_lookupx() attempts to have the driver
        create any files that it does not have nodes for:

                EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev);
                on line 339 of devfs_vnops.c.

        The invoke will eventually end up calling disk_clone() which will attempt
        to create the device, and then devfs_lookupx() will happily make the file

        The code in disk_clone() looks for a device name that matches the start of
        the name we are looking up, and if it finds it tries to make sure the
        remander of the name matches the proper disk device naming convention.
        If it does end up matching then it creates the minor device with the name
        given.  The problem is that it does not verify that the given name does not
        contain any characters after the partition.  So instead of seeing md10ec it
        only sees md10e, and passes it on to make_dev().  The real issue is that the
        minor number for md10ec and md10e are the same, so of course make_dev() is
        unhappy when makedev() returns an named dev_t.

        My original patch silently cut off the last part of the file name, which is
        probably not correct.  IMHO the code should fail first, ask questions later.
        Dima's patch from around the end of July handles it properly I believe.

        Something like this:

@@ -82,6 +82,11 @@
                                p = name[i] - 'a';
+                       if (name[i + 1] != '\0') {
+                               printf("WARNING: bad device name (\"%s\")\n", name);
+                               return;
+                       }
                *dev = make_dev(pdev->si_devsw, dkmakeminor(u, s, p), 

        Note that this has nothing to do with md.  Any device that is cloned by
        disk_clone() will do the same thing.  Just doing an ls -l ad2eeec followed
        by ls -l ad2e will print the same "Driver mistake" message.

Chad David        [EMAIL PROTECTED]
ACNS Inc.         Calgary, Alberta Canada

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to