LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   USB storage devices (https://www.linuxquestions.org/questions/programming-9/usb-storage-devices-395375/)

rpz 12-21-2005 03:37 PM

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.

rose_bud4201 12-21-2005 08:32 PM

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 =/

bigearsbilly 12-22-2005 04:11 AM

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.


All times are GMT -5. The time now is 06:35 AM.