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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
06-12-2006, 02:44 PM
|
#1
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Rep:
|
mapping usb device to device file
Hello,
I've been searching google for a while now for a way to do this and have come up more or less empty handed. I need to list the usb devices (flash card readers) attached to my computer in my program. The problem is that I can't find a good way to figure out what device file each reader corresponds to. I initially tried dmesg which would give me the device names and tell me it was attached to /dev/sdb or some such, but dmesg is very unreliable when I hotplug a new device in or unplug one. The only file I've found which really gives accurate information about what is actually plugged in is in /proc/bus/usb/devices. Unfortunately, I can't find a way to map the information in that file to /dev/sdb or /dev/sdc. The closest i've foudn is sg_scan and sg_map but sg_map crashes my whole system and sg_scan doesn't seem to work too well with hotplugging. fdisk -l will tell me what disks are mapped to where, but I can't find a correlation to the devices file with the names (I also need to be able to tell that they are actually usb readers).
PS- I'm running redhat 8.
Any help would be much appreciated,
-Scerenon
|
|
|
06-12-2006, 06:36 PM
|
#2
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Quote:
Originally Posted by scerenon
PS- I'm running redhat 8.
|
Why? I don't know remember how the older kernels did it, but nowadays, there is udev which lets you create rules for persistent naming of usb (and other) devices. I'm almost positive that there's also an entry in /proc somewhere.
Consider getting a more up-to-date distro.
|
|
|
06-12-2006, 07:20 PM
|
#3
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
I have heard of udev, unfortunately it isn't on rh 8. I need redhat 8 as I need a proprietary app to run on it that only wants to build under rh8. I could try to get it working on newer distros, but it would make my life much easeier if I could just figure out how to solve the device file mapping problem.
Last edited by scerenon; 06-12-2006 at 07:22 PM.
|
|
|
06-12-2006, 08:23 PM
|
#4
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Did you check the /proc filesystem?
|
|
|
06-13-2006, 11:57 AM
|
#5
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by osor
Did you check the /proc filesystem?
|
Thank you for your reply.
I've read through the /proc filesystem and the only file i've found in /proc that is really useful is /proc/bus/usb/devices which I mentioned above. Can you be more specific please?
-thanks
|
|
|
06-13-2006, 12:49 PM
|
#6
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
I'm sorry, I don't think the /sys interface is available in 2.4. I thought maybe /proc might have similar information. Can you post the output of devfsd.conf or equivalent.
|
|
|
06-13-2006, 01:46 PM
|
#7
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
# Sample /etc/devfsd.conf configuration file.
# Richard Gooch <rgooch@atnf.csiro.au> 3-JUL-2000
#
# Enable full compatibility mode for old device names. You may comment these
# out if you don't use the old device names. Make sure you know what you're
# doing!
REGISTER .* MKOLDCOMPAT
UNREGISTER .* RMOLDCOMPAT
# You may comment out the above and uncomment the following if you've
# configured your system to use the original "new" devfs names or the really
# new names
#REGISTER vc/.* MKOLDCOMPAT
#UNREGISTER vc/.* RMOLDCOMPAT
#REGISTER pty/.* MKOLDCOMPAT
#UNREGISTER pty/.* RMOLDCOMPAT
#REGISTER misc MKOLDCOMPAT
#UNREGISTER misc RMOLDCOMPAT
# You may comment these out if you don't use the original "new" names
REGISTER .* MKNEWCOMPAT
UNREGISTER .* RMNEWCOMPAT
# Enable module autoloading. You may comment this out if you don't use
# autoloading
LOOKUP .* MODLOAD
#
# Uncomment this if you want permissions to be saved and restored
#REGISTER .* COPY /dev-state/$devname $devpath
#CHANGE .* COPY $devpath /dev-state/$devname
#CREATE .* COPY $devpath /dev-state/$devname
|
|
|
06-14-2006, 05:30 PM
|
#8
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
Quote:
Originally Posted by osor
I'm sorry, I don't think the /sys interface is available in 2.4. I thought maybe /proc might have similar information. Can you post the output of devfsd.conf or equivalent.
|
Oh yes, and I do have the /proc/sys folder if that's what you meant, it contains the following:
abi, debug, dev, fs, kernel, net, proc, vm
|
|
|
06-14-2006, 05:46 PM
|
#9
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
Quote:
Originally Posted by scerenon
Oh yes, and I do have the /proc/sys folder if that's what you meant, it contains the following:
abi, debug, dev, fs, kernel, net, proc, vm
|
No that's not the same (/sys != /proc/sys). The `/sys' folder is part of the new kernel device scheme (along with udev) which is only for 2.6 kernels.
Right now, (as I'm in the process of digesting your conf file,) I'm trying to remember how devfsd worked. I'm pretty sure that's where you'll find the answer to your problem, I'm just a little rusty on the details (it took me so long to become comfortable with udev!).
P.S.
Are you sure you want to continue with the old distro? You might be able to build or run the proprietary app on newer distros just by downloading a bunch of `legacy' libraries and old versions of gcc, etc., etc (unless your app is closely tied to the kernel). Your best bet might be to get a nice shiny new distro, and load your old setup as a virtual machine (I hear that's all the rage these days). The purpose of the virtual machine would be run only your prop. app.
|
|
|
06-15-2006, 05:50 PM
|
#10
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
Actually that's exactly what I'm doing. My app launches vmware in the background to run the program in linux as I was tasked to get it working on windows ( I communicate with the linux distro through the virtual network). The person that originally worked on it has suffered some health problems so changing anything or building a new one on windows would take more time than I have as I am not very familiar with it. It's kind of a clunky solution to be sure, but it's working for the most part... aside from the fact that I always assume the device file is sdb which isn't always the case.
I will take a more in depth look at devfs and let you know if I find anything, kind of depressing that someone couldn't have made a simple app like this 6 years ago though on linux, there must be a way that doesn't involve hacking the kernel.
|
|
|
06-15-2006, 06:23 PM
|
#11
|
HCL Maintainer
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450
Rep:
|
If you're running a linux distro on a virtual machine in windows, why do you need usb hotplugging to work? Just wondering.
|
|
|
06-16-2006, 01:21 PM
|
#12
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
I list the devices with names to the user in windows, and then they can select one to operate on. So the windows app just queries the linux one for a list of devices, user selects the name they want ( like imagemate 6 in 1 64mb) and linux does the operations on it. If someone were to have an external harddrive plugged in and then plug in a usb card and my program incorrectly used the wrong device file and formatted their external hard drive, it would not be good to say the least. Of course they could just use linux directly, but that is not up to me.
|
|
|
07-20-2006, 04:13 PM
|
#13
|
LQ Newbie
Registered: Jun 2006
Posts: 8
Original Poster
Rep:
|
I figured it out! ... mostly.
I was having trouble to get devfs to work correctly. I found out that it was incorrectly built into the kernel, so i tried recompiling the kernel with /dev support enabled but I kept getting errors with it on make install.
The solution I found without devfs was to use a combination of /proc/bus/usb/devices and /var/log/messages as they both list the "device number". varlogmessages will tell me what devices number was assigned to what product, and then further up it will tell me when the product was first plugged in what device file it was plugged into.
|
|
|
All times are GMT -5. The time now is 05:43 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|