* Matching different levels in sysfs
@ 2006-01-26 0:29 Chris Adams
2006-01-26 1:48 ` Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chris Adams @ 2006-01-26 0:29 UTC (permalink / raw)
To: linux-hotplug
I've got a USB device that I'd like to create a symlink for. It is a
USB-to-serial adapter board that I've used to hook up a GPS interface,
so I'd like the GPS to show up as /dev/gps (I've got multiple
USB-to-serial adapters, so tracking the correct /dev/ttyUSB and getting
the permissions set correctly is otherwise a PITA).
The problem is that this particular USB-to-serial adapter has two serial
ports and the GPS interface is only hooked up to one. I can match the
USB device by serial number, but that is at a different level from the
individual port (the serial number is for the whole device). udevinfo
shows (interesting sections):
########################################################################
# udevinfo -a -p /sys/class/tty/ttyUSB2
udevinfo starts with the device the node belongs to and then walks up the
device chain, to print for every device found, all possibly useful attributes
in the udev key format.
Only attributes within one device section may be used together in one rule,
to match the device for which the node will be created.
looking at class device '/sys/class/tty/ttyUSB2':
SYSFS{dev}="188:2"
follow the class device's "device"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1/ttyUSB2':
BUS="usb-serial"
ID="ttyUSB2"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1':
BUS="usb"
ID="1-6.1:1.1"
SYSFS{bAlternateSetting}=" 0"
SYSFS{bInterfaceClass}="ff"
SYSFS{bInterfaceNumber}="01"
SYSFS{bInterfaceProtocol}="ff"
SYSFS{bInterfaceSubClass}="ff"
SYSFS{bNumEndpoints}="02"
SYSFS{interface}="DLP2232M"
SYSFS{modalias}="usb:v0403p6010d0500dc00dsc00dp00icFFiscFFipFF"
looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1':
BUS="usb"
ID="1-6.1"
SYSFS{bConfigurationValue}="1"
SYSFS{bDeviceClass}="00"
SYSFS{bDeviceProtocol}="00"
SYSFS{bDeviceSubClass}="00"
SYSFS{bMaxPower}="274mA"
SYSFS{bNumConfigurations}="1"
SYSFS{bNumInterfaces}=" 2"
SYSFS{bcdDevice}="0500"
SYSFS{bmAttributes}="80"
SYSFS{devnum}="6"
SYSFS{idProduct}="6010"
SYSFS{idVendor}="0403"
SYSFS{latency_timer}="16"
SYSFS{latency_timer}="16"
SYSFS{manufacturer}="FTDI"
SYSFS{maxchild}="0"
SYSFS{product}="DLP2232M"
SYSFS{serial}="FTOIQ4MN"
SYSFS{speed}="12"
SYSFS{version}=" 2.00"
########################################################################
I'd like to match SYSFS{bInterfaceNumber}="01" and
SYSFS{serial}="FTOIQ4MN", but I don't see how.
I'm planning to use the other port on the board for something else, so I
need a reliable way to distinguish between the two.
--
Chris Adams <cmadams@hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching different levels in sysfs
2006-01-26 0:29 Matching different levels in sysfs Chris Adams
@ 2006-01-26 1:48 ` Kay Sievers
2006-01-26 19:40 ` Andrey Borzenkov
2006-01-28 1:29 ` Chris Adams
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2006-01-26 1:48 UTC (permalink / raw)
To: linux-hotplug
On Wed, Jan 25, 2006 at 06:29:22PM -0600, Chris Adams wrote:
> I've got a USB device that I'd like to create a symlink for. It is a
> USB-to-serial adapter board that I've used to hook up a GPS interface,
> so I'd like the GPS to show up as /dev/gps (I've got multiple
> USB-to-serial adapters, so tracking the correct /dev/ttyUSB and getting
> the permissions set correctly is otherwise a PITA).
>
> The problem is that this particular USB-to-serial adapter has two serial
> ports and the GPS interface is only hooked up to one. I can match the
> USB device by serial number, but that is at a different level from the
> individual port (the serial number is for the whole device). udevinfo
> shows (interesting sections):
>
> ########################################################################
> # udevinfo -a -p /sys/class/tty/ttyUSB2
>
> udevinfo starts with the device the node belongs to and then walks up the
> device chain, to print for every device found, all possibly useful attributes
> in the udev key format.
> Only attributes within one device section may be used together in one rule,
> to match the device for which the node will be created.
>
> looking at class device '/sys/class/tty/ttyUSB2':
> SYSFS{dev}="188:2"
>
> follow the class device's "device"
> looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1/ttyUSB2':
> BUS="usb-serial"
> ID="ttyUSB2"
> looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1':
> BUS="usb"
> ID="1-6.1:1.1"
> SYSFS{bAlternateSetting}=" 0"
> SYSFS{bInterfaceClass}="ff"
> SYSFS{bInterfaceNumber}="01"
> SYSFS{bInterfaceProtocol}="ff"
> SYSFS{bInterfaceSubClass}="ff"
> SYSFS{bNumEndpoints}="02"
> SYSFS{interface}="DLP2232M"
> SYSFS{modalias}="usb:v0403p6010d0500dc00dsc00dp00icFFiscFFipFF"
>
> looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1':
> BUS="usb"
> ID="1-6.1"
> SYSFS{bConfigurationValue}="1"
> SYSFS{bDeviceClass}="00"
> SYSFS{bDeviceProtocol}="00"
> SYSFS{bDeviceSubClass}="00"
> SYSFS{bMaxPower}="274mA"
> SYSFS{bNumConfigurations}="1"
> SYSFS{bNumInterfaces}=" 2"
> SYSFS{bcdDevice}="0500"
> SYSFS{bmAttributes}="80"
> SYSFS{devnum}="6"
> SYSFS{idProduct}="6010"
> SYSFS{idVendor}="0403"
> SYSFS{latency_timer}="16"
> SYSFS{latency_timer}="16"
> SYSFS{manufacturer}="FTDI"
> SYSFS{maxchild}="0"
> SYSFS{product}="DLP2232M"
> SYSFS{serial}="FTOIQ4MN"
> SYSFS{speed}="12"
> SYSFS{version}=" 2.00"
> ########################################################################
>
> I'd like to match SYSFS{bInterfaceNumber}="01" and
> SYSFS{serial}="FTOIQ4MN", but I don't see how.
Udev does not match on different levels with built-in logic, but you should be
able to use something like: SYSFS{bInterfaceNumber}="01", SYSFS{../serial}="FTOIQ4MN".
That makes you dependent on the hierarchy in /sys/devices, which is not guaranteed
to be stable if the kernel code may be changed, but it's very unlikely in this example,
that the usb sysfs layout will be changed, so you should be pretty safe with the "../".
Kay
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching different levels in sysfs
2006-01-26 0:29 Matching different levels in sysfs Chris Adams
2006-01-26 1:48 ` Kay Sievers
@ 2006-01-26 19:40 ` Andrey Borzenkov
2006-01-28 1:29 ` Chris Adams
2 siblings, 0 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2006-01-26 19:40 UTC (permalink / raw)
To: linux-hotplug
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Thursday 26 January 2006 04:48, Kay Sievers wrote:
> On Wed, Jan 25, 2006 at 06:29:22PM -0600, Chris Adams wrote:
> > I've got a USB device that I'd like to create a symlink for. It is a
> > USB-to-serial adapter board that I've used to hook up a GPS interface,
> > so I'd like the GPS to show up as /dev/gps (I've got multiple
> > USB-to-serial adapters, so tracking the correct /dev/ttyUSB and getting
> > the permissions set correctly is otherwise a PITA).
> >
> > The problem is that this particular USB-to-serial adapter has two serial
> > ports and the GPS interface is only hooked up to one. I can match the
> > USB device by serial number, but that is at a different level from the
> > individual port (the serial number is for the whole device). udevinfo
> > shows (interesting sections):
> >
> > ########################################################################
> > # udevinfo -a -p /sys/class/tty/ttyUSB2
> >
> > udevinfo starts with the device the node belongs to and then walks up the
> > device chain, to print for every device found, all possibly useful
> > attributes in the udev key format.
> > Only attributes within one device section may be used together in one
> > rule, to match the device for which the node will be created.
> >
> > looking at class device '/sys/class/tty/ttyUSB2':
> > SYSFS{dev}="188:2"
> >
> > follow the class device's "device"
> > looking at the device chain at
> > '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1/ttyUSB2':
> > BUS="usb-serial"
> > ID="ttyUSB2"
> > looking at the device chain at
> > '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1/1-6.1:1.1':
> > BUS="usb"
> > ID="1-6.1:1.1"
> > SYSFS{bAlternateSetting}=" 0"
> > SYSFS{bInterfaceClass}="ff"
> > SYSFS{bInterfaceNumber}="01"
> > SYSFS{bInterfaceProtocol}="ff"
> > SYSFS{bInterfaceSubClass}="ff"
> > SYSFS{bNumEndpoints}="02"
> > SYSFS{interface}="DLP2232M"
> > SYSFS{modalias}="usb:v0403p6010d0500dc00dsc00dp00icFFiscFFipFF"
> >
> > looking at the device chain at
> > '/sys/devices/pci0000:00/0000:00:10.4/usb1/1-6/1-6.1': BUS="usb"
> > ID="1-6.1"
> > SYSFS{bConfigurationValue}="1"
> > SYSFS{bDeviceClass}="00"
> > SYSFS{bDeviceProtocol}="00"
> > SYSFS{bDeviceSubClass}="00"
> > SYSFS{bMaxPower}="274mA"
> > SYSFS{bNumConfigurations}="1"
> > SYSFS{bNumInterfaces}=" 2"
> > SYSFS{bcdDevice}="0500"
> > SYSFS{bmAttributes}="80"
> > SYSFS{devnum}="6"
> > SYSFS{idProduct}="6010"
> > SYSFS{idVendor}="0403"
> > SYSFS{latency_timer}="16"
> > SYSFS{latency_timer}="16"
> > SYSFS{manufacturer}="FTDI"
> > SYSFS{maxchild}="0"
> > SYSFS{product}="DLP2232M"
> > SYSFS{serial}="FTOIQ4MN"
> > SYSFS{speed}="12"
> > SYSFS{version}=" 2.00"
> > ########################################################################
> >
> > I'd like to match SYSFS{bInterfaceNumber}="01" and
> > SYSFS{serial}="FTOIQ4MN", but I don't see how.
>
> Udev does not match on different levels with built-in logic, but you should
> be able to use something like: SYSFS{bInterfaceNumber}="01",
> SYSFS{../serial}="FTOIQ4MN".
>
> That makes you dependent on the hierarchy in /sys/devices, which is not
> guaranteed to be stable if the kernel code may be changed, but it's very
> unlikely in this example, that the usb sysfs layout will be changed, so you
> should be pretty safe with the "../".
>
It may be possible using GOTO
SYSFS{bInterfaceNumber}!="01", GOTO="not_gps"
SYSFS{serial}="FTOIQ4MN", SYMLINK+="gps"
LABEL="not_gps"
Not sure if this is more portable, but it avoids need to know exact sysfs
structure.
- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
iD8DBQFD2SWhR6LMutpd94wRAronAKC0IcfiGzPvK6IO2vgEDWfW66suvwCbB/yh
oRRKAF6SXaATwzWOmfB9xvE=/pqZ
-----END PGP SIGNATURE-----
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Matching different levels in sysfs
2006-01-26 0:29 Matching different levels in sysfs Chris Adams
2006-01-26 1:48 ` Kay Sievers
2006-01-26 19:40 ` Andrey Borzenkov
@ 2006-01-28 1:29 ` Chris Adams
2 siblings, 0 replies; 4+ messages in thread
From: Chris Adams @ 2006-01-28 1:29 UTC (permalink / raw)
To: linux-hotplug
Once upon a time, Chris Adams <cmadams@hiwaay.net> said:
> I'd like to match SYSFS{bInterfaceNumber}="01" and
> SYSFS{serial}="FTOIQ4MN", but I don't see how.
Well, I tried both of the suggestions, SYSFS{../serial} and GOTO, but
neither worked (may be due to this being a Fedora Core 3 system with
udev-039). I ended up with:
KERNEL="ttyUSB*", SYSFS{serial}="FTOIQ4MN", PROGRAM="/bin/cat /sys/class/tty/%k/device/../bInterfaceNumber", RESULT="01", NAME="%k", SYMLINK="gps%e"
Not the prettiest but it works.
--
Chris Adams <cmadams@hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid\x103432&bid#0486&dat\x121642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-01-28 1:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-01-26 0:29 Matching different levels in sysfs Chris Adams
2006-01-26 1:48 ` Kay Sievers
2006-01-26 19:40 ` Andrey Borzenkov
2006-01-28 1:29 ` Chris Adams
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).