[wellylug] HotSyncing USB Palms - UDEV

David Antliff dave.antliff at paradise.net.nz
Sun Mar 28 01:59:28 NZST 2004


On Sun, 28 Mar 2004, Robin Hinde wrote:

> I suppose the correct way is to create a link /dev/pilot that points to
> /dev/ttyUSB1

Just for interest, when you have multiple USB devices 'udev' really
shines. It is a total replacement for static dev nodes and devfsd that
runs in userspace. The way it works is it 'matches' certain rules with
information obtained from a device you may have just connected, such as
manufacturer info, serial number, bus ID, etc, and creates the appropriate
device node in /dev, just as a system using devfs would do. However,
imagine you have two USB devices - they come up as /dev/sda1 for the first
device, and /dev/sdb1 for the second. If you change the order you connect
them, they appear the other way around. A real pain for syncing scripts or
whatnot. Udev goes a step further and creates a symlink (named by the
rules you provide) so you can always access a single device regardless of
where or when it is attached by a constant and well defined name.

E.g. I have a USB digital camera and a USB mp3 player. Both come up as
/dev/sd[ab]1?. But udev, based on rules I wrote with the udev support
tools, creates symlinks /dev/camera1 and /dev/mp3player1 regardless of the
order I connect them. It's very cool. It guarantees that /dev/camera1 will
always point to the correct device node, no matter what it comes up as.

It works across buses too - imagine a single device that could be
connected via (for example) USB, firewire, serial and parallel port. Udev
will create a symlink automatically that can always be used to access this
device, regardless of whether the 'real' device node is /dev/ttyUSB1,
/dev/sda1, /dev/ttyS0 or whatever.

Another useful example involves multiple printers on the same bus
interface. If you've ever tried to set up two USB printers you'll know
what I'm talking about, and hopefully you will see the benefits of udev.

Just something to look forward to if you use several different
hotpluggable devices and you're thinking of trying out Linux 2.6. If
you're running Gentoo and you'd like to know more about setting up udev,
I'd be happy to answer your questions.

Cheers,
David.





More information about the wellylug mailing list