Re: Figuring out devnodes from a usb device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 3, 2010 at 09:28, Felipe Balbi <me@xxxxxxxxxxxxxxx> wrote:
>>> For example, if I attach a usb mass storage device I want to
>>> figure out which /dev/sdXX I'm supposed to use when trying to read/write
>>> to that particular device. Similarly for ACM, Network and all other devices.
>>
>> For each type of device, you are going to have to do it differently.
>> And note that network devices don't have device nodes, so that makes it
>> harder to make a "general" case here.
>>
>>> Is there any way to achieve that with libudev ?

That's not provided by libudev, but would be possible to do.
It would need an 'udev enumerator' that starts at a given device,
and returns a list of all the children, which can be investigated
individually. All current 'enumerators' only operate on specific
properties of a device, not on parent-child relations.

All devices belonging to a specific USB device are sysfs child devices of
it. It's a simple tree you can walk. The child devices may have their own
device nodes (here: mouse2, event10), and may also belong to different
subsystems (here: input, hid).

That should work for all interfaces a device provides and which is
currently bound by a kernel driver. Note, that not all drivers use a device
node as the interface. No device node does never mean, that there is no
active driver.

  $ tree -d /sys/bus/usb/devices/5-2.1.2
  /sys/bus/usb/devices/5-2.1.2
  ├── 5-2.1.2:1.0
  │   ├── 0003:046D:C045.0009
  │   │   ├── driver -> ../../../../../../../../../bus/hid/drivers/generic-usb
  │   │   ├── power
  │   │   └── subsystem -> ../../../../../../../../../bus/hid
  │   ├── driver -> ../../../../../../../../bus/usb/drivers/usbhid
  │   ├── ep_81
  │   │   └── power
  │   ├── input
  │   │   └── input16
  │   │       ├── capabilities
  │   │       ├── device -> ../../../5-2.1.2:1.0
  │   │       ├── event10
  │   │       │   ├── device -> ../../input16
  │   │       │   ├── power
  │   │       │   └── subsystem -> ../../../../../../../../../../../class/input
  │   │       ├── id
  │   │       ├── mouse2
  │   │       │   ├── device -> ../../input16
  │   │       │   ├── power
  │   │       │   └── subsystem -> ../../../../../../../../../../../class/input
  │   │       ├── power
  │   │       └── subsystem -> ../../../../../../../../../../class/input
  │   ├── power
  │   └── subsystem -> ../../../../../../../../bus/usb
  ├── driver -> ../../../../../../../bus/usb/drivers/usb
  ├── ep_00
  │   └── power
  ├── power
  └── subsystem -> ../../../../../../../bus/usb

Kay

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel]     [Linux DVB]     [Asterisk Internet PBX]     [DCCP]     [Netdev]     [X.org]     [Util Linux NG]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux