LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 07-01-2017, 12:47 PM   #1
jfdavis0817
LQ Newbie
 
Registered: Jul 2017
Posts: 2

Rep: Reputation: Disabled
detecting usb media from within a c program


developing a c application that must be able to detect when a usb drive has been inserted. What is the best way to do this. it almost appears I need to know the name of the media that is to be inserted before I can access it, this won't work. How do I detect it, find it and access it?
 
Old 07-01-2017, 01:20 PM   #2
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
You can use udev. Either change the rule for USB flash devices, or make a rule for all USB flash devices. You can also monitor for system calls. Or, you can use libudev. See: http://www.signal11.us/oss/udev/
 
1 members found this post helpful.
Old 07-01-2017, 01:24 PM   #3
Mill J
Senior Member
 
Registered: Feb 2017
Location: @127.0.0.1
Distribution: Mint, Void, MX, Haiku, PMOS, Plasma Mobile, and many others
Posts: 1,258
Blog Entries: 2

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Maybe try something like this that calls your app.
https://www.axllent.org/docs/view/au...g-usb-storage/
 
1 members found this post helpful.
Old 07-09-2017, 08:55 AM   #4
jfdavis0817
LQ Newbie
 
Registered: Jul 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
Cool

thanks for the help - I was able to solve my problem with a mash up of stuff from everywhere, I just had no idea where to look to start.
 
  


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
[SOLVED] usb mount point used to be /media/$USER/$LABEL, now /media/usb kaz2100 Debian 2 06-29-2016 07:41 PM
USB devices stop detecting (or un-detecting). Mleahy Linux - Desktop 1 07-31-2011 02:08 AM
Fedora is not detecting CD or DVD media mq15 Linux - Hardware 11 03-19-2010 03:06 PM
Detecting Burnable Media tvynr Linux - Software 5 11-05-2006 08:26 AM
need an idea on detecting USB pen present in user program captainstorm Programming 4 11-26-2003 07:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:04 AM.

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
Open Source Consulting | Domain Registration