linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* udev doesn't know about devices further up the tree.
@ 2006-06-16  8:05 Simon Huggins
  2006-06-16  8:35 ` Kay Sievers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Huggins @ 2006-06-16  8:05 UTC (permalink / raw)
  To: linux-hotplug


[-- Attachment #1.1: Type: text/plain, Size: 5787 bytes --]

Hi,

I wrote my first udev rule the other day.

It reads:
KERNEL=="sd*", PROGRAM="/home/huggie/bin/camera %k", SYMLINK+="%c"
where bin/camera does:
DEV=$1
DISK=`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 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 device '/block/sdc/sdc1':
    KERNEL=="sdc1"
    SUBSYSTEM=="block"
    SYSFS{stat}=="     350      350        0        0"
    SYSFS{size}=="1002455"
    SYSFS{start}=="41"
    SYSFS{dev}=="8:33"

  looking at device '/block/sdc':
    ID=="sdc"
    BUS=="block"
    DRIVER==""
    SYSFS{stat}=="      23      328      358      302        0        0        0        0        0      302      302"
    SYSFS{size}=="1002496"
    SYSFS{removable}=="1"
    SYSFS{range}=="16"
    SYSFS{dev}=="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=="16:0:0:0"
    BUS=="scsi"
    DRIVER=="sd"
    SYSFS{ioerr_cnt}=="0x0"
    SYSFS{iodone_cnt}=="0x27"
    SYSFS{iorequest_cnt}=="0x27"
    SYSFS{iocounterbits}=="32"
    SYSFS{timeout}=="30"
    SYSFS{state}=="running"
    SYSFS{rev}=="1.00"
    SYSFS{model}=="DIGITAL_CAMERA  "
    SYSFS{vendor}=="PENTAX  "
    SYSFS{scsi_level}=="3"
    SYSFS{type}=="0"
    SYSFS{queue_type}=="none"
    SYSFS{queue_depth}=="1"
    SYSFS{device_blocked}=="0"
    SYSFS{max_sectors}=="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=="target16:0:0"
    BUS==""
    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:1.0/host16':
    ID=="host16"
    BUS==""
    DRIVER==""

  looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2/2-2.2:1.0':
    ID=="2-2.2:1.0"
    BUS=="usb"
    DRIVER=="usb-storage"
    SYSFS{modalias}=="usb:v0A17p004Cd1000dc00dsc00dp00ic08isc05ip50"
    SYSFS{bInterfaceProtocol}=="50"
    SYSFS{bInterfaceSubClass}=="05"
    SYSFS{bInterfaceClass}=="08"
    SYSFS{bNumEndpoints}=="03"
    SYSFS{bAlternateSetting}==" 0"
    SYSFS{bInterfaceNumber}=="00"

  looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2/2-2.2':
    ID=="2-2.2"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{product}=="PENTAX OPTIO S5n"
    SYSFS{manufacturer}=="PENTAX"
    SYSFS{maxchild}=="0"
    SYSFS{version}==" 2.00"
    SYSFS{devnum}=="16"
    SYSFS{speed}=="12"
    SYSFS{bMaxPacketSize0}=="64"
    SYSFS{bNumConfigurations}=="2"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="00"
    SYSFS{bcdDevice}=="1000"
    SYSFS{idProduct}=="004c"
    SYSFS{idVendor}=="0a17"
    SYSFS{bMaxPower}=="100mA"
    SYSFS{bmAttributes}=="c0"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:02.0/usb2/2-2':
    ID=="2-2"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{product}=="USB Hub"
    SYSFS{maxchild}=="4"
    SYSFS{version}==" 1.10"
    SYSFS{devnum}=="3"
    SYSFS{speed}=="12"
    SYSFS{bMaxPacketSize0}=="8"
    SYSFS{bNumConfigurations}=="1"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="09"
    SYSFS{bcdDevice}=="0305"
    SYSFS{idProduct}=="0604"
    SYSFS{idVendor}=="05e3"
    SYSFS{bMaxPower}=="100mA"
    SYSFS{bmAttributes}=="e0"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:02.0/usb2':
    ID=="usb2"
    BUS=="usb"
    DRIVER=="usb"
    SYSFS{configuration}==""
    SYSFS{serial}=="0000:00:02.0"
    SYSFS{product}=="OHCI Host Controller"
    SYSFS{manufacturer}=="Linux 2.6.16.11 ohci_hcd"
    SYSFS{maxchild}=="10"
    SYSFS{version}==" 1.10"
    SYSFS{devnum}=="1"
    SYSFS{speed}=="12"
    SYSFS{bMaxPacketSize0}=="64"
    SYSFS{bNumConfigurations}=="1"
    SYSFS{bDeviceProtocol}=="00"
    SYSFS{bDeviceSubClass}=="00"
    SYSFS{bDeviceClass}=="09"
    SYSFS{bcdDevice}=="0206"
    SYSFS{idProduct}=="0000"
    SYSFS{idVendor}=="0000"
    SYSFS{bMaxPower}=="  0mA"
    SYSFS{bmAttributes}=="e0"
    SYSFS{bConfigurationValue}=="1"
    SYSFS{bNumInterfaces}==" 1"

  looking at device '/devices/pci0000:00/0000:00:02.0':
    ID=="0000:00:02.0"
    BUS=="pci"
    DRIVER=="ohci_hcd"
    SYSFS{modalias}=="pci:v000010DEd0000005Asv00001043sd0000815Abc0Csc03i10"
    SYSFS{local_cpus}=="ff"
    SYSFS{irq}=="21"
    SYSFS{class}=="0x0c0310"
    SYSFS{subsystem_device}=="0x815a"
    SYSFS{subsystem_vendor}=="0x1043"
    SYSFS{device}=="0x005a"
    SYSFS{vendor}=="0x10de"

  looking at device '/devices/pci0000:00':
    ID=="pci0000:00"
    BUS==""
    DRIVER==""


Simon.

-- 
[ "And what do we burn apart from witches?"   "*More* witches!"        ]
        Black Cat Networks.  http://www.blackcatnetworks.co.uk/

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



[-- Attachment #3: Type: text/plain, Size: 226 bytes --]

_______________________________________________
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-06-16  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-16  8:05 udev doesn't know about devices further up the tree Simon Huggins
2006-06-16  8:35 ` Kay Sievers
2006-06-16  8:50 ` Simon Huggins
2006-06-16  8:57 ` Kay Sievers

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).