LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-21-2005, 04:37 PM   #1
rpz
Member
 
Registered: Mar 2005
Posts: 126

Rep: Reputation: 15
USB storage devices


How can I (in linux of course) enumerate and display info about USB storage devices? For example, if a user plugs in an mp3 player and then calls my program, it should detect it and display amount of available storage, its mount point (if any), vendor & serial number, etc. I have found some info in /proc/bus/usb, but I don't know the rules for parsing this kind of info here, and if there exists an API it would be preferrable.
 
Old 12-21-2005, 09:32 PM   #2
rose_bud4201
Member
 
Registered: Aug 2002
Location: St Louis, MO
Distribution: Xubuntu, RHEL, Solaris 10
Posts: 929

Rep: Reputation: 30
Well, I'd doubt that there's any sort of API
What you'll probably need to do is write a script (or graphical application, whichever you'd prefer) which will literally just go through all the available places to find that sort of information and then display it all for you. You'll get quite a lot from the end of the 'dmesg' command right after you plug the device in; I imagine that if you're using a setup which allows automounting of USB devices then whatever application does the automounting will probably allow you to get the mount information; for available storage you'll probably need to mount the drive and then run 'df' on it; vendor and serial number you may be able to get from dmesg if the information's at all available (it may not be). You can set up udev to automatically mount devices with a given model & serial number to a specified mount point, so you may be able to look more into how udev *gets* that information off of the device.

Not sure whether that helps or not =/
 
Old 12-22-2005, 05:11 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Debian, Mint, Puppy, Raspbian
Posts: 3,433

Rep: Reputation: 203Reputation: 203Reputation: 203
kernel 2.6.0? With devfs?

I did a ls -lrt on /dev to see what the new device is created as.
/dev/sdc?
then put it in my fstab.

I put verbose on in the kernel for storage card messages too.
If there's an easy way I never found it.

If you use gkrellm you can mount stuff with that. It's really nifty as
it's something I'm always running anyway.
You can even eject your CD player.
 
  


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
Speed problem with USB storage devices PhobosK Linux - Hardware 1 10-16-2005 08:35 AM
Mounting USB storage devices COKE CAN Debian 18 08-02-2005 03:14 AM
usb-storage problem with differing devices ta0kira Slackware 1 11-14-2004 01:09 PM
USB storage devices? Valael Fedora 1 08-17-2004 05:24 PM
usb mass storage devices rukinhas Mandriva 1 11-18-2003 08:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration