mdev

Andrew nitr0 at seti.kr.ua
Wed Jan 12 21:18:41 UTC 2011


12.01.2011 22:00, David Henderson пишет:
> David Henderson wrote:
>> Andrew wrote:
>>> 12.01.2011 20:28, David Henderson пишет:
>>>> Andrew wrote:
>>>>> 12.01.2011 18:15, David Henderson пишет:
>>>>>> So far in my project, I've been loading the kernel modules 
>>>>>> (drivers) manually in the startup scripts. This is, obviously, 
>>>>>> far from ideal as this will only allow the OS to work on a fixed 
>>>>>> set of hardware. I've been investigating how to use mdev to 
>>>>>> install the drivers for detected hardware (e.g. network cards). 
>>>>>> So far, it looks like I'll have to setup a script that's called 
>>>>>> by mdev to process any kernel modules related to the hardware in 
>>>>>> /etc/mdev.conf. The problem I've found is that I can't really 
>>>>>> find an example of how to do this with mdev (udev seems to use 
>>>>>> $MODALIAS with /etc/udev/scripts). I've also searched the busybox 
>>>>>> documentation for mdev which doesn't cover this topic. Can anyone 
>>>>>> point me to some relevant documentation/example, or provide 
>>>>>> something to get me started?
>>>>>>
>>>>>> Thanks,
>>>>>> Dave
>>>>> For cold-plug hardware detection I used simple modalias search + 
>>>>> modprobe by aliases (5 lines in script). Works perfectly with full 
>>>>> modprobe, on tiny variant of modprobe (which loads just 1st 
>>>>> matching module) it fails sometimes for devices like IDE 
>>>>> controllers that have 2 or more corresponding modules (for ex., 
>>>>> generic ata which matches by device class&etc and vendor driver 
>>>>> which match VenID/DevID). You can see it in LEAF v4.
>>>>>
>>>> Thanks Andrew.  I'm not familiar with LEAF, and since we're only 
>>>> talking about a file that's 5 lines, can you post in a reply?
>>>>
>>>      #autodetection of hardware
>>>      MODALIAS=`find /sys/devices -iname modalias -exec cat {} \;`
>>>      TMODALIAS=""
>>>      while [ `echo "$MODALIAS"|wc -l` -gt `echo "$TMODALIAS"|wc -l` 
>>> ]; do
>>>      for i in $MODALIAS; do
>>>      /sbin/modprobe $i 2>/dev/null
>>>      done
>>>      [ "$VERBOSE" ] && echo Loaded `echo "$MODALIAS"|wc -l` modaliases
>>>      [ "$DRV_WAIT" -gt 0 ] && sleep $DRV_WAIT
>>>      TMODALIAS="$MODALIAS"
>>>      MODALIAS=`find /sys/devices -iname modalias -exec cat {} \;`
>>>      done
>>>> Is there a way to do a "sleep" or "process order" for devices using 
>>>> 2 or more modules?
>>>>
>>>> Dave
>>> Here is a patch for additional module loading priority: 
>>> http://leaf.cvs.sourceforge.net/viewvc/leaf/src/bering-uclibc4/source/busybox/modprobe_alias_behaviors.patch?revision=1.2&view=markup 
>>>
>>> Or you can switch from tiny to full modutils in busybox (+14kB of code)
>> Thanks for the script Andrew!  I'll incorporate it (and possibly use 
>> it permenantly) right away.  Also, I am currently using the full 
>> version of modutils offered by busybox, so no patching for me! :)
>
> Andrew, I was receiving an error with that script and figured I'd run 
> it by you to (possibly) incorporate in your own.  I was getting an 
> "integer expression expected" error for the "[ "$DRV_WAIT" -gt 0 ] && 
> sleep $DRV_WAIT" line, so I changed it to "(( "$DRV_WAIT" > 0 )) && 
> sleep $DRV_WAIT" and now everything looks fine.  My network card is 
> being detected correctly, although the IP address isn't getting set 
> (but that's an issue with the networking script I'll be working on 
> now).  Looking at lsmod, I now can see 6 entries (two of them are even 
> dependent on another) as opposed to 1 when using mdev and the "fat" 
> /etc/mdev.conf file.
Of course, because you have uninitialized variable DRV_VAIT (wait for 
device initialization - like USB devices). It was initialized in my 
script somewhere earlier (this is only part of module handling script, 
earlier was modules preloading from lists in some files)
>
> Based on the follow-up mail from Vladimir, should this script be 
> adjusted to scan, not just the /sys/devices directory, but the 
> /sys/block and /sys/class directories too?
>
You can look at /sys/block or /sys/class and saw that there are just 
symlinks for /sys/devices items.
> Thanks so much for your help everyone!
> Dave



More information about the busybox mailing list