Группа :: Система/Настройка/Оборудование
Пакет: hotplug
Главная Изменения Спек Патчи Загрузить Bugs and FR
Патч: hotplug-2004_03_29-alt.patch
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/blacklist hotplug-2004_03_29/etc/hotplug/blacklist
--- hotplug-2004_03_29.orig/etc/hotplug/blacklist 2004-03-12 02:32:59 +0300
+++ hotplug-2004_03_29/etc/hotplug/blacklist 2005-05-03 14:41:17 +0400
@@ -21,3 +21,24 @@
#evbug is a debug tool and should be loaded explicitly
evbug
+
+# for hid loading
+usbkbd
+usbmouse
+irusb
+
+# disabling 1394 network interface
+eth1394
+
+# don't load i8xx watchdog
+i8xx_tco
+
+# disabled radeonfb
+radeonfb
+rivafb
+
+# IBM Laptop
+piix4_smbus
+shpchp
+tsdev
+joydev
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/firmware.agent hotplug-2004_03_29/etc/hotplug/firmware.agent
--- hotplug-2004_03_29.orig/etc/hotplug/firmware.agent 2004-03-27 01:34:34 +0300
+++ hotplug-2004_03_29/etc/hotplug/firmware.agent 2005-05-03 14:41:17 +0400
@@ -20,7 +20,7 @@
# DEBUG=yes export DEBUG
# directory of the firmware files
-FIRMWARE_DIR=/usr/lib/hotplug/firmware
+FIRMWARE_DIRS="/lib/firmware /usr/lib/hotplug/firmware"
# mountpoint of sysfs
SYSFS=$(sed -n 's/^.* \([^ ]*\) sysfs .*$/\1/p' /proc/mounts)
@@ -40,14 +40,13 @@
sleep 1
fi
- if [ -f "$FIRMWARE_DIR/$FIRMWARE" ]; then
+ for DIR in $FIRMWARE_DIRS; do
+ [ -e "$DIR/$FIRMWARE" ] || continue
echo 1 > $SYSFS/$DEVPATH/loading
- cp "$FIRMWARE_DIR/$FIRMWARE" $SYSFS/$DEVPATH/data
+ cp "$DIR/$FIRMWARE" $SYSFS/$DEVPATH/data
echo 0 > $SYSFS/$DEVPATH/loading
- else
- echo -1 > $SYSFS/$DEVPATH/loading
- fi
-
+ exit
+ done
;;
remove)
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/hotplug.functions hotplug-2004_03_29/etc/hotplug/hotplug.functions
--- hotplug-2004_03_29.orig/etc/hotplug/hotplug.functions 2004-03-29 23:25:59 +0400
+++ hotplug-2004_03_29/etc/hotplug/hotplug.functions 2005-05-03 14:41:17 +0400
@@ -18,9 +18,7 @@
HOTPLUG_DIR=/etc/hotplug
-if [ -f /etc/sysconfig/hotplug ]; then
- . /etc/sysconfig/hotplug
-fi
+SourceIfNotEmpty /etc/sysconfig/hotplug
if [ -x /usr/bin/logger ]; then
LOGGER=/usr/bin/logger
@@ -55,7 +53,6 @@
# them gets opened; wrong timing.
#
MODPROBE="/sbin/modprobe -s -q"
-#MODPROBE="/sbin/modprobe -vs"
####################################################################
@@ -166,9 +163,6 @@
if [ $LOADED = false ]; then
mesg "missing kernel or user mode driver $MODULE "
fi
- if echo "$MODULE" | grep -q "usb-storage" > /dev/null 2>&1 ; then
- [ -x /usr/sbin/updfstab ] && /usr/sbin/updfstab
- fi
done
}
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/ieee1394.agent hotplug-2004_03_29/etc/hotplug/ieee1394.agent
--- hotplug-2004_03_29.orig/etc/hotplug/ieee1394.agent 2004-03-27 01:34:34 +0300
+++ hotplug-2004_03_29/etc/hotplug/ieee1394.agent 2005-05-03 14:41:17 +0400
@@ -25,8 +25,15 @@
cd /etc/hotplug
. ./hotplug.functions
+. /etc/init.d/functions
# DEBUG=yes export DEBUG
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$IEEE1394PLUG" = "no" ];then
+ exit 0
+fi
+
# generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
MAP_CURRENT=$MODULE_DIR/modules.ieee1394map
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/net.agent hotplug-2004_03_29/etc/hotplug/net.agent
--- hotplug-2004_03_29.orig/etc/hotplug/net.agent 2004-03-30 02:23:31 +0400
+++ hotplug-2004_03_29/etc/hotplug/net.agent 2005-05-03 14:41:17 +0400
@@ -16,6 +16,28 @@
# $Id: net.agent,v 1.18 2004/03/29 22:23:31 kroah Exp $
#
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+SourceIfNotEmpty /etc/sysconfig/network
+
+if [ "$HOTPLUG" = "no" -o "$NETPLUG" = "no" ];then
+ exit 0
+fi
+
+# Define network agent hooks for traditional net-scripts configuration
+# system and for /etc/net.
+case $CONFMETHOD in
+ etcnet)
+ IFUP_HOOK=/etc/net/scripts/ifup-removable
+ IFDOWN_HOOK=/etc/net/scripts/ifdown-removable
+ ;;
+ *)
+ IFUP_HOOK=/sbin/ifup
+ IFDOWN_HOOK=/sbin/ifdown
+ ;;
+esac
+
cd /etc/hotplug
. ./hotplug.functions
# DEBUG=yes export DEBUG
@@ -26,6 +48,25 @@
fi
case $ACTION in
+remove|unregister)
+ case $INTERFACE in
+ # interfaces that are unregistered after being "down" (?)
+ ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
+ debug_mesg assuming $INTERFACE is already up
+ exit 0
+ ;;
+ # interfaces that are unregistered then brought down
+ *)
+
+ # RedHat and similar
+ export IN_HOTPLUG=1
+ if [ -x $IFDOWN_HOOK ]; then
+ debug_mesg invoke ifdown $INTERFACE
+ exec $IFDOWN_HOOK $INTERFACE hotplug
+ fi
+ ;;
+ esac
+ ;;
add|register)
# Red Hat specific hack...
if [ -f /etc/redhat-release ]; then
@@ -55,7 +96,7 @@
# down to change its name.
if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then
debug_mesg invoke ifrename for $INTERFACE
- NEWNAME=`/sbin/ifrename -i $INTERFACE`
+ NEWNAME=`/sbin/ifrename -i $INTERFACE 2>/dev/null`
if [ -n "$NEWNAME" ]; then
debug_mesg iface $INTERFACE is remapped to $NEWNAME
INTERFACE=$NEWNAME
@@ -64,9 +105,9 @@
# RedHat and similar
export IN_HOTPLUG=1
- if [ -x /sbin/ifup ]; then
+ if [ -x $IFUP_HOOK ]; then
debug_mesg invoke ifup $INTERFACE
- exec /sbin/ifup $INTERFACE
+ exec $IFUP_HOOK $INTERFACE hotplug
else
mesg "how do I bring interfaces up on this distro?"
fi
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/pci.agent hotplug-2004_03_29/etc/hotplug/pci.agent
--- hotplug-2004_03_29.orig/etc/hotplug/pci.agent 2004-03-27 01:36:38 +0300
+++ hotplug-2004_03_29/etc/hotplug/pci.agent 2005-05-03 14:41:17 +0400
@@ -32,6 +32,14 @@
# $Id: pci.agent,v 1.15 2004/03/26 22:36:38 kroah Exp $
#
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$PCIPLUG" = "no" ];then
+ exit 0
+fi
+
cd /etc/hotplug
. ./hotplug.functions
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/pci.rc hotplug-2004_03_29/etc/hotplug/pci.rc
--- hotplug-2004_03_29.orig/etc/hotplug/pci.rc 2004-03-27 01:34:24 +0300
+++ hotplug-2004_03_29/etc/hotplug/pci.rc 2005-05-03 14:41:17 +0400
@@ -8,6 +8,14 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$PCIPLUG" = "no" ];then
+ exit 0
+fi
+
cd /etc/hotplug
. ./hotplug.functions
@@ -38,26 +46,12 @@
sub_vendor_id=`cat $PCI_DEVICE/subsystem_vendor`
sub_device_id=`cat $PCI_DEVICE/subsystem_device`
PCI_SUBSYS_ID="${sub_vendor_id#0x}:${sub_device_id#0x}"
+ # skip pci network controllers
+ [ "${PCI_CLASS:0:2}" != "02" ] || continue
/sbin/hotplug pci
done
fi
- else
- # 2.4 kernels
- LISTER=`which pcimodules`
- if [ "$LISTER" = "" -o ! -f /proc/bus/pci/devices -o ! -x pci.agent ]; then
- echo $"** can't synthesize pci hotplug events"
- return
- fi
-
- # these notifications will be handled by pcimodules
- for BUS in `cd /proc/bus/pci;find * -type d -print`; do
- for SLOT_FUNC in `cd /proc/bus/pci/$BUS; echo *`; do
- PCI_SLOT=$BUS:$SLOT_FUNC
- /sbin/hotplug pci
- done
- done
fi
-
return 0
}
@@ -78,8 +72,8 @@
if [ $COUNT -gt 1 ]; then
COUNT=`expr $COUNT - 1`
echo $"PCI up; bus count is $COUNT"
- if [ -x /sbin/lspci ]; then
- /sbin/lspci
+ if [ -x /usr/bin/lspci ]; then
+ /usr/bin/lspci 2>/dev/null
fi
else
echo $"no PCI busses?"
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/pnp.distmap hotplug-2004_03_29/etc/hotplug/pnp.distmap
--- hotplug-2004_03_29.orig/etc/hotplug/pnp.distmap 1970-01-01 03:00:00 +0300
+++ hotplug-2004_03_29/etc/hotplug/pnp.distmap 2005-05-03 14:38:39 +0400
@@ -0,0 +1,9 @@
+# isapnp module cardvendor carddevice driver_data vendor function ...
+irtty-sir 0xffff 0xffff 0x00000000 0xd041 0x1005
+nsc-ircc 0xffff 0xffff 0x00000000 0xd041 0x1105
+floppy 0xffff 0xffff 0x00000000 0xd041 0x0007
+pcspkr 0xffff 0xffff 0x00000000 0xd041 0x0008
+rtc 0xffff 0xffff 0x00000000 0xd041 0x000b
+atkbd 0xffff 0xffff 0x00000000 0xd041 0x0303
+psmouse 0xffff 0xffff 0x00000000 0xd041 0x130f
+analog 0xffff 0xffff 0x00000000 0xd041 0x2fb0
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/pnp.rc hotplug-2004_03_29/etc/hotplug/pnp.rc
--- hotplug-2004_03_29.orig/etc/hotplug/pnp.rc 1970-01-01 03:00:00 +0300
+++ hotplug-2004_03_29/etc/hotplug/pnp.rc 2005-05-03 14:38:39 +0400
@@ -0,0 +1,153 @@
+#!/bin/sh
+# vim: syntax=sh
+#
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# Copyright (C) 2004 Alexander E. Patrakov (patrakov@ums.usu.ru)
+# Copyright (C) 2004 Simone Gotti (simone.gotti@email.it)
+# All Rights Reserved.
+#
+# Based on scripts by Simone Gotti, from:
+# http://members.xoom.virgilio.it/motaboy/hotplug-isapnp-0.2.1.tar.bz2
+#
+
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+. /etc/init.d/functions
+
+if [ "$(echo /sys/bus/pnp/devices/*)" = "/sys/bus/pnp/devices/*" ]
+then
+ exit 0
+fi
+
+SYSFS=/sys
+
+cd /etc/hotplug
+. ./hotplug.functions
+
+MAP_CURRENT=$MODULE_DIR/modules.isapnpmap
+DRIVERS=
+
+# WARNING: od and printf are in /usr/bin
+decode_isapnp_vendor() {
+ echo -n $1 | od -A n -t d1 | ( read A B C
+ printf '%04x\n' $(( ( ( $A & 0x3f ) << 2) | \
+ ( ( $B & 0x18 ) >> 3) | \
+ ( ( $B & 0x07 ) <<13) | \
+ ( ( $C & 0x1f ) << 8) )) )
+}
+
+hex_swab() {
+ echo `echo $1 | cut -b3-4``echo $1 | cut -b1-2`
+}
+
+#
+# stdin is "modules.isapnpmap" syntax
+# on return, ONE matching module was added to $DRIVERS
+#
+isapnp_map_modules ()
+{
+ local module ignored
+
+ # comment line lists (current) isapnp_device_id field names
+ read ignored
+
+ while read module cardvendor carddevice driver_data therest
+ do
+ # comments are lines that start with "#" ...
+ # be careful, they still get parsed by bash!
+ case "$module" in
+ \#*) continue ;;
+ esac
+ id_temp=""
+ next=""
+ [ "$ISAPNP_CARDID" = "$cardvendor$carddevice " ] || continue
+ : checkmatch $module
+ set $therest
+ while [ $# -gt 0 ]
+ do
+ devid=$1$2
+ if [ ! -z "${ISAPNP_ID##*$devid*}" ];then
+ next=1
+ break;
+ fi
+ shift
+ shift
+ done
+ [ ! -z "$next" ] && continue
+ DRIVERS="$module $DRIVERS"
+ : drivers $DRIVERS
+ done
+}
+
+
+isapnp_get_devices()
+{
+ local DEVICE ISAPNP_STRING ISAPNP_DEVICE
+ DEVICE=$1
+ for ISAPNP_DEVICE in $DEVICE/*:* ;do
+ for ISAPNP_STRING in `cat $ISAPNP_DEVICE/id` ; do
+ decode_card_id $ISAPNP_STRING
+ done
+ done
+}
+
+decode_card_id()
+{
+ local ISAPNP_STRING
+ ISAPNP_STRING=$1
+ rawcardvendor=`echo $ISAPNP_STRING | cut -b1-3`
+ rawcarddevice=`echo $ISAPNP_STRING | cut -b4-7`
+ cardvendor=`decode_isapnp_vendor $rawcardvendor`
+ carddevice=`hex_swab $rawcarddevice`
+ echo -n "0x${cardvendor}0x${carddevice} "
+}
+
+isapnp_boot_events ()
+{
+ for ISAPNP_DEVICE in $SYSFS/devices/pnp*/*:* ; do
+ ISAPNP_ID=""
+ ISAPNP_CARDID=""
+ if [ -f $ISAPNP_DEVICE/card_id ];then
+ ISAPNP_ID=`isapnp_get_devices $ISAPNP_DEVICE`
+ ISAPNP_STRINGS=`cat $ISAPNP_DEVICE/card_id`
+ ISAPNP_CARDID=`decode_card_id $ISAPNP_STRINGS`
+ else
+ ISAPNP_STRINGS=`cat $ISAPNP_DEVICE/id`
+ ISAPNP_CARDID='0xffff0xffff '
+ for ISAPNP_STRING in $ISAPNP_STRINGS ; do
+ ISAPNP_ID="$ISAPNP_STRING `decode_card_id $ISAPNP_STRING`"
+ done
+ fi
+ LABEL="ISAPNP cardid $ISAPNP_CARDID deviceid $ISAPNP_ID"
+ load_drivers isapnp $MAP_CURRENT "$LABEL"
+ load_drivers isapnp $HOTPLUG_DIR/pnp.distmap "$LABEL"
+ done
+ return 0
+}
+
+
+# See how we were called.
+case "$1" in
+ start)
+ isapnp_boot_events
+ ;;
+ stop)
+ # echo $"isapnp stop -- ignored"
+ ;;
+ status)
+ # echo $"isapnp status -- ignored"
+ ;;
+ restart)
+ # always invoke by absolute path, else PATH=$PATH:
+ $0 stop && $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart}"
+ exit 1
+esac
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/scsi.agent hotplug-2004_03_29/etc/hotplug/scsi.agent
--- hotplug-2004_03_29.orig/etc/hotplug/scsi.agent 2004-03-27 02:08:48 +0300
+++ hotplug-2004_03_29/etc/hotplug/scsi.agent 2005-05-03 14:41:17 +0400
@@ -6,6 +6,14 @@
# DEVPATH=devices/scsi0/0:0:0:0
#
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$SCSIPLUG" = "no" ];then
+ exit 0
+fi
+
cd /etc/hotplug
. ./hotplug.functions
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/sound.agent hotplug-2004_03_29/etc/hotplug/sound.agent
--- hotplug-2004_03_29.orig/etc/hotplug/sound.agent 1970-01-01 03:00:00 +0300
+++ hotplug-2004_03_29/etc/hotplug/sound.agent 2005-05-03 14:41:17 +0400
@@ -0,0 +1,92 @@
+#!/bin/sh
+#
+# SOUND hotplug agent for 2.6 kernels
+#
+# ACTION=add
+# DEVPATH=/class/sound/*
+#
+
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$SOUNDPLUG" = "no" ];then
+ exit 0
+fi
+
+cd /etc/hotplug
+. ./hotplug.functions
+
+STATEPATH=/var/lib/hotplug
+
+AMIXER=/usr/bin/amixer
+ALSACTL=/usr/sbin/alsactl
+
+[ -x $AMIXER -a -x $ALSACTL ] || exit 0
+
+function mixer() {
+ $AMIXER -c $CARDN set "$1" "$2" >/dev/null 2>&1
+ $AMIXER -c $CARDN set "$1" unmute >/dev/null 2>&1
+}
+
+function set_mixer_default() {
+ mesg "Set default mixer values for $DEVPATH ($CARDN)"
+ mixer Master 90%
+ mixer PCM 90%
+ mixer Synth 90%
+ mixer CD 90%
+ # mute mic
+ $AMIXER -c $CARDN set Mic 0% mute >/dev/null 2>&1
+ # ESS 1969 chipset has 2 PCM channels
+ mixer PCM,1 90%
+ # Trident/YMFPCI/emu10k1
+ mixer Wave 100%
+ mixer Music 100%
+ mixer AC97 100%
+ # CS4237B chipset:
+ mixer 'Master Digital' 75%
+ # Envy24 chips with analog outs
+ mixer DAC 90%
+ mixer DAC,0 90%
+ mixer DAC,1 90%
+ # some notebooks use headphone instead of master
+ mixer Headphone 75%
+ mixer Playback 100%
+ save_mixer
+ exit 0
+}
+
+function restore_mixer() {
+ mesg "Restore mixer values for $DEVPATH ($CARDN)"
+ ret=`$ALSACTL -f "$STATEPATH/asound$CARDN.state" restore $CARDN 2>&1`
+ [ "$ret" = "" ] || return 1
+}
+
+function save_mixer() {
+ mesg "Save mixer values for $DEVPATH ($CARDN)"
+ rm -f "$STATEPATH/asound$CARDN.state"
+ $ALSACTL -f "$STATEPATH/asound$CARDN.state" store $CARDN >/dev/null 2>&1
+ return $?
+}
+
+case $ACTION in
+
+add)
+ [ "${DEVPATH:0:21}" = "/class/sound/controlC" ] || exit 0
+ CARDN=${DEVPATH#'/class/sound/controlC'}
+ [ -f "$STATEPATH/asound$CARDN.state" ] || set_mixer_default
+ restore_mixer || set_mixer_default
+ exit 0
+ ;;
+remove)
+ [ "$FROM_RC" = "yes" ] || exit 0
+ [ "${DEVPATH:0:21}" = "/class/sound/controlC" ] || exit 0
+ CARDN=${DEVPATH#'/class/sound/controlC'}
+ save_mixer
+ ;;
+*)
+ debug_mesg SOUND $ACTION event not supported
+ exit 1
+ ;;
+
+esac
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/sound.rc hotplug-2004_03_29/etc/hotplug/sound.rc
--- hotplug-2004_03_29.orig/etc/hotplug/sound.rc 1970-01-01 03:00:00 +0300
+++ hotplug-2004_03_29/etc/hotplug/sound.rc 2005-05-03 14:41:17 +0400
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" ];then
+ exit 0
+fi
+
+cd /etc/hotplug
+. ./hotplug.functions
+
+# start this script only for 2.6 kernel and if sound cards exists
+[ -d /sys/class/sound ] || exit 0
+
+start()
+{
+ for i in /sys/class/sound/controlC*
+ do
+ DEVPATH=${i#'/sys'} ACTION=add FROM_RC=yes ./sound.agent
+ done
+}
+
+stop()
+{
+ for i in /sys/class/sound/controlC*
+ do
+ DEVPATH=${i#'/sys'} ACTION=remove FROM_RC=yes ./sound.agent
+ done
+}
+
+status()
+{
+ echo "Sound status:"
+ STATEPATH=/var/lib/hotplug
+ NUM=0
+ for i in /sys/class/sound/controlC*
+ do
+ NUM=$((NUM+1))
+ DEVPATH=${i#'/sys'}
+ CARDN=${DEVPATH#'/class/sound/controlC'}
+ STATUS="not saved"
+ [ -f "$STATEPATH/asound$CARDN.state" ] && STATUS="$STATEPATH/asound$CARDN.state"
+ echo "Mixer settings for card #$CARDN ($i): $STATUS"
+ done
+}
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ status)
+ status
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart}"
+ exit 1
+esac
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/usb.agent hotplug-2004_03_29/etc/hotplug/usb.agent
--- hotplug-2004_03_29.orig/etc/hotplug/usb.agent 2004-03-27 01:36:38 +0300
+++ hotplug-2004_03_29/etc/hotplug/usb.agent 2005-05-03 14:41:17 +0400
@@ -74,8 +74,11 @@
# $Id: usb.agent,v 1.39 2004/03/26 22:36:38 kroah Exp $
#
-if [ -f /etc/sysconfig/usb ]; then
- . /etc/sysconfig/usb
+. /etc/init.d/functions
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+if [ "$HOTPLUG" = "no" -o "$USBPLUG" = "no" ];then
+ exit 0
fi
cd /etc/hotplug
@@ -248,7 +251,7 @@
case "$line" in
\#*) continue ;;
esac
-
+ [ "$line" = "" ] && continue
set $line
module=$1
@@ -357,6 +360,7 @@
# they happen to issue requests at the same time ... it happens easily
# with slow HID devices and "usbmodules".
# starting with 2.5 (DEVPATH set), all hcds must queue control traffic.
+ [ "$PRODUCT" = "0/0/0" ] && exit 0;
if [ "$DEVPATH" = "" ]; then
sleep 3
fi
@@ -431,10 +435,6 @@
$REMOVER
fi
rm -f $REMOVER
-
- if [ -x /usr/sbin/updfstab ]; then
- /usr/sbin/updfstab
- fi
;;
*)
diff -Naur hotplug-2004_03_29.orig/etc/hotplug/usb.rc hotplug-2004_03_29/etc/hotplug/usb.rc
--- hotplug-2004_03_29.orig/etc/hotplug/usb.rc 2004-03-29 23:34:30 +0400
+++ hotplug-2004_03_29/etc/hotplug/usb.rc 2005-05-03 14:41:17 +0400
@@ -24,59 +24,20 @@
unset I_WANT_A_BROKEN_PS
PS_PERSONALITY=linux
-STATIC_MODULE_LIST=
-X11_USBMICE_HACK=false
+. /etc/init.d/functions
+SourceIfNotEmpty /etc/sysconfig/hotplug
-# override any of the defaults above?
-if [ -f /etc/sysconfig/usb ]; then
- . /etc/sysconfig/usb
+if [ "$HOTPLUG" = "no" -o "$USBPLUG" = "no" ];then
+ exit 0
fi
+cd /etc/hotplug
+. ./hotplug.functions
-MOUSE_MODULES="mousedev input"
+grep -iq nousb /proc/cmdline && exit 0
-# In its currently-recommended configuration, XFree86 3.3.6 always opens
-# /dev/input/mice; so mousedev and input must be loaded before X11 starts.
-if [ $X11_USBMICE_HACK = true ]; then
- STATIC_MODULE_LIST="$MOUSE_MODULES $STATIC_MODULE_LIST"
-fi
-
-
-#
-# "COLD PLUG" ... recovery from partial USB init that may have happened
-# before the OS could really handle hotplug, perhaps because /sbin or
-# $HOTPLUG_DIR wasn't available or /tmp wasn't writable. When/if the
-# /sbin/hotplug program is invoked then, hotplug event notifications
-# get dropped. To make up for such "cold boot" errors, we synthesize
-# all the hotplug events we expect to have seen already. They can be
-# out of order, and some might be duplicates.
-#
-# Note that on 2.5 the init filesystem may have loaded some of the more
-# essential usb drivers (maybe usb-storage for a boot disk, and hid),
-# but we may still need to load less important ones or invoke setup
-# scripts that couldn't run earlier.
-#
usb_boot_events ()
{
- #
- # FIXME on 2.5, /sys/bus/usb/devices/* gives all of the
- # info we need. Interface hotplug events come from the
- # "*:*" files, and device events (do them first) come
- # from the others.
- #
- # don't expect usbmodules to exist!! and remove the
- # dependency (below) on usbfs to decide whether we should
- # be synthesizing coldplug events.
- #
-
- # synthesize hotplug events if we can
- # we need (non-bash) programs to parse descriptors.
- LISTER=`which usbmodules`
- if [ "$LISTER" = "" -o ! -f /proc/bus/usb/devices ]; then
- echo $"** can't synthesize root hub events"
- return
- fi
-
# make sure the usb agent will run
ACTION=add
PRODUCT=0/0/0
@@ -87,6 +48,7 @@
DEVICE=
export ACTION PRODUCT TYPE INTERFACE DEVPATH DEVFS DEVICE
+ # for 2.4 kernels
# these notifications will be handled by usbmodules
# NOTE: we're not providing a full set of hotplug
# parameters for USB. that's why "usbmodules" is a
@@ -96,229 +58,146 @@
# FIXME usbmodules, or something, should set real
# PRODUCT and DEVICE strings so /etc/hotplug/usb/*
# scripts can rely on them ...
- # FIXME: this comment is out of date.
- if [ -d /sys/bus ]; then
- if [ -d /sys/bus/usb/devices ]; then
- cd /sys/bus/usb/devices
- # XXX FIXME this is not the right way...
- for device in /sys/bus/usb/devices/[0-9]*; do
- DEVPATH=${device#/sys/}
- if [ -f $device/idVendor ]; then
- PRODUCT="$(cat $device/idVendor)/$(cat $device/idProduct)/$(cat $device/bcdDevice)"
- /etc/hotplug/usb.agent
- fi
+ if [ ! -d /sys/bus/ ]; then
+ # on 2.4 kernels we need (non-bash) programs to parse descriptors
+ LISTER=`which usbmodules`
+ if [ "$LISTER" = "" -o ! -f /proc/bus/usb/devices ]; then
+ echo "** can't synthesize root hub events"
+ return 1
+ fi
+
+ DEVFS=/proc/bus/usb
+ for DEVICE in /proc/bus/usb/*/*; do
+ /etc/hotplug/usb.agent
done
- fi
- else
- for DEVICE in /proc/bus/usb/*/*; do
- /etc/hotplug/usb.agent
- done
+ return
fi
-}
+ # for 2.6 kernels
+ [ -d /sys/bus/usb/devices/ ] || return
+
+ # file names in /sys/bus/usb/devices/ are documented in
+ # drivers/usb/core/usb.c usb_alloc_dev()
+
+ # device events
+ for link in /sys/bus/usb/devices/[0-9]*; do
+ # skip interface events
+ case "$link" in
+ *:*) continue;;
+ esac
+# DEVPATH=${link#/sys/}
+ DEVPATH=$(readlink -f $link)
+ DEVPATH=${DEVPATH#/sys}
+ ./usb.agent
+ done
+
+ # interface events
+ for link in /sys/bus/usb/devices/[0-9]*:*; do
+# DEVPATH=${link#/sys/}
+ DEVPATH=$(readlink -f $link)
+ DEVPATH=${DEVPATH#/sys}
+ dir=$link/.. # XXX I don't know why this is needed, but it works
+ busnum=${dir#/sys/bus/usb/devices/}; busnum=${busnum%-*}
+ devnum=$(cat $dir/devnum)
+ DEVICE="/proc/bus/usb/$(printf %03d $busnum)/$(printf %03d $devnum)"
+ PRODUCT="$(cat $dir/idVendor)/$(cat $dir/idProduct)/$(cat $dir/bcdDevice)"
+ bDeviceClass=$((0x$(cat $dir/bDeviceClass)))
+ if [ "$bDeviceClass" = 9 ]; then
+ continue # skip hubs, nobody cares about their events
+ fi
+ TYPE="$bDeviceClass/$((0x$(cat $dir/bDeviceSubClass)))/$((0x$(cat $dir/bDeviceProtocol)))"
+ if [ "$bDeviceClass" = 0 ]; then
+ INTERFACE="$((0x$(cat $link/bInterfaceClass)))/$((0x$(cat $link/bInterfaceSubClass)))/$((0x$(cat $link/bInterfaceProtocol) + 1))"
+ else
+ INTERFACE=
+ fi
+ ./usb.agent
+ done
+}
maybe_start_usb ()
{
- local COUNT SYNTHESIZE
- COUNT=0
+ local COUNT SYNTHESIZE
+ COUNT=0
- # if USB is partially initted then synthesize "cold plug" events. the
- # kernel probably dropped many "hot plug" events, and those it didn't
- # drop likely couldn't trigger all the setup actions (kicking daemons,
- # dropping config records, and so on).
-
- # if it's not initted at all (no hcds loaded) no synthesized events
- # will be needed, we'll see real ones. knowing that there are no
- # hcds available through version-portable logic is a nightmare, so
- # assume we synthesize unless "usbfs" is clearly not initted (which
- # we currently need when synthesizing, anyway).
-
- SYNTHESIZE=true
- if [ ! -d /proc/bus/usb ]; then
- SYNTHESIZE=false
- fi
-
- # if distro hasn't already done part of this ... load core,
- # and mount usbfs before the first hotplug agent fires
- # (so it'll be available to the agents).
- modprobe -q usbcore >/dev/null 2>&1
- if [ -d /proc/bus/usb ]; then
- # if it's not mounted, try to mount it
- if [ ! -f /proc/bus/usb/devices ]; then
- if grep -q -E "^[^#][^[:space:]]+[[:space:]]+/proc/bus/usb/?[[:space:]]" /etc/fstab; then
- mount /proc/bus/usb
- else
- if grep -q usbfs /proc/filesystems; then
- mount -t usbfs usbfs /proc/bus/usb
- else
- mount -t usbdevfs usbdevfs /proc/bus/usb
+ # if USB is partially initted then synthesize "cold plug" events. the
+ # kernel probably dropped many "hot plug" events, and those it didn't
+ # drop likely couldn't trigger all the setup actions (kicking daemons,
+ # dropping config records, and so on).
+
+ # if it's not initted at all (no hcds loaded) no synthesized events
+ # will be needed, we'll see real ones. knowing that there are no
+ # hcds available through version-portable logic is a nightmare, so
+ # assume we synthesize unless "usbfs" is clearly not initted (which
+ # we currently need when synthesizing, anyway).
+
+ SYNTHESIZE=true
+ if [ ! -d /proc/bus/usb ]; then
+ SYNTHESIZE=false
+ fi
+
+ $MODPROBE usbcore >/dev/null 2>&1
+ if [ -d /proc/bus/usb ]; then
+ # if it's not mounted, try to mount it
+ if [ ! -f /proc/bus/usb/devices ]; then
+ mount -t usbfs usbfs /proc/bus/usb
fi
- fi
fi
- fi
- # Load Host Controller Drivers (HCDs) ... this automatically handles
- # systems with multiple controllers (EHCI, OHCI, UHCI) without needing
- # /proc or tools (lspci -v|grep USB, etc) to do so. If hotplugging
- # is enabled on this system, initting a root hub will cause hotplug
- # events to fire for every device on the tree at that root.
-
- # FIXME: some of this should be driven by PCI hotplugging, and have
- # the blacklist control which uhci driver gets used (before 2.5).
-
- # "new style" HCDs ... more common code
- modprobe -q ehci-hcd >/dev/null 2>&1
- modprobe -q ohci-hcd >/dev/null 2>&1
- modprobe -q uhci-hcd >/dev/null 2>&1
-
- # "old style" HCDs ... more driver-specific bugs
- modprobe -q usb-ohci >/dev/null 2>&1
- # NOTE: this prefers "uhci"; you may prefer "usb-uhci".
- # modprobe -q usb-uhci >/dev/null 2>&1 || modprobe -q uhci >/dev/null 2>&1
- modprobe -q uhci >/dev/null 2>&1 || modprobe -q usb-uhci >/dev/null 2>&1
-
- # ... add any non-PCI HCDS here. Examples include the
- # CRIS usb-host, Philips ISP-1161, Symlogic 811HS, and so on.
- # ohci-hcd can handle some non-pci variants.
-
- if [ -d /proc/bus/usb ]; then
- # If we see there are no busses, we "failed" and
- # can report so even if we're partially nonmodular.
- #
- # NOTE: this fails on older kernels, where usbdevfs had two files
- # ('devices' and 'drivers') with no hcds registered, but works on
- # newer kernels where usbfs has zero files until hcds register,
- # and might not have the 'drivers' file.
- COUNT=`ls /proc/bus/usb | wc -l`
- if [ $COUNT -lt 2 ]; then
- umount /proc/bus/usb
- rmmod usbcore >/dev/null 2>&1
- return 1
+ if [ "$SYNTHESIZE" = false ] || [ ! -f /proc/bus/usb/devices ] \
+ || ! grep -q -i bus /proc/bus/usb/devices; then
+
+ case "$KERNEL" in
+ 2.2*|2.3*|2.4*)
+ $MODPROBE usb-uhci >/dev/hull 2>&1
+ $MODPROBE usb-ohci >/dev/hull 2>&1
+ ;;
+ 2.5*|2.6*)
+ $MODPROBE uhci_hcd >/dev/null 2>&1
+ $MODPROBE -q ohci-hcd >/dev/null 2>&1
+ cat /proc/bus/usb/devices | grep -q "USB.*Hub\|OHCI" || rmmod ohci-hcd >/dev/null 2>&1
+ ;;
+ esac
+ $MODPROBE ehci-hcd >/dev/null 2>&1
+ cat /proc/bus/usb/devices | grep -q "USB[[:space:]]*2\|EHCI" || rmmod ehci-hcd >/dev/null 2>&1
+
fi
- # if USB is fully modular and yet can clean up,
- # we know init failed without needing usbfs
- elif rmmod usbcore >/dev/null 2>&1; then
- return 1
- fi
+ if [ -d /proc/bus/usb ]; then
+ COUNT=`ls /proc/bus/usb | wc -l`
+ if [ $COUNT -lt 2 ]; then
+ umount /proc/bus/usb
+ rmmod usbcore >/dev/null 2>&1
+ return 1
+ fi
- # hotplug events didn't fire during booting;
- # cope with devices that enumerated earlier
- # and may not have been fully configured.
- if [ $SYNTHESIZE = true ]; then
- sleep 1
- usb_boot_events
- fi
+ elif rmmod usbcore >/dev/null 2>&1; then
+ return 1
+ fi
- # Some modules are statically loaded, perhaps because they are
- # needed to activate filesystem device nodes.
- for MODULE in $STATIC_MODULE_LIST; do
- modprobe $MODULE
- done
+ if [ $SYNTHESIZE = true ]; then
+ sleep 1
+ usb_boot_events
+ fi
- # we did everything we could ...
- return 0
+ return 0
}
maybe_stop_usb ()
{
- # call this multiple times if you had to take down components of the
- # USB subsystem by hand; it cleans up whatever can
- # be cleaned up, letting the system quiesce further.
-
- # NOTE: this list of "all USB modules" is unfortunate, but it seems
- # inevitable until modutils supports the notion of drivers with use
- # counts of zero that shouldn't be removed until after their device
- # gets removed. Maybe in 2.5 ... of necessity, the list is partial.
-
- # disconnect all controllers we can, and kernel drivers
- # HCDs first, so most drivers reduce their use counts.
- rmmod ehci-hcd >/dev/null 2>&1
- rmmod ohci-hcd >/dev/null 2>&1
- rmmod uhci-hcd >/dev/null 2>&1
- rmmod usb-ohci >/dev/null 2>&1
- rmmod usb-uhci >/dev/null 2>&1
- rmmod uhci >/dev/null 2>&1
-
- # user mode code may keep usbfs busy for a while yet ...
-
- # OK, usbcore won't actually be removed unless there happen to be
- # no USB drivers loaded, and usbfs isn't mounted. let's force
- # removal of autocleanable modules before trying to rmmod usbcore
- rmmod -as
-# note: module-init-tools 0.8a doesn't handle "-as" flags
-
- # Now let's workaround the fact that some USB modules never increase
- # their module use counts, so that "rmmod -a" won't unload them.
- # (And we can't use "modprobe --autoclean" anyway.)
- rmmod acm >/dev/null 2>&1
- rmmod audio >/dev/null 2>&1
- rmmod auerswald >/dev/null 2>&1
- rmmod belkin_sa >/dev/null 2>&1
- rmmod bluetooth >/dev/null 2>&1
- rmmod catc >/dev/null 2>&1
- rmmod CDCEther >/dev/null 2>&1
- rmmod cpia_usb >/dev/null 2>&1
- rmmod cyberjack >/dev/null 2>&1
- rmmod dabusb >/dev/null 2>&1
- rmmod dc2xx >/dev/null 2>&1
- rmmod digi_acceleport >/dev/null 2>&1
- rmmod dsbr100 >/dev/null 2>&1
- rmmod emi26 >/dev/null 2>&1
- rmmod empeg >/dev/null 2>&1
- rmmod ftdi_sio >/dev/null 2>&1
- rmmod hci_usb >/dev/null 2>&1
- rmmod hid >/dev/null 2>&1
- rmmod hpusbscsi >/dev/null 2>&1
- rmmod ibmcam >/dev/null 2>&1
- rmmod iforce >/dev/null 2>&1
- rmmod io_edgeport >/dev/null 2>&1
- rmmod ipaq >/dev/null 2>&1
- rmmod ir-usb >/dev/null 2>&1
- rmmod irda-usb >/dev/null 2>&1
- rmmod kaweth >/dev/null 2>&1
- rmmod keyspan >/dev/null 2>&1
- rmmod keyspan_pda >/dev/null 2>&1
- rmmod kl5kusb105 >/dev/null 2>&1
- rmmod mct_u232 >/dev/null 2>&1
- rmmod mdc800 >/dev/null 2>&1
- rmmod microtek >/dev/null 2>&1
- rmmod omninet >/dev/null 2>&1
- rmmod ov511 >/dev/null 2>&1
- rmmod pegasus >/dev/null 2>&1
- rmmod pl2303 >/dev/null 2>&1
- rmmod printer >/dev/null 2>&1
- rmmod pwc pwcx >/dev/null 2>&1
- rmmod rio500 >/dev/null 2>&1
- rmmod rtl8150 >/dev/null 2>&1
- rmmod scanner >/dev/null 2>&1
- rmmod se401 >/dev/null 2>&1
- rmmod stv680 >/dev/null 2>&1
- rmmod usbkbd >/dev/null 2>&1
- rmmod usbmouse >/dev/null 2>&1
- rmmod usbnet >/dev/null 2>&1
- rmmod usbtest >/dev/null 2>&1
- rmmod usb-storage >/dev/null 2>&1
- rmmod uss720 >/dev/null 2>&1
- rmmod vicam >/dev/null 2>&1
- rmmod visor >/dev/null 2>&1
- rmmod wacom >/dev/null 2>&1
- rmmod whiteheat >/dev/null 2>&1
-
- if [ "$STATIC_MODULE_LIST" != "" ]; then
- rmmod $STATIC_MODULE_LIST >/dev/null 2>&1
+ MODULES=`lsmod | sed -rn '/^usbcore[[:space:]]/{
+ s/([^[:space:]]+[[:space:]]*){3}(.*)/\2/
+ /\[/s/.*\[(.*)\]/\1/
+ /\[/!s/,/ /g
+ p}'`
+ if [ -n "$MODULES" ]; then
+ for m in $MODULES; do
+ /sbin/rmmod $m >/dev/null 2>&1
+ done
fi
-
- # remove the helper modules that some usb modules need
- rmmod usbserial >/dev/null 2>&1
- rmmod usbvideo >/dev/null 2>&1
-
# ok, hope that user mode drivers/managers closed their fds.
- umount /proc/bus/usb >/dev/null 2>&1
-
- rmmod usbcore >/dev/null 2>&1
-
- # we did everything we could ...
+ [ -z "`mount | grep "/proc/bus/usb"`" ] || umount /proc/bus/usb >/dev/null 2>&1
+ [ -z "`lsmod | grep usbcore`" ] || /sbin/rmmod usbcore >/dev/null 2>&1
return 0;
}
@@ -326,6 +205,11 @@
case "$1" in
start)
maybe_start_usb
+ case "$KERNEL" in
+ 2.2*|2.3*|2.4*)
+ sleep 5
+ ;;
+ esac
;;
stop)
maybe_stop_usb
diff -Naur hotplug-2004_03_29.orig/etc/rc.d/init.d/hotplug hotplug-2004_03_29/etc/rc.d/init.d/hotplug
--- hotplug-2004_03_29.orig/etc/rc.d/init.d/hotplug 2003-03-28 03:25:03 +0300
+++ hotplug-2004_03_29/etc/rc.d/init.d/hotplug 2005-05-03 14:41:17 +0400
@@ -2,53 +2,59 @@
#
# hotplug This scripts starts hotpluggable subsystems.
#
-# chkconfig: 2345 01 99
+# chkconfig: 2345 08 96
# description: Starts and stops each hotpluggable subsystem. \
# On startup, may simulate hotplug events for devices \
# that were present at boot time, before filesystems \
# (or other resources) used by hotplug agents were available.
#
-# $Id: hotplug,v 1.3 2002/12/03 02:01:48 dbrownell Exp $
-#
-PATH=/sbin:/bin:/usr/sbin:/usr/bin
+# Do not load RH compatibility interface.
+WITHOUT_RC_COMPAT=1
# source function library
-if [ -f /etc/init.d/functions ]; then
- . /etc/init.d/functions
-elif [ -f /etc/rc.d/init.d/functions ]; then
- . /etc/rc.d/init.d/functions
-fi
+. /etc/init.d/functions
+
+SourceIfNotEmpty /etc/sysconfig/hotplug
+
+[ "$HOTPLUG" = "no" ] && exit 0
+
+LOCKFILE=/var/lock/subsys/hotplug
+
+RETVAL=0
+
+[ -z "$HOTPLUGRC" ] && HOTPLUGRC="usb.rc pci.rc sound.rc"
+
+run_rcs () {
+ for RC in $HOTPLUGRC
+ do
+ action "Hotplug ($RC) $1:" /etc/hotplug/$RC $1
+ RETVAL=$?
+ done
+}
case "$1" in
- start|restart|status)
- for RC in /etc/hotplug/*.rc
- do
- $RC $1
- done
- touch /var/lock/subsys/hotplug
+ start|restart)
+ run_rcs $1
+ [ $RETVAL -eq 0 ] && touch $LOCKFILE
;;
stop)
- for RC in /etc/hotplug/*.rc
- do
- $RC stop
- done
- rm -f /var/lock/subsys/hotplug
+ run_rcs $1
+ rm -f $LOCKFILE
;;
force-reload)
- for RC in /etc/hotplug/*.rc
- do
- $RC stop
- done
- for RC in /etc/hotplug/*.rc
- do
- $RC start
- done
- rm -f /var/lock/subsys/hotplug
+ run_rcs $1
;;
-
+ status)
+ run_rcs $1
+ ;;
+ condrestart|condstop)
+ RETVAL=0
+ ;;
*)
- echo $"Usage: $0 {start|stop|restart|status|force_reload}"
- exit 3
+ echo $"Usage: $0 {start|stop|restart|status|force_reload|condrestart|condstop}"
+ RETVAL=3
;;
esac
+
+exit $RETVAL
diff -Naur hotplug-2004_03_29.orig/Makefile hotplug-2004_03_29/Makefile
--- hotplug-2004_03_29.orig/Makefile 2003-06-28 04:13:10 +0400
+++ hotplug-2004_03_29/Makefile 2005-05-03 14:41:17 +0400
@@ -20,7 +20,7 @@
TOPDIR=/
DIRS= /sbin \
/etc/hotplug \
- /etc/init.d/ \
+ /etc/rc.d/init.d/ \
/var/run/usb \
/usr/share/man/man8
@@ -88,10 +88,10 @@
for F in etc/hotplug/{*.{agent,rc},hotplug.functions} ; do \
${INSTALL_SCRIPT} $$F $(etcdir)/hotplug ; \
done
- for F in etc/hotplug/{blacklist,usb.{user,hand,dist}map} ; do \
+ for F in etc/hotplug/{blacklist,{usb,pnp}.{user,hand,dist}map} ; do \
${INSTALL_DATA} $$F $(etcdir)/hotplug ; \
done
- ${INSTALL_SCRIPT} -D etc/rc.d/init.d/hotplug $(etcdir)/init.d/hotplug
+ ${INSTALL_SCRIPT} -D etc/rc.d/init.d/hotplug $(etcdir)/rc.d/init.d/hotplug
$(INSTALL_DATA) -D hotplug.8 $(mandir)/man8/hotplug.8
$(INSTALL) -d $(prefix)/var/log/hotplug $(prefix)/var/run
$(INSTALL) -d -m 700 $(prefix)/var/run/usb