Getting hotplug to work with busybox
Today I enabled hotplug support for my thinclient installation.
That was not that tricky, but some of debian's hotplug scripts use
commands or regular expressions that can't be handled when using busybox.
I had to modify two files,
/etc/hotplug/usb.rc and
/etc/hotplug/firmware.agent
(I don't know if these are the only two files to modify, but at the moment
I don't need more functionality from hotplug):
--- usb.rc.orig 2005-05-31 10:11:19.585542257 +0200
+++ usb.rc 2005-05-31 10:13:04.817216587 +0200
@@ -108,7 +108,12 @@
case "$device" in
*:*) continue;;
esac
- devlink=$(readlink -f $device)
+ # modification for busybox, because busybox's readlink does not
+ # support the -f option
+ # devlink=$(readlink -f $device)
+ devlink=$(readlink $device)
+ devlink=$(echo $devlink | sed 's/^\.\.\/\.\.\/\.\.\//\/sys\//')
+ # end of modification
DEVPATH=${devlink#/sys}
./usb.agent
@@ -116,7 +121,12 @@
# interface events
for device in /sys/bus/usb/devices/[0-9]*:*; do
- devlink=$(readlink -f $device)
+ # modification for busybox, because busybox's readlink does not
+ # support the -f option
+ # devlink=$(readlink -f $device)
+ devlink=$(readlink $device)
+ devlink=$(echo $devlink | sed 's/^\.\.\/\.\.\/\.\.\//\/sys\//')
+ # end of modification
DEVPATH=${devlink#/sys}
bDeviceClass=$((0x$(cat $devlink/../bDeviceClass)))
--- firmware.agent.orig 2005-05-31 10:11:27.646215495 +0200
+++ firmware.agent 2005-05-31 10:14:12.707033483 +0200
@@ -23,7 +23,10 @@
FIRMWARE_DIRS="/lib/firmware /usr/local/lib/firmware /usr/lib/hotplug/firmware"
# mountpoint of sysfs
-SYSFS=$(sed -n '/^.* \([^ ]*\) sysfs .*$/ { s//\1/p ; q }' /proc/mounts)
+# modification for busybox, because busybox's sed can't handle this regex
+# SYSFS=$(sed -n '/^.* \([^ ]*\) sysfs .*$/ { s//\1/p ; q }' /proc/mounts)
+SYSFS=$(awk "-F " '/^sysfs/ { print $2 } ' /proc/mounts)
+# end of modification
# use /proc for 2.4 kernels
if [ "$SYSFS" = "" ]; then
Update 2005-06-14: Today I downloaded a daily snapshot of busybox and
was very pleased to see, that the readlink-plugin now supports the -f option, so the patch to usb.rc is obsolete. The problem with firmware.agent persists though.
Posted by Alexander Griesser
| Categories:
Busybox
| Comments:
--> New comment