SOURCES: udev-ieee1394.helper (NEW), udev-net.helper (NEW), udev-i...
freetz
freetz at pld-linux.org
Wed Oct 19 15:01:29 CEST 2005
Author: freetz Date: Wed Oct 19 13:01:29 2005 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- imported from hotplug
---- Files affected:
SOURCES:
udev-ieee1394.helper (NONE -> 1.1) (NEW), udev-net.helper (NONE -> 1.1) (NEW), udev-input-coldplug (NONE -> 1.1) (NEW), udev-input.helper (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/udev-ieee1394.helper
diff -u /dev/null SOURCES/udev-ieee1394.helper:1.1
--- /dev/null Wed Oct 19 15:01:29 2005
+++ SOURCES/udev-ieee1394.helper Wed Oct 19 15:01:23 2005
@@ -0,0 +1,115 @@
+#!/bin/sh
+#
+# IEEE1394-specific hotplug policy agent.
+#
+# This should handle 2.4.10 (or later) IEEE1394 hotplugging, with a
+# consistent framework for adding device and driver specific treatments.
+#
+# Kernel IEEE1394 params are:
+#
+# ACTION=add or remove
+# VENDOR_ID=24 bit vendor id
+# GUID=64 bit globally unique id
+# SPEFICIER_ID=24 bit id of owner of specification
+# VERSION=version of specification
+#
+# See IEEE1212 for details on these parameters.
+#
+# HISTORY:
+# 26-Mar-2002 Small cleanups to match other .agent files. (gkh)
+# 16-Sept-2001 Initial version from Kristian Hogsberg
+# <hogsberg at users.sourceforge.net> (plus tweaks)
+#
+# $Id$
+#
+
+debug_mesg() {
+ :
+}
+
+# generated by modutils 2.4.9 or later, for 2.4.10 and later kernels
+MAP_CURRENT=/lib/modules/`uname -r`/modules.ieee1394map
+
+# accumulates list of modules we may care about
+DRIVERS=
+
+if [ "$ACTION" = "" ]; then
+ mesg Bad IEEE1394 agent invocation
+ exit 1
+fi
+
+
+device_vendor_id=$((0x$VENDOR_ID))
+device_specifier_id=$((0x$SPECIFIER_ID))
+device_version=$((0x$VERSION))
+
+MATCH_VENDOR_ID=0x0001
+MATCH_SPECIFIER_ID=0x0004
+MATCH_VERSION=0x0008
+
+#
+# stdin is "modules.ieee1394map" syntax
+# on return, all matching modules were added to $DRIVERS
+#
+ieee1394_map_modules ()
+{
+ # comment line lists (current) pci_device_id field names
+ read ignored
+
+ while read module match_flags vendor_id model_id specifier_id version
+ do
+ : check match for $module
+
+ # convert from hex to dec
+ match_flags=$(($match_flags))
+ vendor_id=$(($vendor_id)); model_id=$(($model_id))
+ specifier_id=$(($specifier_id)); version=$(($version))
+
+ : vendor_id $vendor_id $device_vendor_id
+ if [ $(($match_flags & $MATCH_VENDOR_ID)) -ne 0 ] && [ $vendor_id -ne $device_vendor_id ]; then
+ continue
+ fi
+
+ : specifier_id $specifier_id $device_specifier_id
+ if [ $(($match_flags & $MATCH_SPECIFIER_ID)) -ne 0 ] && [ $specifier_id -ne $device_specifier_id ]; then
+ continue
+ fi
+
+ : version $version $device_version
+ if [ $(($match_flags & $MATCH_VERSION)) -ne 0 ] && [ $version != $device_version ]; then
+ continue
+ fi
+
+ DRIVERS="$module $DRIVERS"
+ done
+}
+
+#
+# What to do with this IEEE1394 hotplug event?
+#
+case "$ACTION" in
+
+add)
+ ieee1394_map_modules < $MAP_CURRENT
+ for MODULE in $DRIVERS; do
+ [ -x $HOTPLUG_DIR/ieee1394/$MODULE ] && $HOTPLUG_DIR/ieee1394/$MODULE
+ /sbin/modprobe $MODULE
+ done
+ LABEL="IEEE1394 product 0x$VENDOR_ID/0x$SPECIFIER_ID/0x$VERSION"
+ debug_mesg "$LABEL, found drivers: $DRIVERS"
+ ;;
+
+remove)
+ ieee1394_map_modules < $MAP_CURRENT
+ for MODULE in $DRIVERS; do
+ [ -x $HOTPLUG_DIR/ieee1394/$MODULE ] && $HOTPLUG_DIR/ieee1394/$MODULE
+ /sbin/rmmod $MODULE
+ done
+ ;;
+
+*)
+ debug_mesg "IEEE1394 '$ACTION' event not supported"
+ exit 1
+ ;;
+
+esac
================================================================
Index: SOURCES/udev-net.helper
diff -u /dev/null SOURCES/udev-net.helper:1.1
--- /dev/null Wed Oct 19 15:01:29 2005
+++ SOURCES/udev-net.helper Wed Oct 19 15:01:23 2005
@@ -0,0 +1,117 @@
+#!/bin/sh
+#
+# Kernel NET hotplug params include:
+#
+# ACTION=%s [register or unregister]
+# INTERFACE=%s
+
+. /etc/sysconfig/network-scripts/network-functions
+
+mesg() {
+ /usr/bin/logger -t $(basename $0)"[$$]" "$@"
+}
+
+debug_mesg() {
+ :
+}
+
+# returns true if device is either wireless, usbnet or is named eth* and supports ethtool
+ethernet_check() {
+ [ -d /sys/class/net/$1/wireless/ ] && return 0
+ [[ "$1" == bnep* ]] && return 0
+ # eagle-usb/firewire create a fake ethX interface
+ if [ -x /usr/sbin/ethtool ] && ! /usr/sbin/ethtool $1 > /dev/null 2>&1;
+ then return 1;
+ fi
+ return 0;
+}
+
+if [ "$INTERFACE" = "" ]; then
+ mesg Bad NET invocation: \$INTERFACE is not set
+ exit 1
+fi
+
+export IN_HOTPLUG=1
+
+case $ACTION in
+add|register)
+ case $INTERFACE in
+ # interfaces that are registered after being "up" (?)
+ ppp*|ippp*|isdn*|plip*|lo*|irda*|dummy*|ipsec*|tun*|tap*)
+ debug_mesg assuming $INTERFACE is already up
+ exit 0
+ ;;
+ # interfaces that are registered then brought up
+ *)
+ # NOTE: network configuration relies on administered state,
+ # we can't do much here without distro-specific knowledge
+ # such as whether/how to invoke DHCP, set up bridging, etc.
+
+ # Run ifrename as needed - Jean II
+ # Remap interface names based on MAC address. This workaround
+ # the dreaded configuration problem "all my cards are 'eth0'"...
+ # This needs to be done before ifup otherwise ifup will get
+ # confused by the name changed and because iface need to be
+ # down to change its name.
+ if [ -x /sbin/ifrename ] && [ -r /etc/iftab ]; then
+ debug_mesg invoke ifrename for $INTERFACE
+ NEWNAME=`/sbin/ifrename -i $INTERFACE`
+ if [ -n "$NEWNAME" ]; then
+ debug_mesg iface $INTERFACE is remapped to $NEWNAME
+ INTERFACE=$NEWNAME
+ fi;
+ fi
+
+ # conform to network service (AUTOMATIC_IFCFG)
+ [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
+
+ # don't do anything for non ethernet devices
+ ethernet_check $INTERFACE || exit 0;
+
+ # automatically create an interface file
+ CFG=/etc/sysconfig/network-scripts/ifcfg-$INTERFACE
+ if [ "$AUTOMATIC_IFCFG" != no -a ! -r $CFG ]; then
+ debug_mesg creating config file for $INTERFACE
+ cat > $CFG <<EOF
+DEVICE=$INTERFACE
+BOOTPROTO=dhcp
+ONBOOT=yes
+EOF
+ fi
+
+ if [ ! -f /var/lock/subsys/network ] || [ ! -r $CFG ]; then
+ # Don't do anything if the network is stopped or interface isn't configured
+ exit 0
+ fi
+
+ if [ -x /sbin/ifup ]; then
+ debug_mesg invoke ifup $INTERFACE
+ exec /sbin/ifup $INTERFACE daemon
+ fi
+ ;;
+ esac
+ mesg $1 $ACTION event not handled
+ ;;
+
+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 down
+ exit 0
+ ;;
+ *)
+ if [ -x /sbin/ifdown ]; then
+ debug_mesg invoke ifdown $INTERFACE
+ exec /sbin/ifdown $INTERFACE daemon
+ fi
+ ;;
+ esac
+ mesg $1 $ACTION event not handled
+ ;;
+
+*)
+ debug_mesg NET $ACTION event for $INTERFACE not supported
+ exit 1 ;;
+
+esac
================================================================
Index: SOURCES/udev-input-coldplug
diff -u /dev/null SOURCES/udev-input-coldplug:1.1
--- /dev/null Wed Oct 19 15:01:29 2005
+++ SOURCES/udev-input-coldplug Wed Oct 19 15:01:23 2005
@@ -0,0 +1,140 @@
+#!/bin/sh
+#
+# input.rc This loads handlers for those input devices
+# that have drivers compiled in kernel
+# Currently stopping is not supported
+#
+# Best invoked via /etc/init.d/hotplug or equivalent, with
+# writable /tmp, /usr mounted, and syslogging active.
+#
+
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+PROCDIR=/proc/bus/input
+
+debug_mesg () {
+ :
+}
+
+input_reset_state () {
+ PRODUCT=
+ NAME=
+ PHYS=
+ EV=
+ KEY=
+ REL=
+ ABS=
+ MSC=
+ LED=
+ SND=
+ FF=
+
+}
+
+#
+# "COLD PLUG" ... load input handlers for compile-in input drivers loaded
+# 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.
+#
+input_boot_events ()
+{
+ # do not even try if /proc/bus/input is missing
+ [ -d $PROCDIR ] || return
+
+ if [ ! -r $PROCDIR/devices ]; then
+ echo $"** can't synthesize input events - $PROCDIR/devices missing"
+ return
+ fi
+
+ ACTION=add
+ export ACTION
+
+ export PRODUCT NAME PHYS EV KEY REL ABS MSC LED SND FF
+ input_reset_state
+
+ #
+ # the following reads from /proc/bus/input/devices. It is inherently
+ # racy (esp. as this file may be changed by input.agent invocation)
+ # but so far input devices do not appear in sysfs
+ #
+ while read line; do
+ case "$line" in
+ I:* ) # product ID
+ eval "${line#I: }"
+ PRODUCT="$Bus/$Vendor/$Product/$Version"
+ ;;
+ N:* ) # name
+ eval "${line#N: }"
+ NAME="$Name"
+ ;;
+ P:* ) # Physical
+ eval "${line#P: }"
+ PHYS="$Phys"
+ ;;
+ B:* ) # Controls supported
+ line="${line#B: }"
+ eval "${line%%=*}=\"${line#*=}\""
+ ;;
+ "" ) # End of block
+ debug_mesg "Invoking input.agent"
+ debug_mesg "PRODUCT=$PRODUCT"
+ debug_mesg "NAME=$NAME"
+ debug_mesg "PHYS=$PHYS"
+ debug_mesg "EV=$EV"
+ debug_mesg "KEY=$KEY"
+ debug_mesg "REL=$REL"
+ debug_mesg "ABS=$ABS"
+ debug_mesg "MSC=$MSC"
+ debug_mesg "LED=$LED"
+ debug_mesg "SND=$SND"
+ debug_mesg "FF=$FF"
+ /sbin/udev_input_helper < /dev/null
+ input_reset_state
+ ;;
+ esac
+ done < $PROCDIR/devices
+}
+
+
+# See how we were called.
+case "$1" in
+ start)
+ input_boot_events
+ ;;
+ stop)
+ : not supported currently
+ ;;
+ status)
+ echo $"INPUT status for kernel: " `uname -srm`
+ echo ''
+
+ echo "INPUT devices:"
+ if [ -r $PROCDIR/devices ]; then
+ grep "^[INHP]:" $PROCDIR/devices
+ else
+ echo "$PROCDIR/devices not available"
+ fi
+ echo ''
+
+ echo "INPUT handlers:"
+ if [ -r $PROCDIR/handlers ]; then
+ cat $PROCDIR/handlers
+ else
+ echo "$PROCDIR/handlers not available"
+ fi
+
+ echo ''
+
+ ;;
+ restart)
+ # always invoke by absolute path, else PATH=$PATH:
+ $0 stop && $0 start
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart}"
+ exit 1
+esac
================================================================
Index: SOURCES/udev-input.helper
diff -u /dev/null SOURCES/udev-input.helper:1.1
--- /dev/null Wed Oct 19 15:01:29 2005
+++ SOURCES/udev-input.helper Wed Oct 19 15:01:23 2005
@@ -0,0 +1,293 @@
+#!/bin/sh
+#
+# input-specific hotplug policy agent.
+#
+# This should handle 2.6.* input hotplugging,
+# with a consistent framework for adding device and driver
+# specific handling.
+#
+# Normally, adding a input device will modprobe handler(s) for
+# this device.
+#
+# Kernel input hotplug params include (not all of them may be available):
+#
+# ACTION=%s [add or remove]
+# PRODUCT=%x/%x/%x/%x
+# NAME=%s
+# PHYS=%s
+# EV=%lx
+# KEY=%lx %lx ...
+# REL=%lx
+# ABS=%lx %lx ...
+# MSC=%lx
+# LED=%lx
+# SND=%lx
+# FF=%lx %lx ...
+
+debug_mesg () {
+ :
+}
+
+# accumulates list of modules we may care about
+DRIVERS=""
+
+if [ "$ACTION" = "" ]; then
+ mesg Bad INPUT agent invocation, no action
+ exit 1
+fi
+
+# we can't "unset IFS" on bash1, so save a copy
+DEFAULT_IFS="$IFS"
+
+#
+# Each modules.inputmap format line corresponds to one entry in a
+# MODULE_DEVICE_TABLE(input,...) declaration in a kernel file.
+#
+matchBits=0; i_bustype=0; i_vendor=0; i_product=0; i_version=0; i_evBits=0
+
+input_join_words ()
+{
+ name="$1"
+ array="$2"
+
+ if [ "$array" = '' ]; then
+ return
+ fi
+
+ set $array
+
+ tmp="$1"
+ shift
+ while [ "$#" -gt 0 ]; do
+ tmp="$tmp:$1"
+ shift
+ done
+
+ eval "$name=\"$tmp\""
+}
+
+input_convert_vars ()
+{
+ if [ "$PRODUCT" != "" ]; then
+ IFS=/
+ set $PRODUCT ''
+ IFS="$DEFAULT_IFS"
+ i_bustype=$((0x$1))
+ i_vendor=$((0x$2))
+ i_product=$((0x$3))
+ i_version=$((0x$4))
+ fi
+
+ if [ "$EV" != "" ]; then
+ i_evBits=$((0x$EV))
+ fi
+
+ input_join_words i_keyBits "$KEY"
+ input_join_words i_relBits "$REL"
+ input_join_words i_absBits "$ABS"
+ input_join_words i_mscBits "$MSC"
+ input_join_words i_ledBits "$LED"
+ input_join_words i_sndBits "$SND"
+ input_join_words i_ffBits "$FF"
+}
+
+INPUT_DEVICE_ID_MATCH_BUS=1
+INPUT_DEVICE_ID_MATCH_VENDOR=2
+INPUT_DEVICE_ID_MATCH_PRODUCT=4
+INPUT_DEVICE_ID_MATCH_VERSION=8
+INPUT_DEVICE_ID_MATCH_EVBIT=$((0x010))
+INPUT_DEVICE_ID_MATCH_KEYBIT=$((0x020))
+INPUT_DEVICE_ID_MATCH_RELBIT=$((0x040))
+INPUT_DEVICE_ID_MATCH_ABSBIT=$((0x080))
+INPUT_DEVICE_ID_MATCH_MSCBIT=$((0x100))
+INPUT_DEVICE_ID_MATCH_LEDBIT=$((0x200))
+INPUT_DEVICE_ID_MATCH_SNDBIT=$((0x400))
+INPUT_DEVICE_ID_MATCH_FFBIT=$((0x800))
+
+
+input_match_bits ()
+{
+ mod_bits=$1
+ dev_bits=$2
+
+ if [ "$dev_bits" = "" ]; then
+ return 0
+ fi
+ mword=$((0x${mod_bits##*:}))
+ dword=$((0x${dev_bits##*:}))
+
+ while true; do
+ if [ $(( $mword & $dword != $mword )) -eq 1 ]; then
+ return 1
+ fi
+
+ mod_bits=${mod_bits%:*}
+ dev_bits=${dev_bits%:*}
+
+ case "$mod_bits-$dev_bits" in
+ *:*-*:* )
+ : continue
+ ;;
+ *:*-*|*-*:* )
+ return 0
+ ;;
+ * )
+ return 1
+ ;;
+ esac
+ done
+}
+
+#
+# stdin is "modules.inputmap" syntax
+# on return, all matching modules were added to $DRIVERS
+#
+input_map_modules ()
+{
+ while read line
+ do
+ # comments are lines that start with "#" ...
+ # be careful, they still get parsed by bash!
+ case "$line" in
+ \#*) continue ;;
+ esac
+
+ set $line
+
+ module="$1"
+ matchBits=$(($2))
+
+ bustype=$(($3))
+ vendor=$(($4))
+ product=$(($5))
+ version=$(($6))
+
+ evBits="$7"
+ keyBits="$8"
+ relBits="$9"
+
+ shift 9
+ absBits="{$1}"
+ cbsBits="{$2}"
+ ledBits="{$3}"
+ sndBits="{$4}"
+ ffBits="{$5}"
+ driverInfo=$(({$6}))
+
+ : checkmatch $module
+
+ : bustype $bustype $i_bustype
+ if [ $INPUT_DEVICE_ID_MATCH_BUS -eq $(( $matchBits & $INPUT_DEVICE_ID_MATCH_BUS )) ] &&
+ [ $bustype -ne $i_bustype ]; then
+ continue
+ fi
+
+ : vendor $vendor $i_vendor
+ if [ $INPUT_DEVICE_ID_MATCH_VENDOR -eq $(( $matchBits & $INPUT_DEVICE_ID_MATCH_VENDOR )) ] &&
+ [ $vendor -ne $i_vendor ]; then
+ continue
+ fi
+
+ : product $product $i_product
+ if [ $INPUT_DEVICE_ID_MATCH_PRODUCT -eq $(( $matchBits & $INPUT_DEVICE_ID_MATCH_PRODUCT )) ] &&
+ [ $product -ne $i_product ]; then
+ continue
+ fi
+
+ # version i_version $i_version < version $version
+ if [ $INPUT_DEVICE_ID_MATCH_VERSION -eq $(( $matchBits & $INPUT_DEVICE_ID_MATCH_VERSION )) ] &&
+ [ $version -ge $i_version ]; then
+ continue
+ fi
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list