Results 1 to 4 of 4
Hi. I have an application that I have written for an embedded linux device. I believe it is a monta vista distro. (If that matters.)
I want my application to ...
- 05-06-2008 #1Just Joined!
- Join Date
- Mar 2008
- Posts
- 2
Recognize USB device insertion/removal in my application
Hi. I have an application that I have written for an embedded linux device. I believe it is a monta vista distro. (If that matters.)
I want my application to be able to tell when a USB storage device is inserted/removed. I can plug in a USB key and then do a couple of commands and now I have it mounted as part of the file system. That's nice, but now I want the application to get called when this happens and be able to issue commands to mount it as part of the file system and then start doing stuff if it sees certain things in that part of the file system (i.e. I want it to validate a certificate on the device and then read a file and take some actions based on the content of the file.)
This is a small feature that I want to add to a larger existing C program.
I'm not sure where to go to find out how to do this. Its not a driver - its just that I want to be called at the application level when the disk is inserted and get whatever info I need to mount it.
Right now, I'm mounting the disk using:
mknod /dev/sda1 b 8 1
mkdir -p /mnt/usb
mount -t vfat /dev/sda1 /mnt/usb
I'm issuing these commands from the terminal after I insert the usb key. After I get the event, then I'll issue these via a system call from my C program. I'm thinking that if I were using a different kind of usb key or a hard drive, then maybe the commands might have to be different. Also, the above commands assume that the device is formatted using FAT which it might be something else (maybe I'll just choose to support only FAT?) I also don't want it to get called if the user inserts something that isn't a storage device (like a microphone or some weird usb device - I don't support that, but I just want it to not crash if the user does that).
Can someone point me to the right direction on this? What C APIs I might use?
- 10-28-2008 #2Just Joined!
- Join Date
- Oct 2008
- Posts
- 2
Recognize USB device insertion/removal in my application
Hi Everybody,
I am also developing the application which needs to detect USB devices automatically and need to show the device in GUI.
Please help me in this.
Thanks in Advance,
Natarajan
- 06-12-2009 #3Just Joined!
- Join Date
- May 2009
- Posts
- 8
- 06-12-2009 #4Linux User
- Join Date
- May 2008
- Location
- NYC, moved from KS & MO
- Posts
- 251
This should help you:
Writing udev rules



