I'm using Linux Inotify to detect FS events on my program.
How could I be notified when a device is mounted on a monitored directory?
I'm using Linux Inotify to detect FS events on my program.
How could I be notified when a device is mounted on a monitored directory?
I don't think you can do it with inotify
. Here is the method though:
"ACTION"
is not "mount"
."/proc/mounts"
when you get an event with a "mount"
action.If you don't mind depending on fairly new libraries, you could use libudev for the first step.
Again, if you don't mind depending on new stuff and DBus, DeviceKit-Disks will do all of this for you, too. You'd hook into the DeviceChanged signal, and then look at the device-mount-paths property.