Some questions about mdev

Souf Oued souf_oued at yahoo.fr
Tue Aug 17 02:41:32 UTC 2010


  Le 16/08/2010 15:42, Alexander Griesser a écrit :
> On 16.08.2010 14:40, Denys Vlasenko wrote:
>>> Is that by design or am I missing something here? I have added mdev 
>>> to the
>>> kernel hotplug mechanism by doing that (of course):
>>>
>>> echo /sbin/mdev>/proc/sys/kernel/hotplug
>>
>> You need to debug the problem. Does mdev get called when you create
>> /dev/sda1 via fdisk?
>
> Yes, when I delete a partition, mdev gets called 4 times with the 
> following parameters:
>
> block
> block
> block
> block
>
> When I create a new partition, output is the same, but still,
> it doesn't add the device file to /dev (i.e. sda2), when I run `mdev -s`
> right after the fdisk command, the device files get created.
>
>
> Thanks to your debugging script, I found out something else
> I always wondered about.
>
> When I plugin a USB memory stick, mdev gets called 8 times
> in a row with the following parameters:
>
> usb
> usb
> scsi_host
> scsi
> scsi_disk
> scsi_device
> block
> bdi
>
> But `cat /proc/partitions` doesn't show the new device (should be sdb 
> and sdb1 according to the output of `dmesg`), also, running `mdev -s`
> manually doesn't help in this situation.
>
> When I unplug the USB memory stick, mdev gets called 8 times in
> a row with the following parameters:
>
> scsi_device
> scsi_disk
> bdi
> block
> scsi
> scsi_host
> usb
> usb
>
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox
>
This is normal, mdev is always called by the kernel with 
argv[1]=$SUBSYSTEM, I use it in modified version of mdev.
In my customized version of mdev I use one structure for all environment 
variables:

struct globals {
     int major;
     int minor;
     mode_t devmode;
     char *devname;
     char *devpath;
     char *subsystem;
} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define k_major        (G.major    )
#define k_minor        (G.minor    )
#define k_devmode    (G.devmode    )
#define k_devname    (G.devname    )
#define k_devpath    (G.devpath    )
#define k_subsystem    (G.subsystem    )
#define INIT_G() do { \
     k_major = -1; \
     k_minor = -1; \
     k_devmode = 0660; \
     k_devname = NULL; \
     k_devpath = NULL; \
     k_subsystem = NULL; \
} while (0)

When mdev is called by kernel as hotplug helper, I use getenv() :
k_major = = xstrtou(getenv("MAJOR"), 10);
k_minor = = xstrtou(getenv("MINOR"), 10);
k_devname = getenv("DEVNAME");

With mdev -s, I use uevent files instead of dev files to extract 
k_major, k_minor, k_devname and for some devices k_mode (null, full, 
zero, random, urandom).
The uevent file for null device:
MAJOR=1
MINOR=3
DEVNAME=null
DEVMODE=0666

uevent file file for timer device:
MAJOR=116
MINOR=2
DEVNAME=snd/timer

I also found when DEVNAME contains a slash, like snd/timer, this is the 
path under /dev and timer device is automatically created under 
/dev/snd/ and I do not need to specify it in mdev.conf.

if anyone is interested in my version I can send her a copy.
I AM SORRY FOR MY ENGLISH :-[

Regards.
Malek.


More information about the busybox mailing list