Wanna see this logo while booting your 2.6 kernel? Click here!

31.05.2005 10:13

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.

24.05.2005 12:49

NFS sucks


Why isn't it possible to unmount a NFS share if the IP-address of the NFS-Server has changed? Today I had a situation where a client hosting a NFS filesytem which is being mounted on one of my AIX boxes died. Every ls command in the mount point resulted in either long timeouts or I/O Errors which drove one of our FAM-processes crazy. So I had to unmount the filesystem to ensure the functionality of this process. That was impossible, because the host was not up anymore and so I couldn't unmount the filesystem. What really helped then was to bring up a secondary interface with this hosts ip-address (it was down at this time anyway) on my client machine. After doing so, I was able to unmount the NFS share (just to mention, my client does not understand a word of NFS) by just bringing up the ip-address again. Where's the damn sense in that?

13.05.2005 14:08

tuxx-home.at is now running on new hardware


This week, the old server hardware, where this domain is hosted on, died occasionally. Rest in peace, good old AMD K6-233!
As we already planned to replace the old hardware, we were not that surprised as it died and so I drove to Graz with the new hardware and installed it there. Now we have Linux 2.6 running on a IBM Intelli Workstation with dual Intel PIII 500MHz, 1GiB of RAM and a Mylex DAC960 RAID Controller which is a real performance boost compared to the previous hardware :)
Many, many thanks to inode [DE] for supporting our work and generously providing our uplink!

13.05.2005 13:15

busybox and shell traps


Today I stumbled accross an issue with busybox and shell traps. I tried to add some kind of automatic error responses to my thinclient runlevel scripts using signal traps. I configured a trap to signal 0 to start a dialog interface containing the detaild error message, but because of the trap on signal 0, it's always executed - on success and on failure - when the scripts exits. So I had to define some a variable that contains one specified value on success and another value on failure. Due to the forementioned fact that busybox lets me just do a single command in the trap, I wasn't able to check for the value of this variable, e.g. the following code didn't work:
[ "$VARIABLE" = "0" ] && do_something
Busybox only evalutes $VARIABLE and then returns from my trap, do_something was never called.
Finally I came to this solution:
ignore()
{
}

errordlg()
{
  $SCRIPT_OK /usr/bin/dialog --title "LXTC" --clear --msgbox "$*" 8 51
}

# Enable Error Reporting
set -e
SCRIPT_OK=

trap 'errordlg Error while loading keyboard layout!' 0

echo -n "Loading keyboard layout $KEYLAYOUT..."
try /bin/loadkeys $KEYLAYOUT

SCRIPT_OK=ignore
That worked fine and should be self-explanatory.