Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 10-24-2006, 02:31 PM   #1
LQ Newbie
Registered: Oct 2006
Posts: 2

Rep: Reputation: 0
user-space notification of USB device attached/detached

I have a user-space application that needs to be notified when a USB device has just been attached or detached (hot plugged/unplugged). Can someone tell me how to setup or register for such a notification? I'm running embedded linux 2.6.

I want to be notified of any type of USB device. But just for starters, I'm using a USB Memory Stick. I've loaded all of the necessary drivers:
modprobe ehci-hcd
modprobe usb-storage
modprobe sg
modprobe sd_mod
modprobe vfat
modprobe msdos
modprobe nls_iso8859-1
modprobe nls_cp437
and when I attach or detach the USB Memory Stick, I do see debug traces indicating the attachment/detachment. I can also manually mount the device (/dev/sda1) and read and write files on it. Now, I just need my user-space app to automatically get the attach/detach notifications so it knows when it can read and write the USB Memory Stick.


Last edited by rhardy; 10-24-2006 at 03:03 PM.
Old 10-25-2006, 09:31 AM   #2
Registered: Oct 2006
Location: Cp6uja
Distribution: Slackware each x86 + ARM and Porteus
Posts: 658

Rep: Reputation: 46

Make use of code in my project if you will...

there is a thread:

where you can find link to SF ...

or see the hotplug hooks mentioned in this thread (There is a nifty script you could use?)


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
user-space notification of USB device attached/detached rhardy Linux - Software 1 10-24-2006 04:17 PM
Retrieve write protect state of USB device in user space GeertPh Linux - Software 0 10-03-2006 02:25 AM
GMplayer Attached/Detached Skin sadarax Linux - Software 1 04-24-2006 08:15 AM
dm does not load if usb device attached grey man Mandriva 1 03-17-2006 11:48 AM
callback or notification from kernel to user space yhus Programming 5 09-18-2005 10:41 PM

All times are GMT -5. The time now is 07:57 PM.

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