Linux – Ignoring other USB devices in a udev rule

linuxudevusb

Is it possible to create a udev rule for an USB device and ignore other USB devices?

I want my system to support HID USB touchscreen (hid.ko) and ignore HID devices such as keyboards, mice, etc.

Best Answer

By the time udev is running to handle creating the device, it's too lateā€”the kernel has already attached the HID driver to the mouse/keyboard/etc.

Instead, you should be able to use the USB authorization framework (I've personally never used this, so I can't vouch it works). Basically, you tell Linux not to authorize new USB devices. Then you individually authorize each one by doing echo 1 > /sys/bus/usb/devices/DEVICE/authorized as root.

You can set the default to not authorized via the usbcore authorized_default=0 module parameter or the usbcore.authorized_default=0 kernel parameter (if USB isn't compiled as a module). Alternatively, you can do it on a per-bus basis, after boot, with echo 0 > /sys/bus/usb/devices/usbX/authorized_default.

Related Question