1

I use Advanced Tomato on my Asus RT-AC68R/U. This is Shibby Tomato with some GUI modification only. I want to connect via USB measuring unit and create for it dedicated, unique device. At this moment, Tomato creates device named /dev/usbdevX.Y where X and Y are random numbers. Below is part of my hotplug script. It is not final version, just part of my investigation to resolve the problem.

PRODID="5555/1/600"
SYMLINK="arco"

if [ "${PRODUCT}" = "${PRODID}" ];
then if [ "${ACTION}" = "add" ];
then
DEVICE_NAME=$(ls /sys/$DEVPATH)
echo $DEVICE_NAME > /tmp/arco1
echo $DEVPATH > /tmp/arco2
if [ -z ${DEVICE_NAME} ];
then echo " Hotplug Warning DEVICE_NAME is empty" > /tmp/arco
exit
fi

The variable DEVPATH returns value:

/sys/devices/pci0000:00/0000:00:0b.0/usb3/3-2/3-2:1.0

Variable DEVICE_NAME returns listing of content of /sys/devices/pci0000:00/0000:00:0b.0/usb3/3-2/3-2:1.0 directory.

lsusb returns for that device value:

Bus 003 Device 007: ID 5555:0001

The subdir /sys/devices/pci0000:00/0000:00:0b.0/usb3/3-2/3-2:1.0 consist files:

root@asus:/sys/devices/pci0000:00/0000:00:0b.0/usb3/3-2/3-2:1.0# ls
bAlternateSetting     bInterfaceProtocol    bus                          interface             supports_autosuspend
bInterfaceClass       bInterfaceSubClass    ep_02                 modalias              uevent
bInterfaceNumber      bNumEndpoints         ep_81                 subsystem

And the file uevent consist:

DEVTYPE=usb_interface
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/003/007
PRODUCT=5555/1/600
TYPE=0/0/0
INTERFACE=255/255/255
MODALIAS=usb:v5555p0001d0600dc00dsc00dp00icFFiscFFipFF

Notice that the line:

DEVICE=/proc/bus/usb/003/007

corresponds to lsusb output for that device. So it is for sure my new connected device

My question is. How in this case I can create symbolic link for such random created device to /dev/arco?

migrated from serverfault.com Aug 18 '16 at 19:13

This question came from our site for system and network administrators.

0

Finally I found out solution. This is my working hotplug script. It creates symlink of /dev/arco to new created "generic" device named /dev/usbdev3.Y where Y is a random numbers. I use Advanced Tomato, so the script is added in section NAS&USB -> USB Support -> Hotplug script

PRODID="5555/1/600"
SYMLINK="arco"

if [ "${PRODUCT}" = "${PRODID}" ];
then if [ "${ACTION}" = "add" ];
then
echo $DEVICE > /tmp/arco1


if [ -z ${DEVICE} ];
then echo " Hotplug Warning DEVICE is empty" > /tmp/arco
exit
fi

usb=`echo -n $DEVICE | tail -c 1`
echo " Hotplug Device name of ARCO is $DEVICE" > /tmp/arco
ln -s /dev/usbdev3.$usb /dev/${SYMLINK}
echo " Hotplug Symlink from $DEVICE to /dev/${SYMLINK} created" > /tmp/arco
fi
fi

if [ "${PRODUCT}" = "${PRODID}" ];
then if [ "${ACTION}" = "remove" ];
then rm /dev/${SYMLINK}
echo " Hotplug Symlink /dev/${SYMLINK} removed" > /tmp/arco
fi
fi 

And thats all ;-)

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.