Re: [linux-minidisc] implementing unix himd autodetection function


Am 23.12.2012 16:28, schrieb John Paul Adrian Glaubitz:
On Sun, Dec 23, 2012 at 04:01:20PM +0100, John Paul Adrian Glaubitz wrote:
An easy way would be to use udev which is unfortunately
Linux-specific. udev emumerates devices and can assign device files
according to specific properties (USB IDs, for example). With udev,
you could have any HiMD/NetMD device known from a
himd.rules/netmd.rules file assign the device file /dev/himdN or
/dev/netmdN (N being an integer number).
As a quick follow up, here's a good introductory guide to writing udev
rules [1]. However, I think we should discuss the whole auto detection
mechanism on Linux, *BSD and MacOS X on more detail before we start
implementing it so we can be sure to have maximum cross-platform
compatibility.

Adrian

[1] http://www.reactivated.net/writing_udev_rules.html
I took a look at udev-discoverer gui application to see which information we can get from udev. Is there any way to get the mountpoint? I cannot find anything about that. If not maybe we can use dbus to get the device file and "DriveAdded"/"DriveRemoved" notification and use udev to get the device information for the specified device file. Or better use the other way: use udev to get notifications and device information and than use dbus to get the mountpoint if device is a himd device. Also maybe we could make use of libudev to provide autodetection mechanism without the need to create/install any udev rules.

I think netmd detection at application start is mostly platform independent using libusb, libusb provides it's own enumeration function as used in libnetmd. We just need device added/removed notification to reenumerate libusb devices.

I will read some more about udev.

Thomas