Detect when a USB device is connected in C
c, linux, usb
Solution
Look into udev documentation for this (writing udev rules).
Also have a look at this stackoverflow thread.
Problem
I am new to C and am trying to write a program that syncs files on my computer to a USB device. It currently works my me cd'ing to the directory that the device mounts to and typing "myprog init" which creates a .myprog file. The idea then is that when a USB device is connected my program checks for the .myprog file, if it finds it then it syncs. Problem is that I can't figure out how to detect when a new USB device is connected. I am writing the program for Linux (I'm using Ubuntu 9.04) and using GCC. Thanks for any help :)