Browse Source

- skel-root/hd1: align mdev-handling to hd2

master
vanhofen 7 years ago
parent
commit
1b319a008a
  1. 57
      skel-root/coolstream/hd1/etc/mdev.conf
  2. 82
      skel-root/coolstream/hd1/etc/mdev/usbdev.sh
  3. 18
      skel-root/coolstream/hd1/etc/mdev/wlan.sh
  4. 33
      skel-root/coolstream/hd1/lib/mdev/common/log
  5. 7
      skel-root/coolstream/hd1/lib/mdev/common/mdevlog
  6. 5
      skel-root/coolstream/hd1/lib/mdev/common/mdevmodule
  7. 9
      skel-root/coolstream/hd1/lib/mdev/common/mdevprobe
  8. 35
      skel-root/coolstream/hd1/lib/mdev/fs/mount
  9. 19
      skel-root/coolstream/hd1/lib/mdev/net/wlan
  10. 32
      skel-root/coolstream/hd1/lib/mdev/usb/eventvars
  11. 119
      skel-root/coolstream/hd1/lib/mdev/usb/usbcontrol

57
skel-root/coolstream/hd1/etc/mdev.conf

@ -8,31 +8,48 @@
# =: move, >: move and create a symlink
# @|$|*: run $cmd on delete, @cmd on create, *cmd on both
null 0:0 0666
zero 0:0 0666
full 0:0 0666
random 0:0 0666
urandom 0:0 0444
#$MODALIAS=.* root:root 0660 @/bin/busybox modprobe "$MODALIAS"
dvb([0-9]).([a-z]*)([0-9]) 0:0 0644 =dvb/adapter%1/%2%3
fb([0-2]) 0:0 0660 >fb/%1
ram1 0:0 0660 >ram
null root:root 0666
zero root:root 0666
full root:root 0666
random root:root 0666
urandom root:root 0444
# HDD/BD-Player
sd[a-z][0-9] 0:0 0664 */etc/mdev/mdev-mount.sh
sr[0-9] 0:0 0664 */etc/mdev/mdev-mount.sh
# Console device
console root:tty 0600
# WLAN devices
wlan[0-9]* 0:0 0660 */etc/mdev/wlan.sh
rausb[0-9]* 0:0 0660 */etc/mdev/wlan.sh
ra[0-9]* 0:0 0660 */etc/mdev/wlan.sh
# TTY devices
ttyS[0-9]* root:root 0660
ttyUSB[0-9]* root:root 0660
# DVB devices
dvb([0-9])\.(.*)([0-9]) root:root 0660 =dvb/adapter%1/%2%3
# Input layer
event[0-9]+ root:root 0640 =input/
mice root:root 0640 =input/
mouse[0-9]+ root:root 0640 =input/
# USB devices
usbdev.* 0:0 0660 */etc/mdev/usbdev.sh
[0-3]-.*:1.0 root:root 0660 */lib/mdev/usb/usbcontrol
# block devices
mtdblock[0-6] 0:0 0660
# HDDs / SD-cards
sd[a-z][0-9] root:root 0664 */lib/mdev/fs/mount
mmcblk[0-9]p[0-9] root:root 0664 */lib/mdev/fs/mount
sr[0-9] root:root 0664 */lib/mdev/fs/mount
# WLAN devices
ra[0-9]* root:root 0644 */lib/mdev/net/wlan
rausb[0-9]* root:root 0644 */lib/mdev/net/wlan
wlan[0-9]* root:root 0644 */lib/mdev/net/wlan
# block devices: group -> disk
mtdblock[0-9] root:root 0600
# double up flash characters devices
mtd[0-6]+ 0:0 0660
mtd[0-6]+ro 0:0 0660
mtd[0-9]+ root:root 0600
mtd[0-9]+ro root:root 0600
# everything else
.* root:root 0600 */lib/mdev/common/mdevlog

82
skel-root/coolstream/hd1/etc/mdev/usbdev.sh

@ -1,82 +0,0 @@
#!/bin/sh
LOG="/bin/logger -p user.info -t mdev-usb"
WARN="/bin/logger -p user.warn -t mdev-usb"
flagLCD=/tmp/.lcd-${MDEV}
# supported dpf-devices
DPF="1908:0102"
# supported spf-devices
SPFstorage="04E8:200A 04E8:200E 04E8:200C 04E8:2012 04E8:2016 04E8:2025 04E8:2033 04E8:201C 04E8:2027 04E8:2035 04E8:204F 04E8:2039"
SPFmonitor="04E8:200B 04E8:200F 04E8:200D 04E8:2013 04E8:2017 04E8:2026 04E8:2034 04E8:201B 04E8:2028 04E8:2036 04E8:2050 04E8:2040"
# SPFmodel: ^SPF-72H ^SPF-75H ^SPF-83H ^SPF-85H ^SPF-85P ^SPF-87H ^SPF-87H ^SPF-105P ^SPF-107H ^SPF-107H ^SPF-700T ^SPF-1000P
# SPFmodel: ^SPF-76H ^SPF-86H ^SPF-86P old new
SPF="${SPFstorage} ${SPFmonitor}"
DEVICES="${DPF} ${SPF}"
for DEVICE in ${DEVICES}; do
V=$(echo ${DEVICE:0:4} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) # lower case vendor w/o leading zeros
P=$(echo ${DEVICE:5:4} | sed 's/^[0]*//' | tr [:upper:] [:lower:]) # lower case product w/o leading zeros
case "$ACTION" in
add|"")
#$LOG "trying to process ${DEVICE} (V:{$V} P:{$P}) on ${MDEV}"
uevent=/sys/class/usb_device/${MDEV}/device/uevent
test -e $uevent || continue
grep "^PRODUCT=${V}/${P}/*" $uevent >/dev/null || continue
$LOG "supported device (ID ${DEVICE}) on ${MDEV} found"
# dpf/spf-support
if $(echo "${DPF} ${SPF}" | grep -q "${DEVICE}"); then
$LOG "creating flagfile '$flagLCD'"
echo "${DEVICE}" > $flagLCD
if $(echo "${DPF} ${SPFstorage}" | grep -q "${DEVICE}"); then
$LOG "DPF or SPF in storage mode found"
$LOG "(re)starting lcd4linux"
service lcd4linux restart
fi
if $(echo "${SPFmonitor}" | grep -q "${DEVICE}"); then
$LOG "SPF in monitor mode found"
if [ -e /tmp/lcd4linux.pid ]; then
$LOG "do nothing"
else
$LOG "(re)starting lcd4linux"
service lcd4linux restart
fi
fi
fi
;;
remove)
#$LOG "trying to process ${DEVICE} (V:{$V} P:{$P}) on ${MDEV}"
# dpf/spf-support
if [ -e $flagLCD ]; then
grep "^${DEVICE}" $flagLCD >/dev/null || continue
$LOG "supported DPF/SPF (ID ${DEVICE}) removed from ${MDEV}"
if $(echo "${DPF} ${SPFmonitor}" | grep -q "${DEVICE}"); then
$LOG "DPF or SPF in monitor mode removed"
$LOG "stopping lcd4linux"
service lcd4linux stop
fi
if $(echo "${SPFstorage}" | grep -q "${DEVICE}"); then
$LOG "SPF in storage mode removed"
$LOG "do nothing"
fi
$LOG "removing flagfile '$flagLCD'"
rm -f $flagLCD
fi
;;
esac
done

18
skel-root/coolstream/hd1/etc/mdev/wlan.sh

@ -1,18 +0,0 @@
#!/bin/sh
LOG="logger -p user.info -t mdev-wlan"
WARN="logger -p user.warn -t mdev-wlan"
case "$ACTION" in
add|"")
if [ -s /etc/wpa_supplicant.conf ]; then
$LOG "trying to bring $MDEV up"
ifup $MDEV
else
$WARN "/etc/wpa_supplicant.conf missing or empty, not trying to bring $MDEV up"
fi
;;
remove)
$LOG "trying to bring $MDEV down"
ifdown $MDEV
;;
esac

33
skel-root/coolstream/hd1/lib/mdev/common/log

@ -0,0 +1,33 @@
#!/bin/sh
# vim: se ft=sh:
log_debug () {
logger -t "${0##*/}[$$]" -p local0.debug "$@"
}
log_error () {
logger -t "${0##*/}[$$]" -p local0.error "$@"
}
log_info () {
logger -t "${0##*/}[$$]" -p local0.info "$@"
}
log_warn () {
logger -t "${0##*/}[$$]" -p local0.warn "$@"
}
# can't get the return code from a piped process
# cat /etc/passwd | log_error => $? is from log_error not cat ;(
log_rt_error () {
local fifo=/tmp/.log_rt_error_$$
trap "trap - HUP QUIT TERM CHLD; log_error exited prematurely; rm -f $fifo; exit 1" \
HUP QUIT TERM
mkfifo -m 600 $fifo
trap "trap - HUP QUIT TERM CHLD; rm -f $fifo" CHLD
log_error <$fifo &
"$@" 2>$fifo
}
log_clean () {
unset -f log_debug log_error log_info log_rt_error
}

7
skel-root/coolstream/hd1/lib/mdev/common/mdevlog

@ -0,0 +1,7 @@
#!/bin/sh
# log only when requested
[ 0 -eq $# ] && exit 0
. /lib/mdev/common/log
env | egrep -v '^(HOME|PATH|PWD|CONFIG_.*)=' | log_debug

5
skel-root/coolstream/hd1/lib/mdev/common/mdevmodule

@ -0,0 +1,5 @@
#!/bin/sh
. /lib/mdev/common/log
log_info "${ACTION:-scan} module chain $@"
/lib/mdev/common/mdevprobe "$@"

9
skel-root/coolstream/hd1/lib/mdev/common/mdevprobe

@ -0,0 +1,9 @@
#!/bin/sh
[ "$ACTION" = remove ] && action='-r -a'
. /lib/mdev/common/log
for module in "$@"; do
modprobe $action $module &&
log_info "${ACTION:-scan} module $module succeed"
done

35
skel-root/coolstream/hd1/etc/mdev/mdev-mount.sh → skel-root/coolstream/hd1/lib/mdev/fs/mount

@ -1,6 +1,9 @@
#!/bin/sh
LOG="logger -p user.info -t mdev-mount"
WARN="logger -p user.warn -t mdev-mount"
# based on script from http://gitorious.org/neutrino-hd/buildsystem-cs
. /lib/mdev/common/log
MOUNTBASE=/media
MOUNTPOINT="$MOUNTBASE/$MDEV"
@ -9,7 +12,7 @@ ROOTDEV=$(readlink /dev/root)
# do not add or remove root device again...
[ "$ROOTDEV" = "$MDEV" ] && exit 0
if [ -e /tmp/.nomdevmount ]; then
$LOG "no action on $MDEV -- /tmp/.nomdevmount exists"
log_info "no action on $MDEV -- /tmp/.nomdevmount exists"
exit 0
fi
@ -58,24 +61,24 @@ remove_symlinks() {
}
case "$ACTION" in
add|"")
add)
if [ ${#MDEV} = 3 ]; then # sda, sdb, sdc => whole drive
PARTS=$(sed -n "/ ${MDEV}[0-9]$/{s/ *[0-9]* *[0-9]* * [0-9]* //;p}" /proc/partitions)
if [ -n "$PARTS" ]; then
$LOG "drive has partitions $PARTS, not trying to mount $MDEV"
log_info "drive has partitions $PARTS, not trying to mount $MDEV"
exit 0
fi
fi
if grep -q "/dev/$MDEV" /proc/mounts; then
$LOG "/dev/$MDEV already mounted - not mounting again"
log_info "/dev/$MDEV already mounted - not mounting again"
exit 0
fi
$LOG "[$ACTION] mounting /dev/$MDEV to $MOUNTPOINT"
log_info "[$ACTION] mounting /dev/$MDEV to $MOUNTPOINT"
# remove old mountpoint symlinks we might have for this device
rm -f $MOUNTPOINT
mkdir -p $MOUNTPOINT
for i in 1 2 3 4 5 6 7 8 9; do # retry 9 times for slow devices
# $LOG "mounting /dev/$MDEV to $MOUNTPOINT try $i"
# log_info "mounting /dev/$MDEV to $MOUNTPOINT try $i"
OUT1=$(mount -t auto /dev/$MDEV $MOUNTPOINT 2>&1 >/dev/null)
RET1=$?
[ $RET1 = 0 ] && break
@ -84,21 +87,27 @@ case "$ACTION" in
if [ $RET1 = 0 ]; then
create_symlinks
else
$WARN "mount /dev/$MDEV $MOUNTPOINT failed with $RET1"
$WARN " $OUT1"
log_warn "mount /dev/$MDEV $MOUNTPOINT failed with $RET1"
log_warn " $OUT1"
rmdir $MOUNTPOINT
fi
if [ -x /bin/mdev_helper ]; then
/bin/mdev_helper
fi
;;
remove)
$LOG "[$ACTION] unmounting /dev/$MDEV"
log_info "[$ACTION] unmounting $MOUNTBASE/$MDEV"
grep -q "^/dev/$MDEV " /proc/mounts || exit 0 # not mounted...
umount -lf /dev/$MDEV
umount -lf $MOUNTBASE/$MDEV
RET=$?
if [ $RET = 0 ]; then
rmdir $MOUNTPOINT
remove_symlinks
else
$WARN "umount /dev/$MDEV failed with $RET"
log_warn "umount $MOUNTBASE/$MDEV failed with $RET"
fi
if [ -x /bin/mdev_helper ]; then
/bin/mdev_helper
fi
;;
esac

19
skel-root/coolstream/hd1/lib/mdev/net/wlan

@ -0,0 +1,19 @@
#!/bin/sh
. /lib/mdev/common/log
case "$ACTION" in
add|"")
if [ -s /etc/wpa_supplicant.conf ]; then
log_info "trying to bring $MDEV up"
ifup $MDEV
else
log_warn "/etc/wpa_supplicant.conf missing or empty, not trying to bring $MDEV up"
fi
;;
remove)
log_info "trying to bring $MDEV down"
ifdown $MDEV
;;
esac

32
skel-root/coolstream/hd1/lib/mdev/usb/eventvars

@ -0,0 +1,32 @@
#!/bin/false
# vim: se ft=sh:
for path in $(find /sys/devices -name "$MDEV" 2>/dev/null); do
DEVPATH=${path#/sys}
done
MODALIAS=$(cat /sys${DEVPATH}/modalias 2>/dev/null)
parse_interface () {
printf '%d/%d/%d' $(sed 's/.*dp[0-F]\{2\}//;s/[iscp]\+/ 0x/g')
}
parse_type () {
printf '%d/%d/%d' $(sed 's/.*d[0-9]\{4\}//;s/ic.*//;s/[dscp]\+/ 0x/g')
}
parse_product () {
sed 's!^usb:\(.*\)dc.*!\1!;s![vpd]!/!g;s!/0\{1,3\}!/!g;s!^/!!;y!ABCDEF!abcdef!'
}
TYPE=$(echo $MODALIAS | parse_type)
PRODUCT=$(echo $MODALIAS | parse_product)
INTERFACE=$(echo $MODALIAS | parse_interface)
for var in DEVPATH MODALIAS TYPE PRODUCT INTERFACE; do
if [ -z "$(eval "echo \$${var}")" ]; then
logerror "Could not set uevent environment variable $var"
exit 1
fi
done
unset path var
unset -f parse_type parse_interface parse_product

119
skel-root/coolstream/hd1/lib/mdev/usb/usbcontrol

@ -0,0 +1,119 @@
#!/bin/sh
. /lib/mdev/common/log
# setup environment for cold plug events
[ -z "$ACTION" ] && . /lib/mdev/usb/eventvars
# get proper product and manufacturer description (only works for ACTION=add)
[ -z "$DEVPATH" ] && logerror 'uevent environment variable DEVPATH is unset' && exit 1
if [ -d /sys${DEVPATH} ]; then
cd /sys${DEVPATH}/..
for f in product manufacturer id[PV]*; do
[ -r $f ] && eval "$f='$(cat $f)'"
done
cd $MDEV
fi
# get $idVendor and $idProduct from $MODALIAS if necessary
idVendor=${idVendor:-${MODALIAS:5:4}}
idProduct=${idProduct:-${MODALIAS:10:4}}
# set $idVendor and $idProduct lower case and w/o leading zeros
idVendor=$(echo ${idVendor} | sed 's/^[0]*//' | tr [:upper:] [:lower:])
idProduct=$(echo ${idProduct} | sed 's/^[0]*//' | tr [:upper:] [:lower:])
channel=${MDEV%:1.0}
log_info "${ACTION} $channel ${manufacturer:-$idVendor} ${product:-$idProduct}"
# for debug
#log_info "ACTION=${ACTION}"
#log_info "MDEV=${MDEV}"
#log_info "DEVPATH=${DEVPATH}"
#log_info "INTERFACE=${INTERFACE}"
#log_info "MODALIAS=${MODALIAS}"
#log_info "PRODUCT=${product} idProduct=${idProduct}"
#log_info "MANUFACTURER=${manufacturer} idVendor=${idVendor}"
# http://en.wikipedia.org/wiki/Universal_Serial_Bus#Device_classes
# http://www.usb.org/developers/defined_class
[ 0 -eq "${TYPE%%/*}" ] && TYPE=$INTERFACE
log_info "type ${TYPE}"
case $TYPE in
1/*/*)
log_info "$channel USB Audio Interface"
;;
2/*/*)
log_info "$channel Communications and CDC Control"
;;
3/*/*)
log_info "$channel HID (Human Interface Device)"
# precheck vendor id for unsupported DPF in bootloader mode
if [ "$idVendor" == "1908" ]; then
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct}
fi
;;
5/*/*)
log_info "$channel Physical Interface"
;;
6/*/*)
log_info "$channel Image Interface"
;;
7/*/*)
log_info "$channel Printer Interface"
;;
8/*/*)
log_info "$channel Mass Storage Interface"
# precheck vendor id for supported SPFs
if [ "$idVendor" == "4e8" ]; then
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct}
fi
;;
9/*/*)
log_info "$channel HUB Device"
;;
10/*/*)
log_info "$channel CDC Data Interface"
;;
11/*/*)
log_info "$channel Smart Card Interface"
;;
13/*/*)
log_info "$channel Content Security Interface"
;;
14/*/*)
log_info "$channel Video Interface"
;;
15/*/*)
log_info "$channel Personal Healthcare Interface"
;;
16/*/*)
log_info "$channel usb Audio/Video Devices Interface"
;;
17/*/*)
log_info "$channel Billboard Device Class"
;;
220/*/*)
log_info "$channel Diagnostic Device"
;;
224/*/*)
log_info "$channel Wireless Controller Interface"
;;
239/*/*)
log_info "$channel Miscellaneous"
;;
254/*/*)
log_info "$channel Application Specific"
;;
255/*/*)
log_info "$channel Vendor Specific"
# precheck vendor id for supported DPFs and SPFs
if [ "$idVendor" = "1908" -o "$idVendor" == "4e8" ]; then
service extdisplay ${ACTION} ${MDEV} ${idVendor} ${idProduct}
fi
;;
*)
log_info "FALLBACK: $channel device $MODALIAS"
;;
esac
/lib/mdev/common/mdevprobe $MODALIAS
Loading…
Cancel
Save