- : controller_dev $controller_dev
- #
- # usb-storage devs have a serial number, hopefully unique
- serial=
- if [ -f $controller_dev/../serial ] ; then
- serial="`sed -e 's@^[ -]\{1,\}\|[ -]\{1,\}$@@g;s@[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789-]@@g' < $controller_dev/../serial`"
- : serial XXX_${serial}_XXX
- d="usb-$serial"
- serial="`echo $serial | sed -e 's@[ 0]\{1,\}@@g'`"
- fi
- if [ -z "$serial" ] ; then
- # no serial, broken device
- # has eventually binary junk in vpd
- identifier=
- if [ -f $controller_dev/../product ] ; then
- product="`sed -e 's@^[ -]\{1,\}\|[ -]\{1,\}$@@g;s@[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789-]@@g' < $controller_dev/../product`"
- fi
- if [ -f $controller_dev/../manufacturer ] ; then
- manufacturer="`sed -e 's@^[ -]\{1,\}\|[ -]\{1,\}$@@g;s@[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789-]@@g' < $controller_dev/../manufacturer`"
- fi
- if [ -z "$product" -o -z "$manufacturer" ] ; then
- read idvendor < $controller_dev/../idVendor
- read idproduct < $controller_dev/../idProduct
- identifier="0x${idvendor}-0x${idproduct}"
- else
- identifier="${manufacturer}-${product}"
- fi
- d="usb-${identifier}"
+ : host_dev_path $host_dev_path
+ usb_host_num=${usb_host_path##*/usb}
+
+ cd "$host_dev_path"
+ usb_host_offset=$(get_port_offset usb $usb_host_num)
+ usb_host_port=$(($usb_host_num - $usb_host_offset))
+ cd "$OPWD"
+
+ if [ "$d" ] ; then
+ d="usb-$usb_host_port:$port_num-${d}"
+ else
+ d="usb-$usb_host_port:$port_num"