All pastes #244343 Raw Edit

firmware.agent

public text v1 · immutable
#244343 ·published 2006-11-09 17:40 UTC
rendered paste body
#!/bin/sh
#
# Firmware-specific hotplug policy agent.
#
# Kernel firmware hotplug params include:
#
# ACTION=%s [add or remove]
# DEVPATH=%s [in 2.5 kernels, /sys/$DEVPATH]
# FIRMWARE=%s
#
# HISTORY:
#
# 24-Jul-2003 Initial version of “new” hotplug agent.
#
# $Id: firmware.agent,v 1.3 2004/03/14 15:52:56 ukai Exp $
#

cd /etc/hotplug
. ./hotplug.functions

load() {
echo 1 > $SYSFS/$DEVPATH/loading
cat “$1″ > $SYSFS/$DEVPATH/data
echo 0 > $SYSFS/$DEVPATH/loading
exit
}

# DEBUG=yes export DEBUG

# directories with the firmware files
FIRMWARE_DIRS=”/lib/hotplug/firmware /usr/local/lib/hotplug/firmware /usr/lib/hotplug/firmware”

# mountpoint of sysfs
SYSFS=$(sed -n ’s/^.* \([^ ]*\) sysfs .*$/\1/p’ /proc/mounts | sed -e ‘2,$d’)

# use /proc for 2.4 kernels
if [ “$SYSFS” = “” ]; then
SYSFS=/proc
fi

VERSION=$(uname -r)

#
# What to do with this firmware hotplug event?
#
case “$ACTION” in

add)
counter=5
while [ ! -e $SYSFS/$DEVPATH/loading -a $counter -gt 0 ]; do
sleep 1
counter=$(($counter - 1))
done

if [ $counter -eq 0 ]; then
mesg “$SYSFS/$DEVPATH/ does not exist”
exit 1
fi

for DIR in $FIRMWARE_DIRS; do
if [ -e “$DIR/$FIRMWARE-$VERSION” ]; then
load “$DIR/$FIRMWARE-$VERSION”
elif [ -e “$DIR/$FIRMWARE” ]; then
load “$DIR/$FIRMWARE”
fi
done

# the firmware was not found
echo -1 > $SYSFS/$DEVPATH/loading

;;

remove)
;;

*)
mesg “Firmware ‘$ACTION’ event not supported”
exit 1
;;

esac