linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: sysfs content varies among instances
Date: Fri, 04 Nov 2005 17:15:12 +0000	[thread overview]
Message-ID: <20051104171512.GC13975@kroah.com> (raw)
In-Reply-To: <IPFM96$A744B6ABED816326F4FE4E47B56A8815@libero.it>

On Fri, Nov 04, 2005 at 02:17:30PM +0100, Matteo Semplice wrote:
> Hi everybody. I'm no developer, but am trying to figure out a proper
> udev rule for my (el-cheapo) usb pen drive (in particular to SYMLINK
> it to /media/myusbpen). Much investigation, doc reading, attempts,
> lead me to find out an odd behaviour in the creation of the /sys
> filesystem.
> 
> The problem is that each time I plug in the pen drive, I get different
> "vendor" and "product" fields in the /sys filesystem...

Then you have a very strange usb device :)

> I run a 2.6.13.3 custom-built kernel plus the udev and hal packages
> from the Debian sarge distribution.
> 
> First of all, the correct vendor and product info for my card are in
> the directory /sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/
> but /sys/block/sda/device points to a subdirectory of that one, which
> does not contain the correct vendor/product files (precisely to
> /sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host1/target1:0:0/1:0:0:0)
> 
> Is this correct?

Yes, the vendor/product files are for the usb _device_ not the usb
_interface_ which is what the usb-storage driver binds to, and the sda
device is created for.

> Further, after plugging the usb pen in a usb port,
>  udevinfo -a -p $(udevinfo -q path -n /dev/sda)
> tells me:
> matteo@roccia:/etc/hotplug$ udevinfo -a -p $(udevinfo -q path -n /dev/sda)
> 
> 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.
> 
> device '/sys/block/sda' has major:minor 8:0
>   looking at class device '/sys/block/sda':
>     SUBSYSTEM="block"
>     SYSFS{dev}="8:0"
>     SYSFS{range}="16"
>     SYSFS{removable}="1"
>     SYSFS{size}="1019617"
>     SYSFS{stat}="       6      234      240      204        0        0        0        0        0      134      204"
> 
> follow the class device's "device"
>   looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host1/target1:0:0/1:0:0:0':
>     BUS="scsi"
>     ID="1:0:0:0"
>     DRIVER="sd"
>     SYSFS{device_blocked}="0"
>     SYSFS{iocounterbits}="32"
>     SYSFS{iodone_cnt}="0xc9a"
>     SYSFS{ioerr_cnt}="0x0"
>     SYSFS{iorequest_cnt}="0xc9a"
>     SYSFS{max_sectors}="240"
>     SYSFS{model}=".2"
>     SYSFS{queue_depth}="1"
>     SYSFS{queue_type}="none"
>     SYSFS{rev}=""
>     SYSFS{scsi_level}="3"
>     SYSFS{state}="running"
>     SYSFS{timeout}="30"
>     SYSFS{type}="0"
>     SYSFS{vendor}="linux.so"
> 
> but I can also get (plugging it in the very same port)
> [...]
> follow the class device's "device"
>   looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host8/target8:0:0/8:0:0:0':
>     BUS="scsi"
>     ID="8:0:0:0"
>     DRIVER="sd"
>     SYSFS{device_blocked}="0"
>     SYSFS{iocounterbits}="32"
>     SYSFS{iodone_cnt}="0xb2"
>     SYSFS{ioerr_cnt}="0x0"
>     SYSFS{iorequest_cnt}="0xb2"
>     SYSFS{max_sectors}="240"
>     SYSFS{model}="ric/sg1"
>     SYSFS{queue_depth}="1"
>     SYSFS{queue_type}="none"
>     SYSFS{rev}=""
>     SYSFS{scsi_level}="3"
>     SYSFS{state}="running"
>     SYSFS{timeout}="30"
>     SYSFS{type}="0"
>     SYSFS{vendor}="csi_gene"
> 
> or even
> [...]
> follow the class device's "device"
>   looking at the device chain at '/sys/devices/pci0000:00/0000:00:10.1/usb2/2-2/2-2:1.0/host9/target9:0:0/9:0:0:0':
>     BUS="scsi"
>     ID="9:0:0:0"
>     DRIVER="sd"
>     SYSFS{device_blocked}="0"
>     SYSFS{iocounterbits}="32"
>     SYSFS{iodone_cnt}="0x8e"
>     SYSFS{ioerr_cnt}="0x0"
>     SYSFS{iorequest_cnt}="0x8e"
>     SYSFS{max_sectors}="240"
>     SYSFS{model}=""
>     SYSFS{queue_depth}="1"
>     SYSFS{queue_type}="none"
>     SYSFS{scsi_level}="3"
>     SYSFS{state}="running"
>     SYSFS{timeout}="30"
>     SYSFS{type}="0"
>     SYSFS{vendor}=""
> 
> Note in particular that the vendor and model names keep changing. (And
> I seem to be cycling through these 3 results)

These are the scsi vendor and model names, not the USB names.  Try
looking up the chain a few levels to see the USB one (where BUS="usb").

Hope this helps,

greg k-h


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
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

      reply	other threads:[~2005-11-04 17:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-04 13:17 sysfs content varies among instances Matteo Semplice
2005-11-04 17:15 ` Greg KH [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051104171512.GC13975@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).