nldev

NetLink DEVice manager; a lightweight netlink frontend for mdev.
git clone git://r-36.net/nldev
Log | Files | Refs | LICENSE

commit 0ae13c5543d925768153f7356ca216330d24a0fd
parent db64d569025530b743e4d2140fc10e0431ae0815
Author: Christoph Lohmann <20h@r-36.net>
Date:   Mon, 28 May 2012 13:55:58 +0200

Preliminary fixes for the new mdev in busybox.

Diffstat:
mdev/etc/mdev.conf | 36++++++++++++++----------------------
mdev/lib/inputdev | 14+++++++++-----
nltrigger | 61+++++++++++++++++++++++++++++++++++++++++++------------------
3 files changed, 66 insertions(+), 45 deletions(-)

diff --git a/mdev/etc/mdev.conf b/mdev/etc/mdev.conf @@ -52,12 +52,9 @@ port root:kmem 640 nvram root:kmem 640 # input -mouse.* root:root 640 =input/ -mice root:root 640 =input/ -event.* root:root 640 */lib/mdev/inputdev -ts[0-9]* root:root 640 =input/ -uinput root:root 640$ =input/ -js[0-9]* root:root 644 =input/ +input/event[0-9]* root:root 640 */lib/mdev/inputdev +input/js[0-9]* root:root 644 +input/.* root:root 640 # v4l vttuner.* root:video 660 >v4l/ @@ -79,10 +76,10 @@ card[0-9]* root:video 660 =dri/ controlD[0-9]* root:video 660 =dri/ # dvb -dvb.* root:video 660 */lib/mdev/dvbdev +dvb.* root:video 660 */lib/mdev/dvbdev # usb -([0-9]+)-([0-9]+).* root:usb 665 */lib/mdev/usb +bus/usb/.* root:usb 665 */lib/mdev/usb # printer parport[0-9]* root:lp 660 @@ -142,20 +139,15 @@ aoe.* root:disk 660 =etherd/ bsg/.* root:disk 660 =bsg/ # audio -pcmC.* root:audio 660 =snd/ -controlC.* root:audio 660 =snd/ -midiC.* root:audio 660 =snd/ -seq root:audio 660 =snd/ -timer root:audio 660 =snd/ -hwC.* root:audio 660 =snd/ - -hpet root:audio 660 - -adsp root:audio 660 >sound/ -audio root:audio 660 >sound/ -dsp root:audio 660 >sound/ -mixer root:audio 660 >sound/ -sequencer.* root:audio 660 >sound/ +snd/.* root:audio 660 + +hpet root:audio 660 + +adsp root:audio 660 +audio root:audio 660 +dsp root:audio 660 +mixer root:audio 660 +sequencer.* root:audio 660 # network -net/.* root:root 600 @nameif diff --git a/mdev/lib/inputdev b/mdev/lib/inputdev @@ -6,6 +6,7 @@ set +x [ -n "$DEVNAME" ] || exit 0 [ "$SUBSYSTEM" = "input" ] || exit 0 +MDEV=$(basename ${MDEV}) BPATH="input" SPATH="/sys${DEVPATH}" @@ -15,25 +16,28 @@ then NAME=$(cat ${SPATH}/../name) fi +printf "bpath = '%s'; spath = '%s'; name = '%s';\n" "$BPATH" "$SPATH" "$NAME" \ + | logger -t daemon + cd $BPATH case "$ACTION" in add|"") - mv ../$MDEV . + #mv ../$MDEV . case "$NAME" in "TPPS/2 IBM TrackPoint") - ln -s $MDEV mouse + ln -fs $MDEV mouse ;; "AT Translated Set 2 keyboard") - ln -s $MDEV kbd + ln -fs $MDEV kbd ;; "ThinkPad Extra Buttons") - ln -s $MDEV extrabuttons + ln -fs $MDEV extrabuttons ;; esac ;; remove) - rm -f $MDEV + #rm -f $MDEV case "$NAME" in "TPPS/2 IBM TrackPoint") diff --git a/nltrigger b/nltrigger @@ -1,41 +1,69 @@ #!/bin/busybox ash -if [ $# -eq 0 ]; -then - printf "usage: %s subsystem [action]\n" "$(basename $0)" >&2 +usage() { + printf "usage: %s [add|list|del|action] [subsystem]\n" "$(basename $1)" >&2 exit 1 +} + +action="list" +if [ $# -gt 0 ]; +then + action="$1" fi -action="add" -if [ $# -eq 2 ]; +if [ "$action" = "list" ]; then - action="$2" + printf "class:\n" + for i in /sys/class/*; + do + printf "\t%s\n" $(basename $i) + done + + printf "bus:\n" + for i in /sys/bus/*; + do + printf "\t%s\n" $(basename $i) + done + + printf "devices:\n" + for i in /sys/devices/*; + do + printf "\t%s\n" $(basename $i) + done + + exit 0 fi -if [ "$1" != "all" ]; +if [ $# -lt 2 ]; then - if [ -d /sys/class/$1 ]; + usage "$0" +fi +subsystem="$2" + +if [ "$subsystem" != "all" ]; +then + if [ -d /sys/class/$subsystem ]; then - for i in /sys/class/$1/*/uevent; + for i in /sys/class/$subsystem/*/uevent; do echo $action > $i done exit 0 fi - if [ -d /sys/bus/$1 ]; + if [ -d /sys/bus/$subsystem ]; then - for i in /sys/bus/$1/devices/*/uevent; + for i in /sys/bus/$subsystem/devices/*/uevent; do echo $action > $i done exit 0 fi - if [ -d /sys/devices/$1 ]; + if [ -d /sys/devices/$subsystem ]; then - for i in /sys/devices/$1/*/uevent \ - /sys/devices/$1/*/*/uevent; + for i in /sys/devices/$subsystem/*/uevent \ + /sys/devices/$subsystem/*/*/uevent; do echo $action > $i done @@ -46,10 +74,7 @@ then exit 1 fi -exit 0 - -for i in /sys/class/*/*/uevent /sys/bus/*/devices/*/uevent \ - /sys/devices/*/*/uevent /sys/devices/*/*/*/uevent; +for i in /sys/class/*/*/uevent; do echo $action > $i done