LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions
User Name
Password
Linux - Distributions This forum is for Distribution specific questions.
Red Hat, Slackware, Debian, Novell, LFS, Mandriva, Ubuntu, Fedora - the list goes on and on... Note: An (*) indicates there is no official participation from that distribution here at LQ.

Notices

Reply
 
Search this Thread
Old 09-16-2009, 05:58 AM   #1
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Rep: Reputation: 15
Distinguish between USB HDD & USB Pen drive


Hi,
I want to differentiate a USB HDD from a USB Pen driver from my application by just reading the USB device/interface descriptors. I observed in both the cases the following are the same:
Device Class - 0x00
InterfaceClass - 0x08
InterfaceSubClass - 0x06
InterfaceProtocol - 0x50
That why I am not able to distinguish these two.

Any idea is appreciated.
Thanks in advance.

Regards,
Deb
 
Old 09-16-2009, 07:09 AM   #2
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
hi

try lsusb....for ids then create udev rule

http://www.reactivated.net/writing_udev_rules.html

Last edited by aus9; 09-16-2009 at 07:20 AM.
 
Old 09-17-2009, 08:26 AM   #3
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Hi aus9,

No I am trying to find all the device descriptors from my application without using libusb & UDEV. Actually I can retrieve all the descriptors but couldn't distinguish USB HDD & USB Pen drive.

Regards,
Deb
 
Old 09-17-2009, 07:19 PM   #4
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
hmm well not sure what you are attempting but udev and its tools can get you information on serial numbers which may be the easiest way to distinguish between devices?
 
Old 09-17-2009, 11:30 PM   #5
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Ok, even if I use LibUSB, can you tell me how can I identify if the inserted device is Hard disk or Pen drive? Only thing I can tell that the inserted device is Mass Storage Device. That also from the Interface Class number.

Regards,
Deb
 
Old 09-18-2009, 12:47 AM   #6
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
hi

well I still do not understand what the issue.

Maybe you can be more verbose?

2) in my file manager...my hal and udev so my device names are different for my 2 usb sticks....sorry don't own an usb hd.

here is one way to see it thru the file manager...Your pathway may differ...its to give you an idea?

/sys/block/sdb/device/vendor


or by command cat /pathway above/vendor shows my usb makername.

which for me is easy as my other usb is different coy name.

3) so if same coy name you could look at a different file?
model...for me shows flash disk whereas the hd may show different?

/sys/block/sdb/size maybe useful?

4) if you like commands try inserting one usb device at a time and running with root powers

tail -n 20 /var/log/messages

mine shows usb serial number
 
Old 09-18-2009, 01:12 AM   #7
paldebojyoti
Member
 
Registered: Aug 2009
Posts: 32

Original Poster
Rep: Reputation: 15
Hi aus9,

Ok let me give you all the information behind my question.

I want to write an application which will identify any inserted or attached USB device without using LibUSB. From the Sysfs my applicatin can retrieve all the USB related information (i.e. device descriptors) about all the connected USB devices. From the device descriptors, the application can easily identify whether the connected device is USB mouse or USB BT Dongle or USB Mass Storage Device, but what it couldn't identify is whether the connected Mass storage device is USB HDD or USB Pen Drive as in both the cases, all the device descriptors are same.

My development PC is Ubuntu 8.10.

Regards,
Dev
 
Old 09-18-2009, 07:02 AM   #8
aus9
Guru
 
Registered: Oct 2003
Posts: 5,060

Rep: Reputation: Disabled
ahh ok.

edit

I still think udev rule will identify the correct devices because you can create an ATTRS udev rule because your log tells you the serial numbers

otherwise if you refuse to write udev rule....create a script with an if then

if cat /var/log/messages | grep (serialnumberfor pen)....then device is sdx
ditto for hd...and you may need to post to programming forum now that I can not help you

Last edited by aus9; 09-18-2009 at 07:05 AM.
 
  


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
USB Pen Drive not detected in Linux (suse & Ubuntu) working fine in windows XP Ayyappan Linux - Newbie 9 02-22-2012 09:43 AM
HowTo use USB pen drive as Loader for iso distros on HDD belbono Linux - General 5 08-22-2008 07:17 AM
read & write USB pen drive?? wrangler Linux - Newbie 5 03-08-2005 03:11 PM
USB Pen drive & camera - Auto sort? r_jensen11 Linux - Hardware 1 07-22-2004 11:07 PM
FreeBSD 5.1 & USB Pen Drive Crito *BSD 5 12-27-2003 12:08 AM


All times are GMT -5. The time now is 10:14 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration