possible bug in mdev (r21557)

Denys Vlasenko vda.linux at googlemail.com
Mon May 26 12:45:29 UTC 2008


On Monday 26 May 2008 03:58, Daniel Mierswa wrote:
> Ok this is going to take a while i guess. First i created an initramfs 
> (with busybox 1.10.2) on an arm machine using a debian kernel 
> 2.6.18-ixp4xx for the NSLU2 of a friend and it just couldn't come up. 
> We've tried several things (it uses USB devices for rootfs) but i could 
> find out where it went wrong. The mount failed. So i checked with ls if 
> the device nodes are actually created and they were. Now i tried a new 
> initramfs for my machine since i updated to 2.6.25.4 recently and 
> earlier LVM versions don't play well with that. Again, I've used busybox 
> 1.10.2 and what my initramfs basically does is using mdev for initial 
> population of /dev and /bin/mdev for hotplugging. After that I'm waiting 
> for usb devices to become ready (by using a loop with blkid in it) if 
> blkid succeeded I'm using that device. I tried several versions of blkid 
> and kernels (with dietlibc, glibc, uclibc, statically linked, 
> dynamically linked) and they all won't show the device when asked for 
> with blkid. I've checked for the presence of the device nodes and they 
> were also there. Then I've tried busybox-1.8.3 and see there, it worked. 

1.8.3 was determining whether device is char or block just by looking
at 5th char (path is "/dev/something"):

        type = path[5]=='c' ? S_IFCHR : S_IFBLK;

But it caused problems, not only devices with 'c' in 5th char
are character devices. Now we do it like this:

        /* http://kernel.org/doc/pending/hotplug.txt says that only
         * "/sys/block/..." is for block devices. "/sys/bus" etc is not!
         * Since kernel 2.6.25 block devices are also in /sys/class/block. */
        if (strncmp(&path[5], "block/", 6) != 0
         && strncmp(&path[5], "class/block/", 12) != 0)
                type = S_IFCHR;
        else
                type = S_IFBLK;

So, if device is not "/dev/block/..." and not "/dev/class/block/...",
it will be created as a char dev. Otherwise, as a block dev.

It looks like your device is created with wrong type.

> :) So i did a git-svn clone -r20000:HEAD and git-bisect the whole thing 
> and it all comes down to one revision where it stopped working which is 
> 21557 - 
> http://busybox.net/cgi-bin/viewcvs.cgi/trunk/busybox/util-linux/mdev.c?rev=21557&view=diff&r1=21557&r2=21556&p1=trunk/busybox/util-linux/mdev.c&p2=/trunk/busybox/util-linux/mdev.c).
> Is there a chance that this could be fixed?

Yes. Please find out what path is passed by kernel to mdev for your device.
Replace mdev.c with the attached file. It has the following
debug printout added:

static void make_device(char *path, int delete)
{
...
        /* Determine device name, type, major and minor */
        device_name = bb_basename(path);
bb_error_msg("PATH '%s' DEVICE NAME '%s'", path, device_name);

Rebuild busybox, run the boot process and let the mailing list
know what you see.
--
vda
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mdev.c
Type: text/x-csrc
Size: 11358 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20080526/5e40281e/attachment-0002.c 


More information about the busybox mailing list