You are not logged in.

#1 2023-04-13 16:05:54

musbur
Member
Registered: 2022-01-14
Posts: 46

udev, hwdb, and my scanner

Hi all,

I'm playing around with an inherited negative scanner. I would like to find it at /dev/scanner. Yes, I can work with scanimage -L and then use whatever device it spits out, but I like it better when it always shows up under /dev/scanner. So I started to write my own udev rule for this thing. Needless to say, I completely failed -- I seem to not be able to convert the output of "udevadm info /dev/bus/usb/..." to anything that udevd recognizes as a rule. Then I looked at some rules in /usr/lub/udev/rules.d but stayed clueless. Then I did "find /usr/lib/udev -type f | xargs grep -i coolscan" and, lo and behold, there it is: "/usr/lib/udev/hwdb.d/20-sane.hwdb:# Nikon Coolscan V ED"  and /usr/lib/udev/hwdb.d/20-usb-vendor-model.hwdb: ID_MODEL_FROM_DATABASE=LS 50 ED/Coolscan V ED"

But these are files for something called "hwdb", and I have no idea if and how this translates into a /dev/something despite some manpage perusal.

So my questions are:

1) How do I write a udev rule that creates a symlink in /dev? I tried this: "ACTION=="connect", SUBSYSTEM=="usb", SYMLINK+="scanner" with the plan to make it more specific once I get it to work at all. Restarting the systemd-udevd and plugging in the scanner didn't create any new symlink in /dev.

2) How can I make use of the hwdb entry for my scanner?

Thanks!

Offline

#2 2023-04-13 17:04:02

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: udev, hwdb, and my scanner

Post the output of udevadm info so more specific advice can be given. For starters I'm fairly certain ACTION=="connect" is not a thing that exists in any context, you'd want add.

As for the hwdb entry, there's nothing you need to do, the hwdb entry will match and apply the relevant settings configured there for your scanner. This is unlikely to have any effect on a symlinking effort.

Last edited by V1del (2023-04-13 17:04:59)

Offline

#3 2023-04-13 18:09:48

musbur
Member
Registered: 2022-01-14
Posts: 46

Re: udev, hwdb, and my scanner

Here is the udevadm output:

$ sudo udevadm info  /dev/bus/usb/001/011
P: /devices/pci0000:00/0000:00:14.0/usb1/1-1
M: 1-1
R: 1
U: usb
T: usb_device
D: c 189:10
N: bus/usb/001/011
L: 0
V: usb
E: DEVPATH=/devices/pci0000:00/0000:00:14.0/usb1/1-1
E: DEVNAME=/dev/bus/usb/001/011
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=4b0/4001/102
E: TYPE=255/255/255
E: BUSNUM=001
E: DEVNUM=011
E: MAJOR=189
E: MINOR=10
E: SUBSYSTEM=usb
E: USEC_INITIALIZED=1719766650
E: ID_BUS=usb
E: ID_MODEL=LS-50_ED
E: ID_MODEL_ENC=LS-50\x20ED
E: ID_MODEL_ID=4001
E: ID_SERIAL=Nikon_LS-50_ED
E: ID_VENDOR=Nikon
E: ID_VENDOR_ENC=Nikon
E: ID_VENDOR_ID=04b0
E: ID_REVISION=0102
E: ID_USB_MODEL=LS-50_ED
E: ID_USB_MODEL_ENC=LS-50\x20ED
E: ID_USB_MODEL_ID=4001
E: ID_USB_SERIAL=Nikon_LS-50_ED
E: ID_USB_VENDOR=Nikon
E: ID_USB_VENDOR_ENC=Nikon
E: ID_USB_VENDOR_ID=04b0
E: ID_USB_REVISION=0102
E: ID_USB_INTERFACES=:ffffff:
E: ID_VENDOR_FROM_DATABASE=Nikon Corp.
E: ID_MODEL_FROM_DATABASE=LS 50 ED/Coolscan V ED
E: libsane_matched=yes
E: ID_PATH=pci-0000:00:14.0-usb-0:1

Offline

#4 2023-04-13 19:15:59

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,425

Re: udev, hwdb, and my scanner

Please use [⁣code][⁣/code] tags for pasting command outputs.

Try

SUBSYSTEM=="usb", ATTRS{vendor}=="Nikon", ATTRS{model}=="LS-50_ED", SYMLINK+="scanner"

and generally make sure you order it late, like 99- or so (... definitely make sure they are after both 65 and 66 sane rules).

Offline

Board footer

Powered by FluxBB