LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-14-2006, 02:55 AM   #1
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Rep: Reputation: 31
USB Device Mount Points & proc


I am curious (I am still looking myself but I thought tapping into the vast knowledge-base here at LQ might help) if /proc/bus/usb/devices holds any valuable information regarding the /dev/ location of a USB device? If it doesn't hold a direct link to such information, perhaps it holds an indirect link that can be gathered from another file?

I would like to create an array list of USB block-devices by NAME from the /proc/ listing, and, with as little over-head as possible, mount a device based on the array information. For example, I would grab the name and <key> information about the device in array[1], I would then present, by name, a list of devices from the /proc/ listing and upon selection, mount the appropriate device. As I see it now, /proc/ doesn't leave me with much about the actual location of the device as much as information about the device itself.

Thanks, in advance, for any tips/help!
 
Old 05-15-2006, 05:33 PM   #2
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 15
Posts: 546

Rep: Reputation: 43
I suspect you won't find nothing useful in /proc/bus/usb/devices since usb block devices use usb-scsi emulation. Usb block drives/flashes use usb_storage driver that enables scsi emulation. You can find some infos about your device on /proc/scsi/usb-storage/0 (may be a different number according to the number of devices connected to the system), but not infos on where the drive is attached to. On my system I get
cat /proc/scsi/usb-storage/0
Host scsi0: usb-storage
Vendor: LEXR PLUG DRIVE
Product: LEXR PLUG DRIVE
Serial Number: 000000105071405266050000000000000000000000000
Protocol: Transparent SCSI
Transport: Bulk
Quirks:
If you want to know where you devices are attached (ie usb controller) I'd have a look to udev tools output (only 2.6 kernels) like udevinfo.
Here is a typical output for an usb pendrive

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/sda/sda1':
KERNEL=="sda1"
SUBSYSTEM=="block"
SYSFS{stat}==" 17 136 0 0"
SYSFS{size}=="250592"
SYSFS{start}=="32"
SYSFS{dev}=="8:1"

looking at device '/block/sda':
ID=="sda"
BUS=="block"
DRIVER==""
SYSFS{stat}==" 11 7 144 142 0 0 0 0 0 142 142"
SYSFS{size}=="251904"
SYSFS{removable}=="1"
SYSFS{range}=="16"
SYSFS{dev}=="8:0"

looking at device '/devices/pci0000:00/0000:00:03.1/usb3/3-2/3-2:1.0/host0/target0:0:0/0:0:0:0':
ID=="0:0:0:0"
BUS=="scsi"
DRIVER=="sd"
SYSFS{ioerr_cnt}=="0x1"
SYSFS{iodone_cnt}=="0x18"
SYSFS{iorequest_cnt}=="0x18"
SYSFS{iocounterbits}=="32"
SYSFS{timeout}=="30"
SYSFS{state}=="running"
SYSFS{rev}=="1.01"
SYSFS{model}=="JUMPDRIVE "
SYSFS{vendor}=="LEXAR "
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:03.1/usb3/3-2/3-2:1.0/host0/target0:0:0':
ID=="target0:0:0"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:03.1/usb3/3-2/3-2:1.0/host0':
ID=="host0"
BUS==""
DRIVER==""

looking at device '/devices/pci0000:00/0000:00:03.1/usb3/3-2/3-2:1.0':
ID=="3-2:1.0"
BUS=="usb"
DRIVER=="usb-storage"
SYSFS{interface}=="LEXR PLUG DRIVE"
SYSFS{modalias}=="usb:v05DCp0080d0001dc00dsc00dp00ic08isc06ip50"
SYSFS{bInterfaceProtocol}=="50"
SYSFS{bInterfaceSubClass}=="06"
SYSFS{bInterfaceClass}=="08"
SYSFS{bNumEndpoints}=="02"
SYSFS{bAlternateSetting}==" 0"
SYSFS{bInterfaceNumber}=="00"

looking at device '/devices/pci0000:00/0000:00:03.1/usb3/3-2':
ID=="3-2"
BUS=="usb"
DRIVER=="usb"
SYSFS{configuration}==""
SYSFS{serial}=="000000105071405266050000000000000000000000000"
SYSFS{product}=="LEXR PLUG DRIVE"
SYSFS{manufacturer}=="LEXR PLUG DRIVE"
SYSFS{maxchild}=="0"
SYSFS{version}==" 1.10"
SYSFS{devnum}=="2"
SYSFS{speed}=="12"
SYSFS{bMaxPacketSize0}=="8"
SYSFS{bNumConfigurations}=="1"
SYSFS{bDeviceProtocol}=="00"
SYSFS{bDeviceSubClass}=="00"
SYSFS{bDeviceClass}=="00"
SYSFS{bcdDevice}=="0001"
SYSFS{idProduct}=="0080"
SYSFS{idVendor}=="05dc"
SYSFS{bMaxPower}==" 90mA"
SYSFS{bmAttributes}=="80"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"

looking at device '/devices/pci0000:00/0000:00:03.1/usb3':
ID=="usb3"
BUS=="usb"
DRIVER=="usb"
SYSFS{configuration}==""
SYSFS{serial}=="0000:00:03.1"
SYSFS{product}=="OHCI Host Controller"
SYSFS{manufacturer}=="Linux 2.6.16.9 ohci_hcd"
SYSFS{maxchild}=="3"
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}=="c0"
SYSFS{bConfigurationValue}=="1"
SYSFS{bNumInterfaces}==" 1"

looking at device '/devices/pci0000:00/0000:00:03.1':
ID=="0000:00:03.1"
BUS=="pci"
DRIVER=="ohci_hcd"
SYSFS{modalias}=="pci:v00001039d00007001sv00001043sd0000810Ebc0Csc03i10"
SYSFS{local_cpus}=="1"
SYSFS{irq}=="21"
SYSFS{class}=="0x0c0310"
SYSFS{subsystem_device}=="0x810e"
SYSFS{subsystem_vendor}=="0x1043"
SYSFS{device}=="0x7001"
SYSFS{vendor}=="0x1039"

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

No idea how to use such infos for your purpose (let me say it is rather unusual)
Hope this helps
Ciao
 
Old 05-15-2006, 06:39 PM   #3
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Original Poster
Rep: Reputation: 31
That is, indeed, useful information.

I want to make the interface more natural for a piece of software that mounts devices (it is my introductory project into C); it doesn't seem intuitive to mount a device based on device locations, so I'd like to give actual device names. Just a little problem I find interesting. There is probably a better way but I sure don't know about it


Thanks for the great info, I will pursue it and see where it takes me.

*EDIT* It doesn't mount them as its whole purpose, it will simply mount a device if it needs *EDIT*

*EDIT2* With your guidance above, I found my way to The Linux SCSI Generic (sg) HOWTO, which will work on both 2.4 and 2.6 kernels. It provides me with the means to derive device information via the /dev/location I will post back with the final version (C code, probably) of the code that makes the connection between the device as mapped on the system and the actual device information (name, manufacturer, etc). I am most appreciative of your post and guidance. *EDIT2.

Last edited by flower.Hercules; 05-15-2006 at 09:33 PM.
 
Old 05-16-2006, 05:03 AM   #4
urka58
Member
 
Registered: Nov 2003
Distribution: slackware 15
Posts: 546

Rep: Reputation: 43
I'd be glad to see your work posted when finished.
I'm very curious ....
Ciao
 
Old 05-16-2006, 10:58 PM   #5
flower.Hercules
Member
 
Registered: Aug 2005
Distribution: Gentoo
Posts: 228

Original Poster
Rep: Reputation: 31
Huge Edit!

I proposed a terribly inefficient (and ultimately impossible) method to determine where a device is located and its name....however, it is much more simple.

The SCSI interface provides all the necessary information. I'm sorry I don't have an update, this seems like a spam post but I don't believe LQ has a way of deleting your messages.

Given the nature of my program, it will sometimes be confusing linking the SCSI subsystem information with the USB device information as many USB devices are made with purchased hardware (such as an MP3 player being made by company X with company Y's hard-drive inside, in this case, the SCSI inquiry will return the hard-drive device information, whereas, the USB device will return the expected information).

Last edited by flower.Hercules; 05-16-2006 at 11:13 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount points on usb devices (dig. camera, zip drive, external hard disk) Impaler Linux - Hardware 3 05-30-2006 12:08 AM
Mount points for USB dvices incl. dig. camera Impaler Linux - Hardware 7 04-03-2004 02:07 AM
HP Deskjet (USB) & CUPS & Slackware 9.1: Unable to open USB device "usb:/dev/usb/lp0&qu arnostienen Slackware 2 01-29-2004 04:22 PM
can't mount USB device rob_xx17 Linux - Hardware 2 01-26-2004 06:41 PM
how can I mount this device: da0: <USB 2.0 Storage Device alkad_mzu *BSD 2 11-15-2003 07:15 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 02:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration