aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-12-05 11:02:03 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-12-05 11:02:51 +0000
commit98a4d550920704cf79e621714053157926dd3f52 (patch)
treef810adc7cb7b6a2d911d7348dd95c636cbbbe6b5
parent5949f936379d49aee62e08ed7a81b6c61a984a1b (diff)
downloadaports-98a4d550920704cf79e621714053157926dd3f52.tar.bz2
aports-98a4d550920704cf79e621714053157926dd3f52.tar.xz
main/busybox-initscripts: try fix usb devices
ref #1481
-rw-r--r--main/busybox-initscripts/APKBUILD8
-rw-r--r--main/busybox-initscripts/mdev.conf3
-rw-r--r--main/busybox-initscripts/mdev.initd6
-rwxr-xr-x[-rw-r--r--]main/busybox-initscripts/usbdev75
4 files changed, 30 insertions, 62 deletions
diff --git a/main/busybox-initscripts/APKBUILD b/main/busybox-initscripts/APKBUILD
index f3c513d7ca..5c63994bd3 100644
--- a/main/busybox-initscripts/APKBUILD
+++ b/main/busybox-initscripts/APKBUILD
@@ -2,7 +2,7 @@
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=busybox-initscripts
pkgver=2.2
-pkgrel=8
+pkgrel=9
pkgdesc="Init scripts for busybox daemons"
url="http://git.alpinelinux.org/cgit/aports/tree/core/busybox-initscripts"
arch="noarch"
@@ -58,7 +58,7 @@ dad20779adfb4b85b57b45c7c903a636 dnsd.initd
7504e0700dfa85f354d31af7a58663f9 inetd.initd
b0146b19b828051985377de1e4431a32 klogd.initd
6de9bac27127a7e1dbcc86acbc920521 mdev-mount.initd
-ef3e93fe17964dd600364b1340654b5b mdev.initd
+42235766420d42ba9df07046e1ad1b05 mdev.initd
c01dc869cbdd68e86e64a35ccc1e885e rdate.initd
4ef91ad26f5b6e64b5bc545e35f18af1 syslog.initd
254186e513ff9fb9ede6a2e92257b247 watchdog.initd
@@ -67,10 +67,10 @@ c01dc869cbdd68e86e64a35ccc1e885e rdate.initd
22adbf155ffc4595206ded6daad07812 rdate.confd
77fb31a75511247bf4e3430565a276bc syslog.confd
0bb55dde32f5e119111fa4938daaef3d watchdog.confd
-d32a00a7a5cd05399dc91962870d4d07 mdev.conf
+3ac0818f602d905f5cd7a2a9c7a340ef mdev.conf
ad1556961294e4aa2abca6be52138b7c dvbdev
5c8725b4cbdeda23b00f08124a0d20bf ide_links
-c422992ca5bfdfabdbba1f1532bc1358 usbdev
+daf57f3d0372f825ddc05b00973e5afe usbdev
30b0c85956b6701caf55309a17e537f6 usbdisk_link
826d85313ca7a4a0205d63bd58b7d01f xvd_links
a346e7a30915856bc53987846e09724c default.script"
diff --git a/main/busybox-initscripts/mdev.conf b/main/busybox-initscripts/mdev.conf
index ff4d4bb3b7..ef2f5ca3f4 100644
--- a/main/busybox-initscripts/mdev.conf
+++ b/main/busybox-initscripts/mdev.conf
@@ -84,8 +84,7 @@ video[0-9]+ root:video 0660 >v4l/
dvb.* root:video 0660 */lib/mdev/dvbdev
# load drivers for usb devices
-usbdev[0-9].[0-9] root:root 0660 */lib/mdev/usbdev
-usbdev[0-9].[0-9]_.* root:root 0660
+usb[0-9]+ root:root 0660 */lib/mdev/usbdev
# net devices
tun[0-9]* root:root 0600 =net/
diff --git a/main/busybox-initscripts/mdev.initd b/main/busybox-initscripts/mdev.initd
index e9309c7006..6638ec4489 100644
--- a/main/busybox-initscripts/mdev.initd
+++ b/main/busybox-initscripts/mdev.initd
@@ -20,6 +20,12 @@ start() {
# use mdev for hotplug
echo "/sbin/mdev" > /proc/sys/kernel/hotplug
+ # mdev -s will not create /dev/usb[1-9] devices with recent kernels
+ # so we trigger hotplug events for usb for now
+ for i in $(find /sys/device -name 'usb[0-9]*'); do
+ [ -e $i/uevent ] && echo add > $i/uevent
+ done
+
# create devices
mdev -s
eend $?
diff --git a/main/busybox-initscripts/usbdev b/main/busybox-initscripts/usbdev
index ea5b915573..c811736dda 100644..100755
--- a/main/busybox-initscripts/usbdev
+++ b/main/busybox-initscripts/usbdev
@@ -1,62 +1,25 @@
#!/bin/sh
-# script is buggy; until patched just do exit 0
-#exit 0
+# mdev -s will not set SUBSYSTEM or DEVNAME so we trigger a hotplug event
+if [ "$SUBSYSTEM" != "usb" ] || [ "$DEVTYPE" != "usb_device" ]; then
+ uev=/sys/bus/usb/devices/$MDEV/uevent
+ [ -e "$uev" ] && echo "add" > "$uev"
+ exit
+fi
-# add zeros to device or bus
-add_zeros () {
- case "$(echo $1 | wc -L)" in
- 1) echo "00$1" ;;
- 2) echo "0$1" ;;
- *) echo "$1"
- esac
- exit 0
-}
+[ -n "$DEVNAME" ] || exit
-
-# bus and device dirs in /sys
-USB_PATH=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).[0-9]/usb\1/')
-USB_PATH=$(find /sys/devices -type d -name "$USB_PATH")
-USB_DEV_DIR=$(echo $MDEV | sed -e 's/usbdev\([0-9]\).\([0-9]\)/\1-\2/')
-
-# dir names in /dev
-BUS=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev\([0-9]\).[0-9]/\1/'))
-USB_DEV=$(add_zeros $(echo $MDEV | sed -e 's/^usbdev[0-9].\([0-9]\)/\1/'))
-
-
-# try to load the proper driver for usb devices
case "$ACTION" in
- add|"")
- # load usb bus driver
- for i in $USB_PATH/*/modalias ; do
- modprobe `cat $i` 2>/dev/null
- done
- # load usb device driver if existent
- if [ -d $USB_PATH/$USB_DEV_DIR ]; then
- for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do
- modprobe `cat $i` 2>/dev/null
- done
- fi
- # move usb device file
- mkdir -p bus/usb/$BUS
- mv $MDEV bus/usb/$BUS/$USB_DEV
- ;;
- remove)
- # unload device driver, if device dir is existent
- if [ -d $USB_PATH/$USB_DEV_DIR ]; then
- for i in $USB_PATH/$USB_DEV_DIR/*/modalias ; do
- modprobe -r `cat $i` 2>/dev/null
- done
- fi
- # unload usb bus driver. Does this make sense?
- # what happens, if two usb devices are plugged in
- # and one is removed?
- for i in $USB_PATH/*/modalias ; do
- modprobe -r `cat $i` 2>/dev/null
- done
- # remove device file and possible empty dirs
- rm -f bus/usb/$BUS/$USB_DEV
- rmdir bus/usb/$BUS/ 2>/dev/null
- rmdir bus/usb/ 2>/dev/null
- rmdir bus/ 2>/dev/null
+add)
+ mkdir -p "${DEVNAME%/*}"
+ mv $MDEV $DEVNAME
+ # autoload driver
+ for i in /sys/$DEVPATH/*/modalias; do
+ [ -e "$i" ] && echo $i
+ done | xargs sort -u | xargs modprobe -a 2>/dev/null
+ ;;
+remove)
+ rm $DEVNAME
+ ;;
esac
+