/lib/udev/usb_modeswitch is in usb-modeswitch 2.2.5+repack0-1ubuntu1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | #!/bin/sh
# part of usb_modeswitch 2.2.5
device_in()
{
if [ ! -e /var/lib/usb_modeswitch/$1 ]; then
return 0
fi
while read line
do
if [ $(expr "$line" : "$2:$3") != 0 ]; then
return 1
fi
done </var/lib/usb_modeswitch/$1
if [ $(expr "$line" : "$2:$3") != 0 ]; then
return 1
fi
return 0
}
if [ $(expr "$1" : "--.*") ]; then
p_id=$4
if [ -z $p_id ]; then
prod=$5
if [ -z $prod ]; then
prod=$3
fi
prod=${prod%/*}
v_id=0x${prod%/*}
p_id=0x${prod#*/}
if [ "$v_id" = "0x" ]; then
v_id="0"
p_id="0"
fi
v_id="$(printf %04x $(($v_id)))"
p_id="$(printf %04x $(($p_id)))"
else
v_id=$3
fi
fi
PATH=/sbin:/usr/sbin:$PATH
case "$1" in
--driver-bind)
(
dir=$(ls -d /sys$2/ttyUSB* 2>/dev/null)
sleep 1
if [ ! -z "$dir" ]; then
exit 0
fi
set +e
device_in "bind_list" $v_id $p_id
if [ "$?" = "1" ]; then
id_attr="/sys/bus/usb-serial/drivers/option1/new_id"
if [ ! -e "$id_attr" ]; then
modprobe option 2>/dev/null || true
fi
if [ -e "$id_attr" ]; then
echo "$v_id $p_id ff" > $id_attr
else
modprobe -r usbserial 2>/dev/null
modprobe usbserial "vendor=0x$v_id" "product=0x$p_id" 2>/dev/null
fi
fi
) &
exit 0
;;
--symlink-name)
device_in "link_list" $v_id $p_id
if [ "$?" = "1" ]; then
. /lib/udev/hotplug.functions
wait_for_file /usr/sbin/usb_modeswitch_dispatcher
exec usb_modeswitch_dispatcher $1 $2 >>/dev/null 2>&1
fi
exit 0
;;
esac
(
IFS='/' read -r p1 p2 <<EOF
$1
EOF
PATH=/bin:/sbin:/usr/bin:/usr/sbin
. /lib/udev/hotplug.functions
wait_for_file /usr/sbin/usb_modeswitch_dispatcher
if [ -d "/run/systemd/system/" ]; then # Test if systemd is running
exec systemctl --no-block start usb_modeswitch@${p1:+${p1}_}$p2.service
elif [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then # Test if upstart is running
exec initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
else
export TMPDIR=/run
exec usb_modeswitch_dispatcher --switch-mode $1 >>/dev/null 2>&1 &
fi
exit 0
) &
exit 0
|