nldev

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

commit 9f094bed8c41fe587bee893c2f7faf94b65d8b1f
parent e54347c4816f96226113d0fddecff41502b22d1f
Author: Christoph Lohmann <20h@r-36.net>
Date:   Sat, 28 Apr 2012 20:30:56 +0200

Add nltrigger.

Diffstat:
Makefile | 2++
nltrigger | 58++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
run_nldev | 2++
3 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/Makefile b/Makefile @@ -42,6 +42,7 @@ install: all @mkdir -p ${DESTDIR}${PREFIX}/bin @cp -f ${NAME} ${DESTDIR}${PREFIX}/bin @cp -f run_${NAME} ${DESTDIR}${PREFIX}/bin + @cp -f nltrigger ${DESTDIR}${PREFIX}/bin @chmod 755 ${DESTDIR}${PREFIX}/bin/${NAME} @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1 @mkdir -p ${DESTDIR}${MANPREFIX}/man1 @@ -52,6 +53,7 @@ uninstall: @echo removing executable file from ${DESTDIR}${PREFIX}/bin @rm -f ${DESTDIR}${PREFIX}/bin/${NAME} @rm -f ${DESTDIR}${PREFIX}/bin/run_${NAME} + @rm -f ${DESTDIR}${PREFIX}/bin/nltrigger @echo removing manual page from ${DESTDIR}${PREFIX}/man1 @rm -f ${DESTDIR}${MANPREFIX}/man1/${NAME}.1 diff --git a/nltrigger b/nltrigger @@ -0,0 +1,58 @@ +#!/bin/sh + +if [ $# -eq 0 ]; +then + printf "usage: %s subsystem [action]\n" "$(basename $0)" >&2 + exit 1 +fi + +action="add" +if [ $# -eq 2 ]; +then + action="$2" +fi + +if [ "$1" != "all" ]; +then + if [ -d /sys/class/$1 ]; + then + for i in /sys/class/$1/*/uevent; + do + echo $action > $i + done + exit 0 + fi + + if [ -d /sys/bus/$1 ]; + then + for i in /sys/bus/$1/devices/*/uevent; + do + echo $action > $i + done + exit 0 + fi + + if [ -d /sys/devices/$1 ]; + then + for i in /sys/devices/$1/*/uevent \ + /sys/devices/$1/*/*/uevent; + do + echo $action > $i + done + exit 0 + fi + + printf "Could not find subsystem '%s'.\n" $i >&2 + exit 1 +fi + +exit 0 + +for i in /sys/class/*/*/uevent /sys/bus/*/devices/*/uevent \ + /sys/devices/*/*/uevent /sys/devices/*/*/*/uevent; +do + echo $action > $i +done + +exit 0 + diff --git a/run_nldev b/run_nldev @@ -1,4 +1,6 @@ #!/bin/sh +ln -s /proc/self/fd /dev/fd + /bin/nldev -kd 2>&1 | logger -p daemon.notice -t nldev