From: Simon Huggins Date: Fri, 16 Jun 2006 08:05:01 +0000 Subject: udev doesn't know about devices further up the tree. Message-Id: <20060616080501.GG26715@paranoidfreak.co.uk> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============2085009557==" List-Id: To: linux-hotplug@vger.kernel.org --===============2085009557== Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3ozdenm5Azl6mQ8k" Content-Disposition: inline --3ozdenm5Azl6mQ8k Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, I wrote my first udev rule the other day. It reads: KERNEL=3D=3D"sd*", PROGRAM=3D"/home/huggie/bin/camera %k", SYMLINK+=3D"%c" where bin/camera does: DEV=3D$1 DISK=3D`echo $DEV|sed -e 's/.*\(sd.\).*/\1/;'` udevinfo -a -p /block/$DISK/$DEV|grep manuf|grep PENTAX >/dev/null 2>&1 && \ echo camera && exit 0 i.e. basically if the usb device (or any device because I'm not that fussy) above the block device is made by PENTAX then echo camera otherwise I just echo $DEV back again. But it strikes me as a bug that I have to spawn out of udevd to run udevinfo in order to just name the device based on what it is. Why aren't SYSFS attributes from higher up the device path available somehow when writing rules? Here's the udevinfo output: 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 attribut= es 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 device '/block/sdc/sdc1': KERNEL=3D=3D"sdc1" SUBSYSTEM=3D=3D"block" SYSFS{stat}=3D=3D" 350 350 0 0" SYSFS{size}=3D=3D"1002455" SYSFS{start}=3D=3D"41" SYSFS{dev}=3D=3D"8:33" looking at device '/block/sdc': ID=3D=3D"sdc" BUS=3D=3D"block" DRIVER=3D=3D"" SYSFS{stat}=3D=3D" 23 328 358 302 0 0= 0 0 0 302 302" SYSFS{size}=3D=3D"1002496" SYSFS{removable}=3D=3D"1" SYSFS{range}=3D=3D"16" SYSFS{dev}=3D=3D"8:32" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:= 1.0/host16/target16:0:0/16:0:0:0': ID=3D=3D"16:0:0:0" BUS=3D=3D"scsi" DRIVER=3D=3D"sd" SYSFS{ioerr_cnt}=3D=3D"0x0" SYSFS{iodone_cnt}=3D=3D"0x27" SYSFS{iorequest_cnt}=3D=3D"0x27" SYSFS{iocounterbits}=3D=3D"32" SYSFS{timeout}=3D=3D"30" SYSFS{state}=3D=3D"running" SYSFS{rev}=3D=3D"1.00" SYSFS{model}=3D=3D"DIGITAL_CAMERA " SYSFS{vendor}=3D=3D"PENTAX " SYSFS{scsi_level}=3D=3D"3" SYSFS{type}=3D=3D"0" SYSFS{queue_type}=3D=3D"none" SYSFS{queue_depth}=3D=3D"1" SYSFS{device_blocked}=3D=3D"0" SYSFS{max_sectors}=3D=3D"240" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:= 1.0/host16/target16:0:0': ID=3D=3D"target16:0:0" BUS=3D=3D"" DRIVER=3D=3D"" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:= 1.0/host16': ID=3D=3D"host16" BUS=3D=3D"" DRIVER=3D=3D"" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:= 1.0': ID=3D=3D"2-2.2:1.0" BUS=3D=3D"usb" DRIVER=3D=3D"usb-storage" SYSFS{modalias}=3D=3D"usb:v0A17p004Cd1000dc00dsc00dp00ic08isc05ip50" SYSFS{bInterfaceProtocol}=3D=3D"50" SYSFS{bInterfaceSubClass}=3D=3D"05" SYSFS{bInterfaceClass}=3D=3D"08" SYSFS{bNumEndpoints}=3D=3D"03" SYSFS{bAlternateSetting}=3D=3D" 0" SYSFS{bInterfaceNumber}=3D=3D"00" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2': ID=3D=3D"2-2.2" BUS=3D=3D"usb" DRIVER=3D=3D"usb" SYSFS{configuration}=3D=3D"" SYSFS{product}=3D=3D"PENTAX OPTIO S5n" SYSFS{manufacturer}=3D=3D"PENTAX" SYSFS{maxchild}=3D=3D"0" SYSFS{version}=3D=3D" 2.00" SYSFS{devnum}=3D=3D"16" SYSFS{speed}=3D=3D"12" SYSFS{bMaxPacketSize0}=3D=3D"64" SYSFS{bNumConfigurations}=3D=3D"2" SYSFS{bDeviceProtocol}=3D=3D"00" SYSFS{bDeviceSubClass}=3D=3D"00" SYSFS{bDeviceClass}=3D=3D"00" SYSFS{bcdDevice}=3D=3D"1000" SYSFS{idProduct}=3D=3D"004c" SYSFS{idVendor}=3D=3D"0a17" SYSFS{bMaxPower}=3D=3D"100mA" SYSFS{bmAttributes}=3D=3D"c0" SYSFS{bConfigurationValue}=3D=3D"1" SYSFS{bNumInterfaces}=3D=3D" 1" looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2': ID=3D=3D"2-2" BUS=3D=3D"usb" DRIVER=3D=3D"usb" SYSFS{configuration}=3D=3D"" SYSFS{product}=3D=3D"USB Hub" SYSFS{maxchild}=3D=3D"4" SYSFS{version}=3D=3D" 1.10" SYSFS{devnum}=3D=3D"3" SYSFS{speed}=3D=3D"12" SYSFS{bMaxPacketSize0}=3D=3D"8" SYSFS{bNumConfigurations}=3D=3D"1" SYSFS{bDeviceProtocol}=3D=3D"00" SYSFS{bDeviceSubClass}=3D=3D"00" SYSFS{bDeviceClass}=3D=3D"09" SYSFS{bcdDevice}=3D=3D"0305" SYSFS{idProduct}=3D=3D"0604" SYSFS{idVendor}=3D=3D"05e3" SYSFS{bMaxPower}=3D=3D"100mA" SYSFS{bmAttributes}=3D=3D"e0" SYSFS{bConfigurationValue}=3D=3D"1" SYSFS{bNumInterfaces}=3D=3D" 1" looking at device '/devices/pci0000:00/0000:00:02.0/usb2': ID=3D=3D"usb2" BUS=3D=3D"usb" DRIVER=3D=3D"usb" SYSFS{configuration}=3D=3D"" SYSFS{serial}=3D=3D"0000:00:02.0" SYSFS{product}=3D=3D"OHCI Host Controller" SYSFS{manufacturer}=3D=3D"Linux 2.6.16.11 ohci_hcd" SYSFS{maxchild}=3D=3D"10" SYSFS{version}=3D=3D" 1.10" SYSFS{devnum}=3D=3D"1" SYSFS{speed}=3D=3D"12" SYSFS{bMaxPacketSize0}=3D=3D"64" SYSFS{bNumConfigurations}=3D=3D"1" SYSFS{bDeviceProtocol}=3D=3D"00" SYSFS{bDeviceSubClass}=3D=3D"00" SYSFS{bDeviceClass}=3D=3D"09" SYSFS{bcdDevice}=3D=3D"0206" SYSFS{idProduct}=3D=3D"0000" SYSFS{idVendor}=3D=3D"0000" SYSFS{bMaxPower}=3D=3D" 0mA" SYSFS{bmAttributes}=3D=3D"e0" SYSFS{bConfigurationValue}=3D=3D"1" SYSFS{bNumInterfaces}=3D=3D" 1" looking at device '/devices/pci0000:00/0000:00:02.0': ID=3D=3D"0000:00:02.0" BUS=3D=3D"pci" DRIVER=3D=3D"ohci_hcd" SYSFS{modalias}=3D=3D"pci:v000010DEd0000005Asv00001043sd0000815Abc0Csc0= 3i10" SYSFS{local_cpus}=3D=3D"ff" SYSFS{irq}=3D=3D"21" SYSFS{class}=3D=3D"0x0c0310" SYSFS{subsystem_device}=3D=3D"0x815a" SYSFS{subsystem_vendor}=3D=3D"0x1043" SYSFS{device}=3D=3D"0x005a" SYSFS{vendor}=3D=3D"0x10de" looking at device '/devices/pci0000:00': ID=3D=3D"pci0000:00" BUS=3D=3D"" DRIVER=3D=3D"" Simon. --=20 [ "And what do we burn apart from witches?" "*More* witches!" ] Black Cat Networks. http://www.blackcatnetworks.co.uk/ --3ozdenm5Azl6mQ8k Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFEkmYtMQdl+99c4rQRAl33AJ9txgmZ3aC9QVZ9pZmZ7nmFZCwzNACeKTUR w0CAlRD/qAzBGPnV+k0TyKg= =p6KC -----END PGP SIGNATURE----- --3ozdenm5Azl6mQ8k-- --===============2085009557== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline --===============2085009557== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============2085009557==--